You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Phoenix Hawk <ph...@gmail.com> on 2007/11/13 04:03:06 UTC
Populating JTable and JList with data
Hi there...
Background: using Cayenne 2.0.3 with NetBeans 5.5.1 (JDK 1.5) on Windows XP
SP2...
I have used the Cayenne Modeler to perform a reverse engineering on my
existing database following the online tutorial.
I am new to the java programming "model", previously I am doing C/C++, perl,
php, tcl/tk, I have to pickup Java myself to do a prototype...
My task is to read data from a MSSQL 2005 database and display it on a Java
desktop application. There is no need to put any data back ( *whew* ) which
is also why I did not want to use iBatis or Hibernate (they are too heavy, I
feel)... :)
I am stuck at how I can display the results of my query (which I am able to
print on the debugging console using System.out.println) on the application.
Does anyone have a code snippet or a link (I have looked at the Cayenne
petstore, examples on the wiki, but none of them have what I want, or maybe
I do not understand enough Java) that shows how the results of a query can
be used to populate a JTable and a JList? Or maybe there is a better way
instead of using JTable or JList?
I would be very grateful for any advice or pointers... I think I'm at the
limit of my learning capacity after 3 days of intensive searching/learning,
my brains feel like they are not mine anymore... :P
Thank you very much... :)
pH
Re: Populating JTable and JList with data
Posted by Aristedes Maniatis <ar...@ish.com.au>.
On 13/11/2007, at 2:03 PM, Phoenix Hawk wrote:
> Does anyone have a code snippet or a link (I have looked at the
> Cayenne
> petstore, examples on the wiki, but none of them have what I want,
> or maybe
> I do not understand enough Java) that shows how the results of a
> query can
> be used to populate a JTable and a JList? Or maybe there is a better
> way
> instead of using JTable or JList?
You'll need to poke around some Swing programming lists rather than
the Cayenne one. What you are after is to take the List returned by
Cayenne and attach it to the table model of your JTable. Then each
column (or cell) will need to have a renderer which is able to draw
the appropriate attribute from that record. There are probably a
million ways to do this, but that's one.
Hope that helps
Ari
-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001 fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
Re: Populating JTable and JList with data
Posted by Peter Karich <pe...@yahoo.de>.
Phoenix Hawk schrieb:
> Hi there...
>
> Background: using Cayenne 2.0.3 with NetBeans 5.5.1 (JDK 1.5) on Windows XP
> SP2...
> I have used the Cayenne Modeler to perform a reverse engineering on my
> existing database following the online tutorial.
>
> I am new to the java programming "model", previously I am doing C/C++, perl,
> php, tcl/tk, I have to pickup Java myself to do a prototype...
>
> My task is to read data from a MSSQL 2005 database and display it on a Java
> desktop application. There is no need to put any data back ( *whew* ) which
> is also why I did not want to use iBatis or Hibernate (they are too heavy, I
> feel)... :)
>
> I am stuck at how I can display the results of my query (which I am able to
> print on the debugging console using System.out.println) on the application.
>
> Does anyone have a code snippet or a link (I have looked at the Cayenne
> petstore, examples on the wiki, but none of them have what I want, or maybe
> I do not understand enough Java) that shows how the results of a query can
> be used to populate a JTable and a JList? Or maybe there is a better way
> instead of using JTable or JList?
If you try to use netbeans 6.0 this could be another way for you:
http://www.netbeans.org/kb/60/java/gui-db.html
or the video:
http://www.netbeans.org/download/flash/netbeans_6_gui_builder/netbeans_6_gui_builder.html
But if you want to learn "how to query with cayenne", this would be more
interesting for you:
http://wiki.netbeans.org/wiki/view/TS_60_FormSimpleJTableDataBinding
Peter.