frame1.java~3~

来自「使用jbuilder开发工具开发的java十个例子代码」· JAVA~3~ 代码 · 共 68 行

JAVA~3~
68
字号
package statusbar;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Frame1 extends JFrame {  JPanel contentPane;  BorderLayout borderLayout1 = new BorderLayout();  Scrollbar scrollbar1 = new Scrollbar();  Label label1 = new Label();  /**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.setResizable(false);    this.setSize(new Dimension(192, 125));    this.setTitle("状态栏演示程序");    scrollbar1.setOrientation(0);    scrollbar1.addAdjustmentListener(new java.awt.event.AdjustmentListener() {      public void adjustmentValueChanged(AdjustmentEvent e) {        scrollbar1_adjustmentValueChanged(e);      }    });    label1.setText("label1");    contentPane.add(scrollbar1, BorderLayout.SOUTH);    contentPane.add(label1, 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 button1_actionPerformed(ActionEvent e) {label1.setText("You hava clicked button1");  }  void button2_actionPerformed(ActionEvent e) {label1.setText("You hava clicked button2");  }  void button3_actionPerformed(ActionEvent e) {label1.setText("You hava clicked button3");  }  void button4_actionPerformed(ActionEvent e) {label1.setText("You hava clicked button4");  }  void scrollbar1_adjustmentValueChanged(AdjustmentEvent e) {  }}

⌨️ 快捷键说明

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