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

📄 nulllayoutframe.java~11~

📁 jbuilder2006一书的所有源代码
💻 JAVA~11~
字号:
package layout;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class NullLayoutFrame extends JFrame {  JPanel contentPane;  //创建3个按钮  JButton jButton1 = new JButton();  JButton jButton2 = new JButton();  JButton jButton3 = new JButton();  public NullLayoutFrame() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  private void jbInit() throws Exception  {    contentPane = (JPanel) this.getContentPane();    //将布局设为null    contentPane.setLayout(null);    this.setSize(new Dimension(400, 300));    this.setTitle("NullLayout示例");    jButton1.setText("jButton1");    jButton2.setText("jButton2");    jButton3.setText("jButton3");    //设置按钮的位置和大小    jButton1.setBounds(new Rectangle(38, 25, 77, 157));    jButton2.setBounds(new Rectangle(130, 28, 251, 52));    jButton3.setBounds(new Rectangle(129, 87, 252, 97));    //为窗口面板加入按钮    contentPane.add(jButton1, null);    contentPane.add(jButton2, null);    contentPane.add(jButton3, null);  }  protected void processWindowEvent(WindowEvent e) {    if (e.getID() == WindowEvent.WINDOW_CLOSING) {      System.exit(0);    }  }}

⌨️ 快捷键说明

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