I have 2 JComboBox
consisting of numbers combobox1= 1 to 5
and combobox2= 1 to 6.
and when I click my JButton
, I
use form.setVisible(true);
then:
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int cb1Int = Integer.parseInt(cb1.getSelectedItem().toString());
int cb2Int = Integer.parseInt(cb2.getSelectedItem().toString());
txt.setText(String.valueOf(cb1Int + cb2Int));
}
});
Good luck with your homework. ;)