• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 421
  • Last Modified:

jtable column link

is it posssible to have a column in a  jtable as a link ..i need the link to open another applet...i have the jtable dispalying data from a table (multiple columns)..i need one of the columns to be a link and when the cursor is placed over the link, the color of the cell changes to red..

0
trance12
Asked:
trance12
  • 5
  • 3
  • 2
1 Solution
 
zzynxSoftware engineerCommented:
>> is it posssible to have a column in a  jtable as a link
Not automatically.
But if you add a MouseListener to the JTable you can become what you want.

>> when the cursor is placed over the link, the color of the cell changes to red
Possible using the combination of (the same) MouseListener and a TableCellRenderer
0
 
objectsCommented:
Not easily achieved sorry

0
 
zzynxSoftware engineerCommented:
>> if you add a MouseListener to the JTable you can become what you want.

yourTable.addMouseListener( new MouseAdapter() {
     public void mouseClicked(MouseEvent e)  {
          JTable theTable = (JTable)MouseEvent.getSource();
          Point pt = e.getPoint();
          if ( theTable.columnAtPoint(pt) == yourSpecificColumn ) {
              int row = theTable.rowAtPoint(pt);
              // get the data for that row and open the link
          }
     }
});
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
objectsCommented:
You'll need to do more than that to get the link to display
0
 
trance12Author Commented:
can i ask if there is a better tool than to display data from  a table..i know jlist only displays one column..is there anything else other than a jtable and a jlist?
0
 
objectsCommented:
not for displaying tabular data, what is it you are trying to achieve?

0
 
trance12Author Commented:
i have data from a table ..5 columns..i'm using a jtable to select and display the data..one of the columns in the jtable needs to be a hyperlink..when the user clicks on that column data, it opens a a diferent applet
0
 
objectsCommented:
You can achieve that using a table, you'll just need to implement your own renderer, and the mouse over and mouse click behaviour yourself.
0
 
objectsCommented:
A button might be a little easier to implement:

http://www.objects.com.au/java/examples/swing/ButtonTableCell.do
0
 
trance12Author Commented:
yep..that sounds like a good idea..i'll give it a shot...thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now