怎么去掉JFrame右上角关闭的×

Chendy1985 2005-10-02 04:01:34
在一个JFrame中,右上角有一个关闭JFrame的×,我想问问怎么把它屏蔽掉,就像屏蔽最大最小化的按钮一样,使他变为灰色不可用状态。谢谢:)
...全文
459 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
liangkandy2002 2005-10-07
  • 打赏
  • 举报
回复
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();
}
}
jin_j_y 2005-10-07
  • 打赏
  • 举报
回复
我把我知道的相关信息告诉你,希望有所帮助。
JFrame 对象可以通过 setUndecorated(true)方法来把整个标题栏去掉,包括把×去掉。
JInternalFrame 对象可以把super的参数全部设为false,这样就不会有×,但是仍然有标题栏。
Chendy1985 2005-10-07
  • 打赏
  • 举报
回复
But how to disable the message?In fact,there is no message-code in a class about the button ×!
skycncomp 2005-10-04
  • 打赏
  • 举报
回复
不清楚,学习中。。。。。。
busade1 2005-10-04
  • 打赏
  • 举报
回复
maybe you can disable the message sent to the button ×.

Then find some material about message in Java.
_-_-_-_- 2005-10-03
  • 打赏
  • 举报
回复
??
楼上可以具体点吗??
我也想知道
Chendy1985 2005-10-03
  • 打赏
  • 举报
回复
用JWindow是连顶部那一行都没有了,我是想问问有没有什么方法可以屏蔽掉关闭按钮×
yonghar 2005-10-02
  • 打赏
  • 举报
回复
用JWindow

62,634

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧