This Example will teach you how to do the Java Color Change step by step
Paste the Code inside the ok button
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | String name = txtName.getText(); if(Option.getSelectedItem().equals("Red")) { txtMsg.setText(name); txtMsg.setForeground(Color.RED); } else if(Option.getSelectedItem().equals("Green")) { txtMsg.setText(name); txtMsg.setForeground(Color.GREEN); } else { txtMsg.setText(name); txtMsg.setForeground(Color.BLUE); } |
i have attached the video link below. which will do this tutorials step by step.