📄 frame1.java
字号:
package com.cxlife.snake;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Frame1 extends JFrame { public static JPanel jPanel1 = new SnakePanel(); private BorderLayout borderLayout1 = new BorderLayout(); //Construct the frame public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));//(JPanel) this.getContentPane(); this.setSize(new Dimension(400, 300)); this.setTitle("Frame Title"); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(WindowEvent e) { this_windowOpened(e); } public void windowActivated(WindowEvent e) { this_windowActivated(e); } }); this.getContentPane().setLayout(borderLayout1); jPanel1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { jPanel1_mouseClicked(e); } }); this.getContentPane().add(jPanel1, BorderLayout.CENTER); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void jPanel1_mouseClicked(MouseEvent e) { } void this_windowOpened(WindowEvent e) { } void this_windowActivated(WindowEvent e) { jPanel1.requestFocus(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -