frame1.java~11~
来自「前段时间帮同学写了个简单动画程序:“贪食蛇的原型”」· JAVA~11~ 代码 · 共 61 行
JAVA~11~
61 行
package com.cxlife.snake;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Frame1 extends JFrame { private 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 + =
减小字号Ctrl + -
显示快捷键?