Я пытаюсь создать простую программу, которая изменяет текст в некоторых текстовых полях при нажатии определенной кнопки. Это мой первый раз с Java, поэтому я не уверен, что я пропустил. Вот мой код.java objects, and frame not working
public abstract class DoctorOption extends JFrame implements ActionListener {
JTextField myTxt = new JTextField(30);
JButton submit = new JButton("Submit");
JRadioButton mywellRB = new JRadioButton("click here if you are well", true);
JRadioButton myunwellRB = new JRadioButton("click here if you are unwell", false);
public static void main(String[] args) {
new DoctorOption() {
};
}
public DoctorOption() {
setSize(400, 120);
setTitle("Doctor Option");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
add(myTxt);
add(mywellRB);
add(myunwellRB);
add(submit);
submit.addActionListener(this);
myunwellRB.addActionListener(this);
mywellRB.addActionListener(this);
setVisible(true);
ButtonGroup buttons = new ButtonGroup();
buttons.add(mywellRB);
buttons.add(myunwellRB);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == mywellRB) {
myTxt.setText("in the pink! ");
myTxt.setBackground(Color.pink);
}
}
}
Пожалуйста, не могли бы вы помочь мне понять, что я сделал неправильно, спасибо!