How to generate more JComboBox/JTextField with a button?
Hi, I was wondering how one can generate more JComboBoxes/JTextField with a touch of a button.
Also, how you can read the data from those boxes? Since they obviously can't be initialiated the normal way, how can you read the data from them?
Thanks in Advance.
# 1
the code below doesn't compile it is just a hint on how to add jcombobox on
button click. Of course you have to do the rest, have some effort on reading tutorials
and coding on your own.
If you have problem with your code then post it here.
JButton button = new JButton();
button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
addComboBox();
}
});
private void addComboBox(){
jCombo = new JComboBox();
jframe.add(jCombo);
jframe.revalidate();
}