Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-10-2007, 08:53 PM
Member
 
Join Date: May 2007
Posts: 39
Alan is on a distinguished road
sort columns in jtable
Hello people!
I have the following question:

I have a jtable with 3 columns.
I want when I click in any column, the jtable sort its information by the column clicked.
do you understand?
please help me
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-10-2007, 09:08 PM
Member
 
Join Date: May 2007
Posts: 42
Freddie is on a distinguished road
hello
please visit this url:


https://jdnc.dev.java.net/ check that the second example use a jtable

another way to do it is:

Code:
JTable table = new JTable() ; ... JTableHeader header = table.getTableHeader() ; header.addMouseListener( new MouseAdapter() { void mouseClicked(MouseEvent e) { JTableHeader h = (JTableHeader)e.getSource() ; int nColumn = h.columnAtPoint(e.getPoint()) if (nColumn != -1) sortColumn(nColumn, h.getTable().getModel()) ; } void sortColumn(int nColumn, TableModel model) { } } ) ;
bye bye freddie
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-14-2007, 06:18 PM
Member
 
Join Date: May 2007
Posts: 38
Marty is on a distinguished road
Please check this:
How to Use Tables (The Java™ Tutorials > Creating a GUI with JFC/Swing > Using Swing Components)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to sort column in JTable johnt AWT / Swing 3 06-14-2008 06:48 AM
How to sort a list using Bubble sort algorithm Java Tip Algorithms 3 04-29-2008 09:04 PM
Using Columns With JTextField The Evil Genius AWT / Swing 1 03-17-2008 02:01 AM
Getting names of table columns Java Tip Java Tips 0 01-07-2008 09:39 AM
Problems with JSF (columns) Peter JavaServer Faces 2 07-04-2007 07:43 AM


All times are GMT +3. The time now is 12:58 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org