The Artima Developer Community
Sponsored Link

Java Answers Forum
The use of MouseListener in a JTable

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Mike Lyons

Posts: 1
Nickname: bullets
Registered: Mar, 2003

The use of MouseListener in a JTable Posted: Mar 27, 2003 9:26 AM
Reply to this message Reply
Advertisement
Hi...I am using a mouselistner on a JTable so i can click on a selected field/tuple within the column of the JTable and take out its infromation. i can get it to print the whole row on the dos screen by using;

table.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
selectedCol(table);
}
});
.
.
.
private void selectedCol(JTable table)
{
int row = table.getRowCount();
int col = table.getColumnCount();
.
.
.
}

but when when tryed to get a an individual field/tuple by using;
private void selectedCol(JTable table)
{
int row = table.getSelectedRow();
int col = table.getSelectedColumn();
if (rows == 1)
{
value = (String)table.getValueAt(row, col);
System.out.println("Value =: "+value);
}
}

i get a value of -1, which in the says in the API a value of -1 means nothing has been selected.

can anyone help

kind regards
Mike.

Topic: need help to practice problem Previous Topic   Next Topic Topic: Session Invalidation

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use