-1

May I know how do I make a popup frame to do the insert of data since I'd like my GUI to popup another frame to ask for user input to the database and as well as the JTable? Thank you!

What I don't get is how to make use of the add button, then insert the entry and make the listener notice about "e.getType()==TableModelEvent.INSERT".

Edit:

At the same panel as the JTable, I would have an add button at the bottom. This add button would then in another 'frame' ask users to enter the items to add to the database as well as adding and refreshing the JTable.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
user1321096
  • 143
  • 3
  • 14
  • Your question is a bit broad. I think that it would be best if you break the big problem down into small steps, and then try and solve each step one at a time. Then if you're still stuck at a small step, you can ask a more reasonable answerable question. Note also that you never want to show a second JFrame, a JDialog or JOptionPane perhaps, but not a second JFrame. – Hovercraft Full Of Eels Nov 05 '13 at 18:01
  • ask your question one by one in smaller form. Be specific to your requirement. Like do you want to load data from other data source e.g., XML into database and your `JTable` ? Try to be specific to your control flow – Sage Nov 05 '13 at 18:28
  • Hi, I have edited the question a little. – user1321096 Nov 06 '13 at 05:33

2 Answers2

1

you must use a DataModel with your JTable, and add item to your datamodel and then update your JTable with yout DataModel.

 DefaultTableModel model = new DefaultTableModel(); 
 JTable table = new JTable(model); 

 // Create a couple of columns 
 model.addColumn("Col1"); 
 model.addColumn("Col2"); 

 // Append a row 
 model.addRow(new Object[]{"v1", "v2"});
jrey
  • 2,163
  • 1
  • 32
  • 48
0

inserting new data from external class into jtable

Have a look at this , I hope your problem will be solved , Pass the Table reference in the constructor of your JFame/JDialogue (Better if you use JDialogue Instead of JFrame click here to know some good reasons) and modify table model accordingly

Community
  • 1
  • 1
Deepak Odedara
  • 481
  • 1
  • 3
  • 12