How to insert new text,box from menu
Hi. ill just show the code.
from my menuclass
Code:
aMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
if(e.getActionCommand().equals("New row")){
createrow();
it calls the method createrow();
Code:
public void createrow() {
aTextField = new JTextField("", 30);
aTextField.setBorder(BorderFactory.createLineBorder(Color.black));
c.fill = GridBagConstraints.HORIZONTAL;
c.ipady = 1; //reset to default
c.weighty = 1.0; //request any extra vertical space
c.anchor = GridBagConstraints.WEST; //bottom of space
c.insets = new Insets(5,0,0,10); //top padding
c.gridy = 1; // what row.
aPanel0.add(aTextField, c); //add TextField 1 to Panel
selDbType1 = new JComboBox(dbType1);
c.fill = GridBagConstraints.HORIZONTAL;
c.ipady = 1; //reset to default
c.weighty = 1.0; //request any extra vertical space
c.anchor = GridBagConstraints.EAST; //bottom of space
c.insets = new Insets(5,0,0,10); //top padding
c.gridy = 1; // what row
selDbType1.setPreferredSize(new Dimension(80, 20)); // set the size for dropmenu
selDbType1.setSelectedIndex(2); // set to 3 choice
selDbType1.addActionListener(new ActionListener(){ // add action handler to combobox
}
Can it be done this way. i also need c.gridy to be dynamic so it pops up at end of page. thankfull for any advice.
EDIT. Mabey should explain better what i want it to do. When a user pushes "new row" i want a new row containing 1 textfield and 1 combobox to insert at bottom of panel. they both need a uniqe id.