File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes database results in a pane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "database results in a pane " Watch "database results in a pane " New topic

database results in a pane

Murasoli Maran
Ranch Hand

Joined: Jun 08, 2003
Posts: 193
Hi all,
in my present app,i have to display database search results to a java pane.
the results needs to have in different colour codings for different results.for eg if a person searches in a Products(for eg) table, the results should be shown in a pane and if the product costs more than 500$ the result should be shown in red color(like that).
which swing pane is ideal for this?..
how can i restrict 10 results in a page and by clicking next page link the user should able to view results from 10 to 20 ..just as seen in web pages.but how can it be implemented in a java standalone program using swing pane to display the database search results?
anyone please help
Chris Brat
Ranch Hand

Joined: May 22, 2003
Posts: 108
Sounds like a JTable work for you:
- can set background and foreground colours
- can define number of rows and columns easily
- can also restrict particular rows, columns, cells to be read only
also not too difficult to implement once you get the hang of it

Jason Steele
Ranch Hand

Joined: Apr 25, 2003
Posts: 100
Chris is right.
JTable would be your best bet. As for limiting the rows returned, well, you could do that the same way that it's done on the web. Use a LIMIT condition on your SQL SELECT statement and track your current position. However, if you are going to limit the size of a JTable's contents, do it by about 50,000 rows! The reason that a lot of pages(like shopping carts) have the previous/next system is not because there is too much data, but because of the nature of the web. Not only do the static page contents have to be rendered and displayed, but also other scripts and calls to sql servers. Add to that images and Flash, whatever, time is of the essence if you want your visitors to come back.
An application is much faster and unless you have a couple hundred thousand + rows to return, why not return them all?
Uh...I'm just sayin!

An egg is a chicken's house!
Murasoli Maran
Ranch Hand

Joined: Jun 08, 2003
Posts: 193
thanks and regards,good help.i use JTable but page selection like (previous,1,2,3,4...last,next) will be a better utility in JTable class.sun may notice?
thanks again
I agree. Here's the link:
subject: database results in a pane
It's not a secret anymore!