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

📄 testpanels.java

📁 java课件
💻 JAVA
字号:
/*
 * TestPanels.java
 *
 * Created on 2007年10月20日, 下午11:16
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
import java.awt.*;
import javax.swing.*;
/**
 *
 * @author admin
 */
public class TestPanels extends JFrame{
  
  /** Creates a new instance of TestPanels */
  public TestPanels() {
    //Get the content pane of the frame
    Container container = this.getContentPane();
    
    //set BorderLayout for the frame
    container.setLayout(new BorderLayout());
    
    //create panel p1 for the buttons and set GridLayout
    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(4,3));
    
    //add buttons to the panel
    for (int i = 1; i <=9; i++) {
      p1.add(new JButton(""+i));
    }
    p1.add(new JButton("0"));
    p1.add(new JButton("start"));
    p1.add(new JButton("stop"));
    
    //create panel p2 to hold a text field and p1
    JPanel p2 = new JPanel(new BorderLayout());
    p2.add(new JTextField("Time to be displayed here"), BorderLayout.NORTH);
    p2.add(p1, BorderLayout.CENTER);
    
    //add p2 and a button to the frame
    container.add(p2, BorderLayout.EAST);
    container.add(new JButton("Food to be placed here"), BorderLayout.CENTER);
  }

  public static void main(String[] args) {
    TestPanels frame = new TestPanels();
    
    frame.setTitle("The front view of a microwave oven");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400, 250);
    frame.setVisible(true);
  }
}

⌨️ 快捷键说明

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