HIho!
Also ich habe nen TableCellRenderer überschrieben, wo ich ein JPanel zurückgebe, auf das ich via FlowLayout eine billige Anzahl an JLabels drauflege!
Das klappt soweit ganz gut!
Dann habe ich beim JPanel noch die getToolTipText(MouseEvent ev) überschrieben, sodaß ich für jedes JLabel den Tooltip zurückgegeben kann!
jedoch is hier das Problem, das wenn ich sage JPanel.getComponentAt(ev.getPoint()) null zurückkommt...
Und wenn ich via getComponent(nummer) alle Componenten durchgehe und mir getBounds und getLocation ausgeben lasse, so hat dort jede Position immer 0!
Warum ist das so und wie kann ich nun wirklich die Positon abfragen?!
Ajo und getLocationOnScreen() liefert ne Exception, weil das Item angeblich gar nicht angezeigt wird?!
BspCode
Also ich habe nen TableCellRenderer überschrieben, wo ich ein JPanel zurückgebe, auf das ich via FlowLayout eine billige Anzahl an JLabels drauflege!
Das klappt soweit ganz gut!
Dann habe ich beim JPanel noch die getToolTipText(MouseEvent ev) überschrieben, sodaß ich für jedes JLabel den Tooltip zurückgegeben kann!
jedoch is hier das Problem, das wenn ich sage JPanel.getComponentAt(ev.getPoint()) null zurückkommt...
Und wenn ich via getComponent(nummer) alle Componenten durchgehe und mir getBounds und getLocation ausgeben lasse, so hat dort jede Position immer 0!
Warum ist das so und wie kann ich nun wirklich die Positon abfragen?!
Ajo und getLocationOnScreen() liefert ne Exception, weil das Item angeblich gar nicht angezeigt wird?!
BspCode
Code:
public class TableRenderer extends JPanel implements TableCellRenderer
public String getToolTipText(java.awt.event.MouseEvent ev)
{
System.out.println("HIER: " + ev.getPoint() + " CNT: " + this.getComponentCount());
Component comp = this.getComponentAt(ev.getPoint());
System.out.println(comp);
if(comp != null && comp instanceof JComponent)
{
return ((JComponent)comp).getToolTipText();
}
else
{
int cnt = this.getComponentCount();
for(int x = 0; x != cnt; x++)
{
comp = this.getComponent(x);
System.out.println(comp + " == " + comp.getBounds() + " " + " " + comp.getLocation(ev.getPoint()));
}
}
return null;
}
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
this.setBackground(table.getBackground());
this.removeAll();
this.validate();
if(isNew || isDelete)
{
JLabel tmp = new JLabel("NEW");
tmp.setToolTipText("AAAABBBBCCC");
this.add(tmp);
}
if(isDelete)
this.add(new javax.swing.JLabel("DEL"));
if(isMarket)
this.add(new javax.swing.JLabel("MAR"));
this.validate();
this.repaint();
if(isSelected || hasFocus)
this.setBackground(table.getSelectionBackground());
return this;
}
}