This Example will teach you how to do the Java Color Change step by step Paste the Code inside the ok button 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.
Java Color Change Example


