Hi,
I am using NetBeans 8.1. I have created a list using swing component. I have a text box (variable name :TF) & 3 buttons. button1 is variable corresponding to the add button. I want to write its handler. I dont know what is the method of list box which can add elements in the list box.
When I press the add button, the data in text field should store in the list box. My variables are:
private javax.swing.JButton button1;
private javax.swing.JButton button2;
private javax.swing.JButton button3;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollBar jScrollBar1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextField jTF;
private javax.swing.JList<String> list;
I cant find the addElement ( ) method to add the string from the textbox into the list.
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String str=jTF.getText();
list.???
}
Some body please guide me about the method to addElement in list box.
Zulfi.