myframe1.java

来自「用java实现面板的相关操作」· Java 代码 · 共 54 行

JAVA
54
字号
import java.awt.*;
import java.awt.event.*;
public class MyFrame1 extends Frame
{
	Button bt=new Button("exit");
	Button bt1=new Button("really??");
	public MyFrame1(String title)
	{
		super(title);
		initComponent();
	}
	public void initComponent()
	{
		this.setSize(800,600);
		this.setLocation(200,100);
		this.setBackground(Color.orange);
		this.setLayout(new FlowLayout());
		this.add(bt);
		this.add(bt1);
		this.addWindowListener(new WindowListener()
		{
			public void windowActivated(WindowEvent e) 
      {
      }    //Invoked when the Window is set to be the active Window. 
 			public void windowClosed(WindowEvent e) 
      {
      }    //Invoked when a window has been closed as the result of calling dispose on the window. 
 			public void windowClosing(WindowEvent e) 
      {
      	System.exit(0);
      }    //Invoked when the user attempts to close the window from the window's system menu. 
 			public void windowDeactivated(WindowEvent e) 
      {
      }    //Invoked when a Window is no longer the active Window. 
 			public void windowDeiconified(WindowEvent e) 
      {
      }    //Invoked when a window is changed from a minimized to a normal state. 
 			public void windowIconified(WindowEvent e) 
      {
      }    //Invoked when a window is changed from a normal to a minimized state. 
 			public void windowOpened(WindowEvent e) 
			{
			}
		});
     
		bt.addActionListener(new MyActionListener());
	  bt1.addActionListener(new MyActionListener());
}
	public static void main(String args[])
	{
		MyFrame1 mf=new MyFrame1("hello");
		mf.setVisible(true);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?