Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
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 01-19-2008, 02:50 AM
Member
 
Join Date: Jan 2008
Posts: 2
AZMichael is on a distinguished road
JTable DataModel - how to get
Hi y'all;

I am creating a project where I use a JTable that i create by specifying rows and columns
for example:

JTable jt = new JTable(10,30);

So, how can I access (and manipulate) the underlying array if I have not used an array to create the table. That is, how can I get to
jt DataModel DataVector elementData


Thanks for your help.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-19-2008, 03:16 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,022
hardwired is on a distinguished road
Code:
JTable table = new JTable(10,10); Vector rows = ((DefaultTableModel)table.getModel()).getDataVector(); for(int j = 0; j < rows.size(); j++) { Vector v = (Vector)rows.get(j); for(int k = 0; k < v.size(); k++) { System.out.print("*"); if(k < v.size()-1) System.out.print(" "); else System.out.println(); } } Dimension d = table.getPreferredSize(); d.width = 400; table.setPreferredScrollableViewportSize(d); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new JScrollPane(table)); f.pack(); f.setLocation(200,200); f.setVisible(true);
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old Yesterday, 10:03 PM
Member
 
Join Date: Jan 2008
Posts: 2
AZMichael is on a distinguished road
Hey thanks. That was a big help. and got me to where I needed to be.

Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old Today, 09:27 AM
Niveditha's Avatar
Senior Member
 
Join Date: May 2008
Posts: 178
Niveditha is on a distinguished road
Send a message via Skype™ to Niveditha
Mark it as Solved please.....
__________________
To finish sooner, take your own time....
Nivedithaaaa
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
How to add in a new row in Jtable? Ry4n AWT / Swing 0 01-18-2008 01:26 PM
JTable with Font Rama Koti Reddy AWT / Swing 1 12-12-2007 06:22 PM
Help with JTable in java carl AWT / Swing 3 08-11-2007 10:47 PM
Help with application with JTable cachi AWT / Swing 2 08-08-2007 09:51 AM
Help with JTable fernando AWT / Swing 1 08-07-2007 07:57 AM


All times are GMT +3. The time now is 09:57 AM.


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