Topic: Eclipse3.2中如何关闭frame窗口 |
Print this page |
1.Eclipse3.2中如何关闭frame窗口 | Copy to clipboard |
Posted by: helloyxw Posted on: 2008-02-20 01:22 在Eclipse中写了一段代码,运行后出现一个窗口,如何关闭这个窗口呢?谢谢高人指点. import java.awt.*; public class MyFrame { /** * @param args */ public static void main(String[] args) { Frame f = new Frame("yxw"); f.setSize(600, 400); f.setLocation(100, 100); f.setBackground(Color.blue); f.show(); } } |
2.Re:Eclipse3.2中如何关闭frame窗口 [Re: helloyxw] | Copy to clipboard |
Posted by: jeff_jian Posted on: 2008-02-25 12:56 给f添加个事件监听器,还有建议不要用show()方法,改用setVisible(boolean); 代码如下: import java.awt.Color; import java.awt.Frame; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class tmp { /** * @param args */ public static void main(String[] args) { Frame f = new Frame("yxw"); f.setSize(600, 400); f.setLocation(100, 100); f.setBackground(Color.blue); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setVisible(true); // f.show(); } } |
3.Re:Eclipse3.2中如何关闭frame窗口 [Re: helloyxw] | Copy to clipboard |
Posted by: Joffeec Posted on: 2008-05-28 10:27 在Eclipse3.2的控制台窗口中,点击右上角的红色方块就行了。 |
4.Re:Eclipse3.2中如何关闭frame窗口 [Re: Joffeec] | Copy to clipboard |
Posted by: JiafanZhou Posted on: 2008-05-30 17:36 Joffeec wrote: haha... this is totally a hacking method. |
5.Re:Eclipse3.2中如何关闭frame窗口 [Re: helloyxw] | Copy to clipboard |
Posted by: 黑骏马 Posted on: 2008-06-28 10:14 添加个事件监听器,不要用show()方法,另外,把引入的接口写的简练点。 import java.awt.*; import java.awt.event.*; public class MyFrame { public static void main(String[] args) { Frame f = new Frame("yxw"); f.setSize(600, 400); f.setLocation(100, 100); f.setBackground(Color.blue); f.setVisible(true); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } } |
6.Re:Eclipse3.2中如何关闭frame窗口 [Re: HenryShanley] | Copy to clipboard |
Posted by: Joffeec Posted on: 2008-07-01 07:55 Joffeec wrote: HenryShanley wrote: 呵呵………对于还没有学到事件处理的,这样做是没有办法中的办法…… |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |