applet1.java~4~

来自「一个在java程序中自动控制web页面大小的程序」· JAVA~4~ 代码 · 共 83 行

JAVA~4~
83
字号
package tmp;import java.awt.*;import java.awt.event.*;import java.applet.*;import javax.swing.*;import com.borland.jbcl.layout.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Applet1 extends Applet {  private boolean isStandalone = false;  JTextField txtWidth = new JTextField();  JTextField txtHeight = new JTextField();  JButton cmdSet = new JButton();  XYLayout xYLayout1 = new XYLayout();  //Get a parameter value  public String getParameter(String key, String def) {    return isStandalone ? System.getProperty(key, def) :      (getParameter(key) != null ? getParameter(key) : def);  }  //Construct the applet  public Applet1() {  }  //Initialize the applet  public void init() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception {    cmdSet.setText("jButton1");    cmdSet.addActionListener(new Applet1_cmdSet_actionAdapter(this));    txtWidth.setText("");    txtHeight.setText("");    this.setLayout(xYLayout1);    this.add(txtWidth,   new XYConstraints(0, 6, 401, -1));    this.add(txtHeight,   new XYConstraints(0, 38, 401, -1));    this.add(cmdSet, new XYConstraints(0, 67, -1, -1));  }  //Get Applet information  public String getAppletInfo() {    return "Applet Information";  }  //Get parameter info  public String[][] getParameterInfo() {    return null;  }  void cmdSet_actionPerformed(ActionEvent e) {    this.setSize(Integer.parseInt(txtWidth.getText()),Integer.parseInt(txtHeight.getText()));    this.repaint();  }}class Applet1_cmdSet_actionAdapter implements java.awt.event.ActionListener {  Applet1 adaptee;  Applet1_cmdSet_actionAdapter(Applet1 adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.cmdSet_actionPerformed(e);  }}

⌨️ 快捷键说明

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