jfive.java

来自「这个是JAVA方面的联系程序」· Java 代码 · 共 36 行

JAVA
36
字号
import javax.swing.*;
import java.awt.Container;
import java.awt.event.*;
public class JFive extends JFrame implements ActionListener{
	DrawPanel drawPanel = new DrawPanel();
	
	JMenuBar menuBar = new JMenuBar(); //菜单栏
	JMenu sysMenu = new JMenu("系统"); //菜单
	JMenuItem startMenuItem = new JMenuItem("开始游戏");
	
	public JFive() {
		super("五子棋");
		//设置菜单栏
		setJMenuBar(menuBar);
		menuBar.add(sysMenu);
		sysMenu.add(startMenuItem);
		startMenuItem.addActionListener(this);
		
		//取得内容面版
		Container c = getContentPane();
		c.add(drawPanel);//向内容面版添加绘制面版
		setSize(520,550);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	public void actionPerformed(ActionEvent e) {
		drawPanel.restartGame();
		//JOptionPane.showMessageDialog(this,"hello, world!");
	}
	
	public static void main(String[] args) {
		JFive f = new JFive();
		f.setVisible(true);
	}
	
}

⌨️ 快捷键说明

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