2 回答
TA贡献1880条经验 获得超4个赞
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class MouseDemo extends JFrame {
private static final long serialVersionUID = 1L;
boolean IS_MAXIMIZED = false;
public MouseDemo() {
super("DoubleClick Demo");
this.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
if (IS_MAXIMIZED) {
setExtendedState(JFrame.NORMAL);
IS_MAXIMIZED = false;
} else {
setExtendedState(JFrame.MAXIMIZED_BOTH);
IS_MAXIMIZED = true;
}
}
}
});
this.setSize(new Dimension(200, 150));
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String args[]) {
new MouseDemo().setVisible(true);
}
}
- 2 回答
- 0 关注
- 629 浏览
添加回答
举报