我想有一個動態的提示我JButton
,所以我用這樣的覆蓋方法JButton的動態提示文本...沒有顯示
JButton myJButton=new JButton("My Button"){
public String getToolTipText(MouseEvent evt){
ToolTipManager.sharedInstance().setInitialDelay(100);
ToolTipManager.sharedInstance().setDismissDelay(60000);
return "Test Tip Here";
} // Return plain text now, will be replaced by calculateTipText() later
};
當我有這樣的代碼,沒有工具提示完全顯示。
但是,如果我添加了這樣的另一條線......
myJButton.setToolTipText("Hi");
這點之後,提示將被正確地顯示爲Test Tip Here
。
爲什麼我的工具提示不起作用,直到我致電setToolTipText()
?
好了,你覆蓋默認實現。它完全按照你所說的做了:返回'Test Tip Here'。 – Obicere
http://www.michaelwilliams.co.za/simple-dynamic-tooltip-text-for-jcomponents-2/希望它能工作 – Simmant