1个回答
展开全部
import java.awt.event.*;
import javax.swing.*;
public class Hi extends JFrame
{
public static void main(String[] args)
{
new Hi();
}
Hi()
{
JButton b=new JButton("按钮");
JPanel p=new JPanel();
b.addMouseListener(new MouseAdapter()
{
public void mouseEntered(MouseEvent e)
{
b.setText("光标在按钮上");
}
public void mouseExited(MouseEvent e)
{
b.setText("按钮");
}
});
p.add(b);
add(p);
setSize(400,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setVisible(true);
}
}
import javax.swing.*;
public class Hi extends JFrame
{
public static void main(String[] args)
{
new Hi();
}
Hi()
{
JButton b=new JButton("按钮");
JPanel p=new JPanel();
b.addMouseListener(new MouseAdapter()
{
public void mouseEntered(MouseEvent e)
{
b.setText("光标在按钮上");
}
public void mouseExited(MouseEvent e)
{
b.setText("按钮");
}
});
p.add(b);
add(p);
setSize(400,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setVisible(true);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询