simpleapplet2.java

来自「java swing 开发代码」· Java 代码 · 共 35 行

JAVA
35
字号
// SimpleApplet2.java// A contrived example of how to add components to an applet after it has// been initialized.  Code to disable the event queue checking is included// (but commented out) for use with older plug-ins.//package	jswing.ch08;import javax.swing.*;import java.awt.*;public class SimpleApplet2 extends JApplet {  public SimpleApplet2() {    // Suppress warning message on older versions if needed...    // getRootPane().putClientProperty("defeatSystemEventQueueCheck",    // Boolean.TRUE);  }  public void start() {    SwingUtilities.invokeLater(new Runnable() {      public void run() { // run in the event thread . . .        JPanel p = new JPanel();        p.setLayout(new GridLayout(2, 2, 2, 2));        p.add(new JLabel("Username"));        p.add(new JTextField());        p.add(new JLabel("Password"));        p.add(new JPasswordField());        Container content = getContentPane();        content.setLayout(new GridBagLayout()); // used to center the panel        content.add(p);        validate();      }    });  }}

⌨️ 快捷键说明

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