JCombo Box issue
HI,
I need to generate a JcomboBox by pressing the key, for that am create a JcomboBox in side the keypressed, how can add it ............. Can you help me out
package swing;
import java.awt.GridBagLayout;
import javax.swing.JPanel;
import java.awt.GridBagConstraints;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JComboBox;
publicclass Key3extends JPanel{
privatestaticfinallong serialVersionUID = 1;
private JPanel jPanel =null;
private JTextField jTextField =null;
public String test;
/**
* This is the default constructor
*/
public Key3(){
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
privatevoid initialize(){
this.setSize(300, 200);
this.setLayout(null);
this.add(getJPanel(),null);
this.add(getJTextField(),null);
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel(){
if (jPanel ==null){
jPanel =new JPanel();
jPanel.setLayout(null);
jPanel.setBounds(new Rectangle(149, 99, 1, 1));
}
return jPanel;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField(){
if (jTextField ==null){
jTextField =new JTextField();
jTextField.setBounds(new Rectangle(56, 34, 170, 42));
jTextField.addKeyListener(new java.awt.event.KeyAdapter(){
publicvoid keyPressed(java.awt.event.KeyEvent e){
JComboBox jComboBox =new JComboBox();
jComboBox.setBounds(new Rectangle(200, 100, 54, 33));
// how can i add jComboBox its not visible now
}
});
}
return jTextField;
}
}

