frame1.java

来自「是用java开发的一些程序原代码 是用java开发的一些程序原代码」· Java 代码 · 共 62 行

JAVA
62
字号
package ex08_11;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Frame1 extends JFrame {  JPanel contentPane;  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]")));    contentPane = (JPanel) this.getContentPane();    contentPane.setLayout(borderLayout1);    this.setSize(new Dimension(400, 300));    this.setTitle("Frame Title");    this.addMouseListener(new java.awt.event.MouseAdapter() {      public void mouseReleased(MouseEvent e) {        this_mouseReleased(e);      }      public void mousePressed(MouseEvent e) {        this_mousePressed(e);      }    });  }  /**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);    }  }//声明画线起点的变量Point startpoint;  void this_mouseReleased(MouseEvent e) {  //声明一个绘图区Graphics mypaint;mypaint=getGraphics();//画线mypaint.drawLine(startpoint.x,startpoint.y,e.getX(),e.getY());  }  void this_mousePressed(MouseEvent e) {  //记录画线起点startpoint=e.getPoint();  }}

⌨️ 快捷键说明

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