myframewithcomponents.java

来自「java课件」· Java 代码 · 共 31 行

JAVA
31
字号
import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JFrame;
/*
 * MyFrameWithComponents.java
 *
 * Created on 2007年10月20日, 下午10:25
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

/**
 *
 * @author admin
 */
public class MyFrameWithComponents {
  public static void main(String[] args) {
    JFrame frame = new JFrame("Adding Components into the Frame");
    
    //向窗口中添加一个按钮
    Container container = frame.getContentPane();
    JButton jbtOK = new JButton("OK");
    container.add(jbtOK);
    
    frame.setSize(400,300);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }  
}

⌨️ 快捷键说明

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