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

📄 picturebutton.java

📁 learning java的源代码。书中每个实例都有相关的代码example。
💻 JAVA
字号:
//file: PictureButton.javaimport java.awt.*;import java.awt.event.*;import javax.swing.*;public class PictureButton extends JFrame {  public PictureButton(  ) {    super("PictureButton v1.0");    setSize(200, 200);    setLocation(200, 200);    Icon icon = new ImageIcon("rhino.gif");    JButton button = new JButton(icon);    button.addActionListener(new ActionListener(  ) {      public void actionPerformed(ActionEvent ae) {        System.out.println("Urp!");      }    });    Container content = getContentPane(  );    content.setLayout(new FlowLayout(  ));    content.add(button);  }  public static void main(String[] args) {    JFrame f = new PictureButton(  );    f.addWindowListener(new WindowAdapter(  ) {      public void windowClosing(WindowEvent we) { System.exit(0); }    });    f.setVisible(true);  }}

⌨️ 快捷键说明

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