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

📄 frame1.java~2~

📁 jbuilder8开发的十个实用例子。
💻 JAVA~2~
字号:
package cardlayout;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;public class Frame1 extends JFrame {  JPanel contentPane;  CardLayout cardLayout1 = new CardLayout();  Panel panel1 = new Panel();  Panel panel2 = new Panel();  Panel panel3 = new Panel();  Button button1 = new Button();  Label label1 = new Label();  Button button2 = new Button();  Label label2 = new Label();  Button button3 = new Button();  Label label3 = 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(cardLayout1);    this.setResizable(false);    this.setSize(new Dimension(230, 191));    this.setTitle("CardLayout演示程序");    button1.setLabel("Next>");    button1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        button_actionPerformed(e);      }    });    label1.setText("This is the first card in cardlayout");    button2.setLabel("Next>");    button2.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        button_actionPerformed(e);      }    });    label2.setText("This is the second card in cardlayout");    button3.setLabel("Next>");    button3.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        button_actionPerformed(e);      }    });    label3.setText("This is the third card in cardlayout");    panel1.add(button1, null);    panel1.add(label1, null);    contentPane.add(panel1,  "panel1");    contentPane.add(panel2,   "panel2");    panel2.add(button2, null);    panel2.add(label2, null);    contentPane.add(panel3,     "panel3");    panel3.add(button3, null);    panel3.add(label3, 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 button_actionPerformed(ActionEvent e) {    cardLayout1.next(contentPane);  }}

⌨️ 快捷键说明

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