Results 1 to 4 of 4
- 01-19-2008, 01:50 AM #1
Member
- Join Date
- Jan 2008
- Posts
- 16
- Rep Power
- 0
[SOLVED] 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.
- 01-19-2008, 02:16 AM #2
Java 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);
- 07-08-2008, 09:03 PM #3
Member
- Join Date
- Jan 2008
- Posts
- 16
- Rep Power
- 0
Hey thanks. That was a big help. and got me to where I needed to be.
:D
- 07-09-2008, 08:27 AM #4
Similar Threads
-
How to add in a new row in Jtable?
By Ry4n in forum AWT / SwingReplies: 0Last Post: 01-18-2008, 12:26 PM -
JTable with Font
By Rama Koti Reddy in forum AWT / SwingReplies: 1Last Post: 12-12-2007, 05:22 PM -
Help with JTable in java
By carl in forum AWT / SwingReplies: 3Last Post: 08-11-2007, 09:47 PM -
Help with application with JTable
By cachi in forum AWT / SwingReplies: 2Last Post: 08-08-2007, 08:51 AM -
Help with JTable
By fernando in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 06:57 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks