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 / GUI / November 2006

Tip: Looking for answers? Try searching our database.

Update jTable Filled from DB

Thread view: 
Philippe Delodder - 21 Oct 2006 13:31 GMT
Hi,

i'm having a question i'm making a small program that involves reading
from a DB and putting the data in jTable.

But when you select a row in the jTable and press a button there comes
an dialog that you can edit the data afterwards when you close the
dialog the jTable should be updated.

I can't seem to figure out how to make it update after closing the dialog

Thx in advance

Philippe Delodder

Sources: http://www.delodder.be/java/AddressBook.rar
jcsnippets.atspace.com - 21 Oct 2006 17:30 GMT
> Hi,
>
[quoted text clipped - 13 lines]
>
> Sources: http://www.delodder.be/java/AddressBook.rar

I've not looked at your source code, but basically what you could do is
this:

- create a class that extends the DefaultTableModel, have it contain an
array of results to be displayed
- each time something changes, you
alter that array and revalidate the JTable

This way, the JTable will interact with the TableModel and will update
what is being shown.

Best regards,

JayCee
Signature

http://jcsnippets.atspace.com/
a collection of source code, tips and tricks

gbruno - 16 Nov 2006 03:49 GMT
> - each time something changes, you
> alter that array and revalidate the JTable

Can you please explain "revalidate the JTable"
ie can you givce the line of code?
Thomas Weidenfeller - 16 Nov 2006 08:09 GMT
>> - each time something changes, you
>> alter that array and revalidate the JTable
>>
> Can you please explain "revalidate the JTable"
> ie can you givce the line of code?

Please consider working through Sun's GUI tutorial.

/Thomas
Signature

The comp.lang.java.gui FAQ:
http://gd.tuwien.ac.at/faqs/faqs-hierarchy/comp/comp.lang.java.gui/
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq

jcsnippets.atspace.com - 17 Nov 2006 13:53 GMT
"gbruno" <ctskinner@gmail.com> wrote in news:1163648967.379835.253280
@b28g2000cwb.googlegroups.com:

>> - each time something changes, you
>> alter that array and revalidate the JTable
>>
> Can you please explain "revalidate the JTable"
> ie can you givce the line of code?

Hi,

Have a look at the following article I've put online yesterday:
http://jcsnippets.atspace.com/java/gui-graphics/creating-a-custom-
tablemodel-for-a-jtable.html

As for revalidation, call the method "revalidate()". You can find more
information on this in the Java Docs:
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JComponent.html#reval
idate()

Also, setting a new model for the JTable will have the same effect.

Best regards,

JayCee
Signature

http://jcsnippets.atspace.com/
a collection of source code, tips and tricks

Andrew Thompson - 17 Nov 2006 14:52 GMT
...
> Have a look at the following article I've put online yesterday:
> http://jcsnippets.atspace.com/java/gui-graphics/creating-a-custom-
> tablemodel-for-a-jtable.html

When posting long URL's, they can be protected
from line wrapping by enclosing in '<', '>'.  E.G.
<http://jcsnippets.atspace.com/java/gui-graphics/creating-a-custom-tablemodel-for
-a-jtable.html
>

Andrew T.
jcsnippets.atspace.com - 19 Nov 2006 15:23 GMT
<snip>
> When posting long URL's, they can be protected
> from line wrapping by enclosing in '<', '>'.

Thank you for the tip, Andrew - I did not know that. Very handy!

Best regards,

JayCee
Signature

http://jcsnippets.atspace.com/
a collection of source code, tips and tricks

John W. Kennedy - 21 Nov 2006 00:37 GMT
> ....
>> Have a look at the following article I've put online yesterday:
[quoted text clipped - 4 lines]
> from line wrapping by enclosing in '<', '>'.  E.G.
> <http://jcsnippets.atspace.com/java/gui-graphics/creating-a-custom-tablemodel-for
-a-jtable.html
>

Actually,
<URL:http://jcsnippets.atspace.com/java/gui-graphics/creating-a-custom-tablemodel-for
-a-jtable.html
>
is often safer. It was once the official standard for quoting URLs in
plain text, but was dropped in a later RFC simply because few people
were using it; however, it is still supported by some software,
including some software that will break up a URL that has merely been
enclosed in <...>.

Signature

John W. Kennedy
"The blind rulers of Logres
Nourished the land on a fallacy of rational virtue."
  -- Charles Williams.  "Taliessin through Logres: Prelude"



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.