怎么去掉JFrame右上角关闭的× 在一个JFrame中,右上角有一个关闭JFrame的×,我想问问怎么把它屏蔽掉,就像屏蔽最大最小化的按钮一样,使他变为灰色不可用状态。谢谢:) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用JWindow是连顶部那一行都没有了,我是想问问有没有什么方法可以屏蔽掉关闭按钮× maybe you can disable the message sent to the button ×.Then find some material about message in Java. But how to disable the message?In fact,there is no message-code in a class about the button ×! 我把我知道的相关信息告诉你,希望有所帮助。JFrame 对象可以通过 setUndecorated(true)方法来把整个标题栏去掉,包括把×去掉。JInternalFrame 对象可以把super的参数全部设为false,这样就不会有×,但是仍然有标题栏。 import java.awt.*;import java.awt.event.*;public class FrameTest { static Point origin = new Point(); public static void main (String args[]) { final Frame frame = new Frame(); frame.setUndecorated(true); frame.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { origin.x = e.getX(); origin.y = e.getY(); } }); frame.addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { Point p = frame.getLocation(); frame.setLocation( p.x + e.getX() - origin.x, p.y + e.getY() - origin.y); } }); frame.setSize(300, 300); Button b1 = new Button("Maximize"); b1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { frame.setExtendedState(Frame.MAXIMIZED_BOTH); } }); Button b2 = new Button("Iconify"); b2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Preserve maximizing frame.setExtendedState(Frame.ICONIFIED | frame.getExtendedState()); } }); Button b3 = new Button("Normal"); b3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { frame.setExtendedState(Frame.NORMAL); } }); Button b4 = new Button("Close"); b4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); frame.setLayout(new GridLayout(5,1)); frame.add(b1); frame.add(b2); frame.add(b3); frame.add(b4); frame.show(); }} 关于float和double后面小数点数的问题 java小程序出错 while(true)问题 java中main参数传入值的问题 帮我解决一个小问题,谢谢大家。 jdbc中resultset高级问题,为什么第二次取记录集rs1时开始取的记录集rs为空了??? 很考人哦! 说说!如何配置JSP运行环境?前5位有分! 如何动态设置一个编辑区(文本区域)中某一行的前景色和背景色? 请问哪里有JDK 1.4的Linux版本下载, www.javasoft.com不能下载 JSplitPane组件的什么属性或什么方法是用来设置外观的? [??在线等]关于this??
JFrame 对象可以通过 setUndecorated(true)方法来把整个标题栏去掉,包括把×去掉。
JInternalFrame 对象可以把super的参数全部设为false,这样就不会有×,但是仍然有标题栏。
import java.awt.event.*;public class FrameTest {
static Point origin = new Point();
public static void main (String args[]) {
final Frame frame = new Frame();
frame.setUndecorated(true);
frame.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
origin.x = e.getX();
origin.y = e.getY();
}
});
frame.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {
Point p = frame.getLocation();
frame.setLocation(
p.x + e.getX() - origin.x,
p.y + e.getY() - origin.y);
}
});
frame.setSize(300, 300);
Button b1 = new Button("Maximize");
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
}
});
Button b2 = new Button("Iconify");
b2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Preserve maximizing
frame.setExtendedState(Frame.ICONIFIED
| frame.getExtendedState());
}
});
Button b3 = new Button("Normal");
b3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.setExtendedState(Frame.NORMAL);
}
});
Button b4 = new Button("Close");
b4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
frame.setLayout(new GridLayout(5,1));
frame.add(b1);
frame.add(b2);
frame.add(b3);
frame.add(b4);
frame.show();
}
}