| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 404 人关注过本帖
标题:我点击这个确定按钮时窗口无法关闭而且报错?
取消只看楼主 加入收藏
ysf465639310
Rank: 2
等 级:论坛游民
帖 子:4
专家分:10
注 册:2013-9-20
结帖率:0
收藏
 问题点数:0 回复次数:0 
我点击这个确定按钮时窗口无法关闭而且报错?
//这是子类:
public class pannel2 extends JFrame {
private static final long serialVersionUID = 1L;
private String title = "帮助文档";
Container con = getContentPane();
JButton button_sure = new JButton("确定");
// private JFrame f=new JFrame();
private JTextArea textArea = new JTextArea(20, 40);
private Box vbox = Box.createVerticalBox();
private Box hbox1 = Box.createHorizontalBox();
private Box hbox2 = Box.createHorizontalBox();
private int HEIGHT = 400;
private int WIDTH = 600;
@SuppressWarnings("deprecation")
public pannel2() throws Exception {
this.setSize(WIDTH, HEIGHT);
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int HEIGHT1 = screenSize.height;
int WIDTH1 = screenSize.width;
int X = (WIDTH1 - WIDTH) / 2 - 100;
int Y = (HEIGHT1 - HEIGHT) / 2 - 100;
this.setTitle(title);
this.setSize(WIDTH, HEIGHT);
this.setSize(WIDTH, HEIGHT);
this.setLocation(X, Y);
this.setResizable(false);
this.setTitle(title);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setOpacity((float) 0.85);
this.setBackground(Color.YELLOW);
textArea.setLineWrap(true);
textArea.setEditable(false);
textArea.setOpaque(true);
hbox1.add(textArea);
hbox2.add(button_sure);
vbox.add(hbox1);
vbox.add(Box.createVerticalStrut(2));
vbox.add(hbox2);
con.add(vbox, BorderLayout.CENTER);
button_sure.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
// TODO Auto-generated method stub
if (button_sure == a.getSource()) {
((JFrame)a.getSource()).dispose();//错误在这,但我不会改求帮助
}
}
});
this.pack();
this.show();
}
}

//mian函数
public class pannel2test {
public static void main(String[] args) throws Exception {      
     pannel2 p2 =new pannel2();  
}   
}
帮我看看因该如何修改呢?
搜索更多相关主题的帖子: private public title 而且 
2013-09-21 13:44
快速回复:我点击这个确定按钮时窗口无法关闭而且报错?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026946 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved