public JTableEx(int numRows, int numColumns) { this(new DefaultTableModel(numRows, numColumns)); }
public JTableEx(final Vector rowData, final Vector columnNames) { super( rowData, columnNames ); }
public JTableEx(final Object[][] rowData, final Object[] columnNames) { super( rowData, columnNames ); }
public String getToolTipText(MouseEvent event) { int row = rowAtPoint( event.getPoint() ); int col = columnAtPoint( event.getPoint() ); Object o = getValueAt(row,col); if( o == null ) return null; if( o.toString().equals("") ) return null; return o.toString(); }
public Point getToolTipLocation(MouseEvent event) { int row = rowAtPoint( event.getPoint() ); int col = columnAtPoint( event.getPoint() ); Object o = getValueAt(row,col); if( o == null ) return null; if( o.toString().equals("") ) return null; Point pt = getCellRect(row, col, true).getLocation(); pt.translate(-1,-2); return pt; } } // End of Class JTableEx -------------------------------------------------------------------------
I am lost in the codes. Please help me. Thank you.
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
not sure what you're trying to do, but is DataTip a multi-line tooltip?
if so, try this
Vani Shastri
Ranch Hand
Joined: Aug 17, 2006
Posts: 52
posted
0
Thanks a lot for that Michael. But, thats a tool tip. At the point of the cursor, it displays the message (hardcoded in html). Is there a way to display the content of the cell (without repeating it again in the html) ? As sometimes the no. of characters exceeds the cell capacity.
Thank you.
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
> Is there a way to display the content of the cell (without repeating it again in the html)
one of the other parameters represents the contents of the cell. Try setting that as the toolTipText (without the html)
Vani Shastri
Ranch Hand
Joined: Aug 17, 2006
Posts: 52
posted
0
The return type of 'row' and 'column' in the method
is of the type int. Therefore, the values that these parameters return are integers but not the string in the cell. As a result, the content of the cell is not being tapped. How to tap the contents of the cell in the method getToolTipText() ?
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
Vani Shastri
Ranch Hand
Joined: Aug 17, 2006
Posts: 52
posted
0
when this piece of code is used,
lbl.setToolTipText(row);(instead of the html)
the error says - setToolTipText() is not applicable for arguments int. Therefore only a string can be passed to the above method. But, the 'row' and 'column' in the method:
I am a little confused. Have i understood it right? or am i wrong somewhere? The 'row' and 'column' keeps a count of no. of rows n cols but not the value in it. How to read the value in the cell?
Vani Shastri
Ranch Hand
Joined: Aug 17, 2006
Posts: 52
posted
0
when this piece of code is used,
lbl.setToolTipText(row);(instead of the html)
the error says - setToolTipText() is not applicable for arguments int. Therefore only a string can be passed to the above method. But, the 'row' and 'column' in the method:
I am a little confused. Have i understood it right? or am i wrong somewhere? The 'row' and 'column' keeps a count of no. of rows n cols but not the value in it. How to read the value in the cell?
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
> How to read the value in the cell?
read my previous replies.
Vani Shastri
Ranch Hand
Joined: Aug 17, 2006
Posts: 52
posted
0
Thank you so much. That was quite stupid of me for not having seen the solution properly. Have a nice day