Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-18-2008, 08:13 PM
Member
 
Join Date: May 2008
Posts: 29
adeeb is on a distinguished road
Regarding JTable
Hi,
I have added up a JTable to a JScrollPane . Now i have a button on clicking it the table is displayed but the problem is when ever i click the button the old rows are not erased and new once are added below
Heres my code
Code:
JPanel jp6 = new JPanel(); due = new JButton("Dues"); due.addActionListener(this); print.setMnemonic(KeyEvent.VK_P); JPanel viewd = new JPanel(); viewd.add(print); due.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cl.show(panel,"6"); try { conn = DriverManager.getConnection("jdbc:odbc:addissue", "library","adeeb"); ps = conn.prepareStatement("SELECT * FROM expired WHERE days > 15 ORDER BY rollno ASC"); String colnames[] = {"ROLLNO","NAME","BOOK","BOOK ID","ISSUED","PRES_DATE","DAYS"}; DefaultTableModel model6 = (DefaultTableModel) tab6.getModel(); model6.setColumnIdentifiers(colnames); rs=ps.executeQuery(); ResultSetMetaData rsmd = rs.getMetaData(); int colno = rsmd.getColumnCount(); while(rs.next()) { Object[] row = new Object[colno]; for(int i=0;i<colno;i++) { row[i]=rs.getObject(i+1); } model6.addRow(row); } tab6.setModel(model6); } catch(Exception ce) { System.out.println(ce); } } }); tab6 = new JTable(); jsp6 = new JScrollPane(tab6); jsp6.setViewportView(tab6); jsp6.revalidate(); jsp6.repaint(); jp6.setLayout(new BorderLayout()); jp6.add(jsp6); jp6.add(viewd, BorderLayout.SOUTH);
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding JTable adeeb AWT / Swing 12 06-19-2008 09:39 AM
Jtable duplicates through Hashtable (JTable condition problem) my assignment plz help salmanpirzada1 Advanced Java 2 05-15-2008 12:15 PM
How to add in a new row in Jtable? Ry4n AWT / Swing 0 01-18-2008 02:26 PM
JTable to txt File Tzaphiel New To Java 0 12-17-2007 06:15 PM
Help with JTable fernando AWT / Swing 1 08-07-2007 08:57 AM


All times are GMT +3. The time now is 09:50 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org