String to JComponent
I'm using BalloonTip in my code, and I need this constructor:
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, 开发者_如何学Calignment, attachLocation, horizontalOffset, verticalOffset, useCloseButton);
setup(table, row, column);
}
In older versions, second parameter was a String and it worked, but not anymore. I need a String into a JComponent then, but I don't know how to.
This kind of question is easily answered by reading the javadoc and manual of the API (which I was able to find with a simple Google search, although I've never heard of this API before).
But even without knowing the API, if it now takes a JComponent
, it's because it's now able to display any kind of component inside the balloon tip. Since you want to simply render some text, using a JLabel
initialized with your string seems like the obvious solution.
精彩评论