Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / October 2005

Tip: Looking for answers? Try searching our database.

java netbeans jtable defaulttablemodel - how to connect them

Thread view: 
cernesimon@gmail.com - 18 Oct 2005 19:55 GMT
Hay!

I am beginner in NetBeans. I have an aplication with JFrame. On it I
have JTable and other things. I want to connect JTable with Vector. I
tried with

Vector vec = new Vector();
DefaultTableModel data = new DefaultTableModel();
JTable table = new JTable(data);

but there is nothing in JTable on my JFrame (after I read file with
data and wanted to insert it in JTable). I wanted to add data with
method data.addRow(vec);. It works if I write code in TextPad and
compile it, but I don't want to write such a long code in text editor.

Have any suggestion?

Thanks in advance, Simon
Roedy Green - 18 Oct 2005 22:58 GMT
>Vector vec = new Vector();
>DefaultTableModel data = new DefaultTableModel();
>JTable table = new JTable(data);
>
>but there is nothing in JTable on my JFrame (after I read file with
>data and wanted to insert it in JTable).

See if you can find a cheap Swing textbook that has some sample JTable
code or some sample code on the net that uses the classes you need.

What you do is create a new class that extends DefaultTableModel and
hence implements TableModel. In that code you write addRow etc. to
insert data into your Vector.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

cernesimon@gmail.com - 20 Oct 2005 19:50 GMT
I add data into vector with .addElement method then I add this vector
with .addRow to DefaultTableModel but I doesn't show in JTable I have
on my JFrame.

What to do, have any suggestion

Simon
Roedy Green - 21 Oct 2005 04:02 GMT
>I add data into vector with .addElement method then I add this vector
>with .addRow to DefaultTableModel but I doesn't show in JTable I have
>on my JFrame.

you are missing your fire methods that tell Swing what you changed
that needs repainting.

see http://mindprod.com/jgloss/jtree.html
and look at the tutorials.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.