Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,218,325 members, 8,037,576 topics. Date: Thursday, 26 December 2024 at 12:13 PM |
Nairaland Forum / Science/Technology / Programming / Update Jtable At Runtime (1454 Views)
Windows Runtime Errors / Conpaas - An Open-source Runtime Environment For Cloud Applications / How Do You Elevate Privileges On Vista At Runtime (2) (3) (4)
(1) (Reply)
Update Jtable At Runtime by jboy01(m): 9:29pm On Oct 27, 2013 |
pls am trying to update data table at runtime, but its not working. the table named 'messageTable' was design in netbean with 4 columns. i want to update the table when the application load. here is my code public static void main(String args[]) { try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MainPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MainPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MainPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MainPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MainPage().setVisible(true); } }); DefaultTableModel model=new DefaultTableModel(); JTable messageTable= new JTable(model); model.insertRow(0,new Object[]{"a","a","a","a"}); model.insertRow(1,new Object[]{"a","a","a","a"}); messageTable.repaint(); } |
Re: Update Jtable At Runtime by javadoctor(m): 1:28am On Oct 29, 2013 |
I dnt seem to see any actionPerformed() on ur JTable, basically a table using a model to run wen initialized. If u using a modal to update the Jtable, create a method called updateTable() in d JFrame class,now create a JDialog class, the class should have a constructor with a this reference to the JFrame class.when u add a new row from the modal,d actionperformed method should make a call on ur JFrame class to call the updateTable() ,a method I feel which contains jTable.setModel(model) and jTable.repaint(), doing this effects changes on ur jtable |
(1) (Reply)
Vote For Nigerian Startup, Flowbyte, In The Global Startup Battle / Science: Could You Travel Back In Time? See What Scientists Achieved. / Webmasters Pls I Need Your Urgent Help. On Creating Html Emails
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12 |