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

📄 frame1.java~9~

📁 是用java开发的一些程序原代码 是用java开发的一些程序原代码
💻 JAVA~9~
字号:
package ex04_07;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Frame1 extends JFrame {  JPanel contentPane;  JButton jButton1 = new JButton();  JButton jButton2 = new JButton();  JLabel jLabel1 = new JLabel();  JLabel jLabel2 = new JLabel();  /**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();    jButton1.setText("jButton1");    jButton1.setBounds(new Rectangle(50, 16, 79, 29));    jButton1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton1_actionPerformed(e);      }    });    contentPane.setLayout(null);    this.setSize(new Dimension(400, 300));    this.setTitle("Frame Title");    jButton2.setText("jButton2");    jButton2.setBounds(new Rectangle(141, 16, 79, 29));    jButton2.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton2_actionPerformed(e);      }    });    jLabel1.setText("jLabel1");    jLabel1.setBounds(new Rectangle(41, 94, 41, 19));    jLabel2.setText("jLabel2");    jLabel2.setBounds(new Rectangle(136, 94, 41, 19));    contentPane.add(jLabel2, null);    contentPane.add(jLabel1, null);    contentPane.add(jButton1, null);    contentPane.add(jButton2, null);  }  /**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 jButton1_actionPerformed(ActionEvent e) {  Icon mypic = new ImageIcon("C:\\jbsample\\twbts.gif");'jLabel1.setSize(mypic.getIconWidth(),mypic.getIconHeight());jLabel1.setIcon(mypic);  }void jButton2_actionPerformed(ActionEvent e) {jLabel2.setSize(jLabel1.getSize());jLabel2.setIcon(jLabel1.getIcon());  }}

⌨️ 快捷键说明

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