⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simple2.java

📁 金旭亮的java教案
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Simple2
{
	private static JFrame frame;
	private static JPanel myPanel;
	private JButton button1;
	private JButton button2;
	
	public Simple2()
	{
		myPanel=new JPanel();
		button1=new JButton("Button 1");
		button2=new JButton("Button 2");
		
				
		button1.addActionListener(
			new ActionListener()
			{
				public void actionPerformed(ActionEvent e)
				{
					JOptionPane.showMessageDialog(frame,"Button 1 Pressed");
				}
			}
		);
		
		button2.addActionListener(
			new ActionListener()
			{
				public void actionPerformed(ActionEvent e)
				{
					JOptionPane.showMessageDialog(frame,"Button 2 Pressed");
				}
			}
		);
		
		
		myPanel.add(button1);
		myPanel.add(button2);
		
	}
	
	public static void main(String s[])
	{
		Simple2 gui=new Simple2();
		frame=new JFrame("Simple2");
		frame.addWindowListener(
			new WindowAdapter()
			{
				public void windowClosing(WindowEvent e)
				{
					System.exit(0);
				}
			
			});
		frame.getContentPane().add(myPanel);
		frame.pack();
		frame.setVisible(true);
	}
		
}
	

⌨️ 快捷键说明

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