日期:2014-05-20 浏览次数:20903 次
<input type="button" value="open" title="this is a button" onMouseOut="" onMouseOver=""/>
------解决方案--------------------
http://blog.csdn.net/doymm2008/article/details/4820243
这里讲的很清楚哈~
------解决方案--------------------
增加addMouseListener,里面有两个方法,mouseEntered(MouseEvent e) 鼠标进入组件时调用;
mouseExited(MouseEvent e)鼠标离开组件时调用。
------解决方案--------------------
你可以在上面加个label什么的,移上去让这个label显示,移走就隐藏呗。大概就这么做
------解决方案--------------------
public class TestButton extends JFrame {
private JButton jButton1;
public TestButton() {
initGUI();
this.setLocationRelativeTo(null);
}
private void initGUI() {
try {
{
getContentPane().setLayout(null);
{
jButton1 = new JButton();
getContentPane().add(jButton1);
jButton1.setText("test");
jButton1.addMouseListener(new MouseAdapter() {
//鼠标进入事件
public void mouseEntered(MouseEvent e) {
jButton1.setText("move on");
}
//鼠标移出事件
public void mouseExited(MouseEvent e) {
jButton1.setText("");
}
});
jButton1.setBounds(109, 39, 161, 107);
}
}
{
this.setSize(426, 241);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String args[]) {
new TestButton().setVisible(true);
}
}
------解决方案--------------------
在eclipse里装windowbuilder 可以方便地可视化设计swing
JButton btnNewButton = new JButton("New button");
btnNewButton.setToolTipText("<html><body bgcolor='red'>move on</body></html>");
http://topic.csdn.net/t/20061012/17/5078236.html