我希望Cell
添加JTable
Tooltips
Cell
,其行为类似于Tooltips
。我的意思是当鼠标在Tooltip
上输入时,它会显示并消失一段时间后(与@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
final JLabel lable = new JLabel(value.toString());
EdgedBalloonStyle style = new EdgedBalloonStyle(new Color(255, 253, 245),
new Color(64, 64, 64));
BalloonTip tooltipBalloon = new BalloonTip(lable, new JLabel(value.toString()), style, new LeftAbovePositioner(15, 10), null);
ToolTipUtils.balloonToToolTip(tooltipBalloon, 400, 2000);
return lable;
}
相同但不是@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
final JLabel lable = new JLabel(value.toString());
EdgedBalloonStyle style = new EdgedBalloonStyle(new Color(255, 253, 245), new Color(64, 64, 64));
TablecellBalloonTip tcb = new TablecellBalloonTip(table, new JLabel(value.toString()),
row, column, style, BalloonTip.Orientation.LEFT_ABOVE,
BalloonTip.AttachLocation.ALIGNED, 30, 10, false);
return lable;
}
)。我试过这个,但没有按照预期为我工作。
Balloon Tip
这没有做任何事。 我也试过这个
{{1}}
这只是作为{{1}}而不是我所寻找的。 有什么建议?
答案 0 :(得分:1)
我认为问题在于你将你的气球附加到新创建的JLabel上......
...尝试将其添加到您的renderedCellCopmponent:
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
final JLabel lable = new JLabel(value.toString());
EdgedBalloonStyle style = new EdgedBalloonStyle(new Color(255, 253, 245), new Color(64, 64, 64));
//look, here is your mistake: you append it onto a new JLabel
//TablecellBalloonTip tcb = new TablecellBalloonTip(table,
// new JLabel(value.toString()), row, column, style,
// BalloonTip.Orientation.LEFT_ABOVE,
// BalloonTip.AttachLocation.ALIGNED, 30, 10, false);
//instead append it on your rendered Component
TablecellBalloonTip tcb = new TablecellBalloonTip(table,
lable, // !!here!!
row, column, style, BalloonTip.Orientation.LEFT_ABOVE,
BalloonTip.AttachLocation.ALIGNED, 30, 10, false);
return lable;
}
我希望有效...