-1

我在我的代码中使用 BalloonTip,我需要这个构造函数:

    public TablecellBalloonTip(JTable table, JComponent component, int row, int column, BalloonTipStyle style, Orientation alignment, AttachLocation attachLocation, int horizontalOffset, int verticalOffset, boolean useCloseButton) {
    super(table, component, table.getCellRect(row, column, true), style, alignment, attachLocation, horizontalOffset, verticalOffset, useCloseButton);
    setup(table, row, column);
}

在旧版本中,第二个参数是一个字符串,它可以工作,但现在不行了。然后我需要一个字符串到一个 JComponent 中,但我不知道该怎么做。

4

1 回答 1

2

通过阅读 API 的 javadoc 和手册可以轻松回答这类问题(我可以通过简单的 Google 搜索找到,尽管我以前从未听说过这个 API)。

但即使不知道 API,如果它现在需要一个JComponent,那是因为它现在能够在气球提示内显示任何类型的组件。由于您只想渲染一些文本,因此使用JLabel字符串初始化似乎是显而易见的解决方案。

于 2011-07-05T10:42:28.147 回答