Results 1 to 20 of 21
Thread: load Jtable
- 01-30-2013, 12:26 PM #1
Member
- Join Date
- Jan 2013
- Posts
- 28
- Rep Power
- 0
- 01-30-2013, 01:09 PM #2
Re: load Jtable
Yes, it's possible.
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 01-30-2013, 01:49 PM #3
Member
- Join Date
- Jan 2013
- Posts
- 28
- Rep Power
- 0
Re: load Jtable
i will give you my code , if u can help please , this problem bloked me before 2 week.
my first jframe contains button Valider and Jtable1 , this is the code of Valider.
u will find join a picture of my interface
the second contain buton Rechercher and jtable1, the code of Recherche do the insert into table in database from Jtable2 and reload jtable1Java Code:Second sec = new Second(); sec.show();
this is code of buton Rechercher
this code of reload run 100 % when i put it in buton in the same jframe of jtable, but when i put it in another jframe , it dind't run.Java Code:private void AjouterActionPerformed(java.awt.event.ActionEvent evt) { try { // le numéro de la ligne selectionée int i = jTable2.getSelectedRow(); //récuperation des données String selt1 = jTable2.getValueAt(i, 0).toString(); String selt2=jTable2.getValueAt(i, 1).toString(); //Insertion in DATABASE (in table A) con.Conn().executeUpdate("insert into A values ('"+selt1+"','"+selt2+"')"); // reload jtable1 of the first jframe First fs = new First(); ResultSet ResultRech = null; DefaultTableModel aModel = (DefaultTableModel) fs.jTable1.getModel(); aModel.getDataVector().removeAllElements(); { ResultRech = con.Conn().executeQuery("select * from A"); ResultSetMetaData rsmd = null; rsmd = ResultRech.getMetaData(); int cols = 0; cols = rsmd.getColumnCount(); while (ResultRech.next()) { Object[] row = new Object[cols]; for (int j = 0; j < row.length; j++) { row[j] = ResultRech.getObject(j + 1); } aModel.addRow(row); } fs.jTable1.setModel(aModel); fs.jTable1.repaint(); this.dispose();//close the Second jframe }}catch (SQLException | RemoteException ex) { Logger.getLogger(B.class.getName()).log(Level.SEVERE, null, ex); }
- 01-30-2013, 02:00 PM #4
Re: load Jtable
CardLayout.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 01-30-2013, 02:16 PM #5
Member
- Join Date
- Jan 2013
- Posts
- 28
- Rep Power
- 0
Re: load Jtable
how i can use CardLayout here
- 01-30-2013, 04:06 PM #6
Re: load Jtable
Wow, you've read the CardLayout tutorial in 16 minutes?
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 01-30-2013, 04:20 PM #7
Member
- Join Date
- Jan 2013
- Posts
- 28
- Rep Power
- 0
Re: load Jtable
Sorry , i am beginner in Netbeans so i don't have a big informations.
for the CardLayout : i know just we can used it in 1 jframe and 2 jpanel or more , but i don't know use it with 2 jframe.
give a link if u have a tutorial to use CardLayout with many Jframe.
Thanks
- 01-30-2013, 04:28 PM #8
Re: load Jtable
The idea is to use one JFrame and the CardLayout within that. And I'm sure you're able to use Google for a tutorial yourself.
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 01-30-2013, 04:36 PM #9
Member
- Join Date
- Jan 2013
- Posts
- 28
- Rep Power
- 0
Re: load Jtable
thanks for your help
but because i'm beginner i will find solution for this porblem after 1 month
Last edited by Ridha; 01-30-2013 at 05:37 PM.
- 02-01-2013, 12:56 PM #10
Member
- Join Date
- Jan 2013
- Posts
- 28
- Rep Power
- 0
Re: load Jtable
we can't did reload of jtable with cardlayout
, u have another idea please ?
- 02-01-2013, 01:54 PM #11
Re: load Jtable
Reload of JTable? setModel(...)
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 02-01-2013, 02:15 PM #12
Re: load Jtable
I get the feeling that the OP is trying a reload via LayoutManager or something strange
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 02-01-2013, 03:45 PM #13
Member
- Join Date
- Jan 2013
- Posts
- 28
- Rep Power
- 0
Re: load Jtable
@DarrylBurke : i put setModel() in my code, i'm sure that u are not understand my problem and i tell in the start of thread my code of reload run 100% when i put the code in the same jframe of jtable.
my problem : i have problem in reload of jtable1(exist in the first jframe and it load data from database)after insert by jtable2(exist in the second jframe ) and this second jframe contain also a boutton rechercher to do the insert into database from the jtable2 and to reload jtable1.(Note : the first jframe is always open meaning i don't need option .show() (to show the first jframe) in the code of button rechercher , this is why the code of relaod don't run)Last edited by Ridha; 02-01-2013 at 03:52 PM.
- 02-01-2013, 04:23 PM #14
Senior Member
- Join Date
- Feb 2009
- Posts
- 303
- Rep Power
- 5
Re: load Jtable
Are you trying to have the button on the 2nd JFrame reload the information on the 1st JFrame?
- 02-01-2013, 05:09 PM #15
Member
- Join Date
- Jan 2013
- Posts
- 28
- Rep Power
- 0
Re: load Jtable
yes , the bouton Rechercher do insert into database and reload of first Jframe
- 02-01-2013, 05:17 PM #16
Senior Member
- Join Date
- Feb 2009
- Posts
- 303
- Rep Power
- 5
Re: load Jtable
I'm confused, I see a constructor in the actionPerformed() for a new First instance. Is the First class the 1st JFrame? I don't see that instance being displayed/made visible, is that a different instance then the one you want to display on?
- 02-01-2013, 05:40 PM #17
Member
- Join Date
- Jan 2013
- Posts
- 28
- Rep Power
- 0
Re: load Jtable
the first jframe is already displayed, when i clik in buton valider , the second jframe will be displayed .
after that when i clik in one row of jtable2 and i clik rechercher , this row will be inserted in the database and the second jframe will be closed and reload jtable1 (to show the new insert)
- 02-01-2013, 09:20 PM #18
Senior Member
- Join Date
- Feb 2009
- Posts
- 303
- Rep Power
- 5
Re: load Jtable
Then why are you creating a new First instance and manipulating the table there? If there is another one already displayed, you should be using that instance.
Is there any connection between the First frame and the Second? Does the Second Frame take in a First as a constructor parameter or anything?
- 02-02-2013, 08:13 AM #19
Member
- Join Date
- Jan 2013
- Posts
- 28
- Rep Power
- 0
Re: load Jtable
sorry , but i did mistake in actionperformed, this code is in button Rechercher
@StormyWaters : i do new first instance(First fs = new First();) to will be have a access for the jtable1 in the first jframe.Java Code:private void RechercherActionPerformed(java.awt.event.ActionEvent evt) { try { // le numéro de la ligne selectionée int i = jTable2.getSelectedRow(); //récuperation des données String selt1 = jTable2.getValueAt(i, 0).toString(); String selt2=jTable2.getValueAt(i, 1).toString(); //Insertion in DATABASE (in table A) con.Conn().executeUpdate("insert into A values ('"+selt1+"','"+selt2+"')"); // reload jtable1 of the first jframe First fs = new First(); ResultSet ResultRech = null; DefaultTableModel aModel = (DefaultTableModel) fs.jTable1.getModel(); aModel.getDataVector().removeAllElements(); { ResultRech = con.Conn().executeQuery("select * from A"); ResultSetMetaData rsmd = null; rsmd = ResultRech.getMetaData(); int cols = 0; cols = rsmd.getColumnCount(); while (ResultRech.next()) { Object[] row = new Object[cols]; for (int j = 0; j < row.length; j++) { row[j] = ResultRech.getObject(j + 1); } aModel.addRow(row); } fs.jTable1.setModel(aModel); fs.jTable1.repaint(); this.dispose();//close the Second jframe }}catch (SQLException | RemoteException ex) { Logger.getLogger(B.class.getName()).log(Level.SEVERE, null, ex); }
the connection between first jframe and the second is in button validerJava Code:Second sec = new Second(); sec.show();
Last edited by Ridha; 02-02-2013 at 08:17 AM.
- 02-02-2013, 08:15 AM #20
Member
- Join Date
- Jan 2013
- Posts
- 28
- Rep Power
- 0
Similar Threads
-
JTable validate already existing JTable data and set Background colour issue
By pi4r0n in forum AWT / SwingReplies: 4Last Post: 04-02-2012, 07:57 PM -
could not load load from location:/test_subreport.jasper
By jadeite100 in forum JavaServer Faces (JSF)Replies: 1Last Post: 03-27-2012, 11:43 AM -
Adding New JTable in JTable
By anilkumar_vist in forum New To JavaReplies: 0Last Post: 01-27-2010, 08:27 AM -
[SOLVED] How to load data from the database and display in jTable?
By tpyq in forum NetBeansReplies: 0Last Post: 12-04-2008, 05:39 PM -
Jtable duplicates through Hashtable (JTable condition problem) my assignment plz help
By salmanpirzada1 in forum Advanced JavaReplies: 2Last Post: 05-15-2008, 10:15 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks