错哪了,关于关闭java图形化窗口小程序
importjava.awt.*;importjava.awt.event.*;publicclassMyFrame{publicstaticvoidmain(Strin...
import java.awt.*;
import java.awt.event.*;
public class MyFrame
{ public static void main(String args[])
{
Frame f=new Frame("mybole");
f.setSize(600,400);
f.setLocation(100,100);
f.setBackground(Color.blue);
//f.setLayout(new BorderLayout(10,10));
//f.setLayout(new FlowLayout(FlowLayout.LEFT));
f.setLayout(new GridLayout(3,2,10,10));
Button btn1=new Button("sunxin");
Button btn2=new Button("weixin");
Button btn3=new Button("WEST");
Button btn4=new Button("EAST");
Button btn5=new Button("CENTER");
f.add(btn1,"North");
f.add(btn2,"South");
f.add(btn3,"West");
f.add(btn4,"East");
f.add(btn5,"Center");
f.addWindowListener(new MywindowListener());
f.show();
}
class MywindowListener implements WindowListener
{
public void WindowOpened(WindowEvent e)
{
}
public void WindowClosing(WindowEvent e)
{
System.exit(0);
}
public void WindowClosed(WindowEvent e)
{
}
public void WindowIconified(WindowEvent e)
{
}
public void WindowDeiconified(WindowEvent e)
{
}
public void WindowActivated(WindowEvent e)
{
}
public void WindowDeactivated(WindowEvent e)
{
}
public void windowActivated(WindowEvent e) {
// TODO Auto-generated method stub
}
public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub
}
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
}
public void windowDeactivated(WindowEvent e) {
// TODO Auto-generated method stub
}
public void windowDeiconified(WindowEvent e) {
// TODO Auto-generated method stub
}
public void windowIconified(WindowEvent e) {
// TODO Auto-generated method stub
}
public void windowOpened(WindowEvent e) {
// TODO Auto-generated method stub
}
}
}
哪里有错啊,请高手指点 展开
import java.awt.event.*;
public class MyFrame
{ public static void main(String args[])
{
Frame f=new Frame("mybole");
f.setSize(600,400);
f.setLocation(100,100);
f.setBackground(Color.blue);
//f.setLayout(new BorderLayout(10,10));
//f.setLayout(new FlowLayout(FlowLayout.LEFT));
f.setLayout(new GridLayout(3,2,10,10));
Button btn1=new Button("sunxin");
Button btn2=new Button("weixin");
Button btn3=new Button("WEST");
Button btn4=new Button("EAST");
Button btn5=new Button("CENTER");
f.add(btn1,"North");
f.add(btn2,"South");
f.add(btn3,"West");
f.add(btn4,"East");
f.add(btn5,"Center");
f.addWindowListener(new MywindowListener());
f.show();
}
class MywindowListener implements WindowListener
{
public void WindowOpened(WindowEvent e)
{
}
public void WindowClosing(WindowEvent e)
{
System.exit(0);
}
public void WindowClosed(WindowEvent e)
{
}
public void WindowIconified(WindowEvent e)
{
}
public void WindowDeiconified(WindowEvent e)
{
}
public void WindowActivated(WindowEvent e)
{
}
public void WindowDeactivated(WindowEvent e)
{
}
public void windowActivated(WindowEvent e) {
// TODO Auto-generated method stub
}
public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub
}
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
}
public void windowDeactivated(WindowEvent e) {
// TODO Auto-generated method stub
}
public void windowDeiconified(WindowEvent e) {
// TODO Auto-generated method stub
}
public void windowIconified(WindowEvent e) {
// TODO Auto-generated method stub
}
public void windowOpened(WindowEvent e) {
// TODO Auto-generated method stub
}
}
}
哪里有错啊,请高手指点 展开
3个回答
展开全部
import java.awt.*;
import java.awt.event.*;
public class MyFrame {
public static void main(String args[]) {
Frame f = new Frame("mybole");
f.setSize(600, 400);
f.setLocation(100, 100);
f.setBackground(Color.blue);
f.setLayout(new GridLayout(3, 2, 10, 10));
Button btn1 = new Button("sunxin");
Button btn2 = new Button("weixin");
Button btn3 = new Button("WEST");
Button btn4 = new Button("EAST");
Button btn5 = new Button("CENTER");
f.add(btn1, "North");
f.add(btn2, "South");
f.add(btn3, "West");
f.add(btn4, "East");
f.add(btn5, "Center");
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
f.setVisible(true);
}
}
import java.awt.event.*;
public class MyFrame {
public static void main(String args[]) {
Frame f = new Frame("mybole");
f.setSize(600, 400);
f.setLocation(100, 100);
f.setBackground(Color.blue);
f.setLayout(new GridLayout(3, 2, 10, 10));
Button btn1 = new Button("sunxin");
Button btn2 = new Button("weixin");
Button btn3 = new Button("WEST");
Button btn4 = new Button("EAST");
Button btn5 = new Button("CENTER");
f.add(btn1, "North");
f.add(btn2, "South");
f.add(btn3, "West");
f.add(btn4, "East");
f.add(btn5, "Center");
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
f.setVisible(true);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询