📄 applet1.java~7~
字号:
package jishuji;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.JButton;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Applet1 extends Applet {
boolean isStandalone = false;
BorderLayout borderLayout1 = new BorderLayout();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JTextField jTextField1 = new JTextField();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
JButton jButton5 = new JButton();
JButton jButton6 = new JButton();
//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 {
jButton1.setBounds(new Rectangle(61, 203, 81, 23));
jButton1.setText("+");
jButton1.addActionListener(new Applet1_jButton1_actionAdapter(this));
this.setLayout(null);
jButton2.setBounds(new Rectangle(159, 206, 81, 23));
jButton2.setText("jButton2");
jTextField1.setHorizontalAlignment(SwingConstants.RIGHT);
jTextField1.setBounds(new Rectangle(1, 75, 391, 22));
jButton3.setBounds(new Rectangle(59, 255, 81, 23));
jButton3.setText("jButton3");
jButton4.setBounds(new Rectangle(159, 256, 81, 23));
jButton4.setText("jButton4");
jButton5.setBounds(new Rectangle(275, 207, 81, 23));
jButton5.setText("立方");
jButton5.addActionListener(new Applet1_jButton5_actionAdapter(this));
jButton6.setBounds(new Rectangle(274, 253, 81, 23));
jButton6.setText("=");
jButton6.addActionListener(new Applet1_jButton6_actionAdapter(this));
this.add(jButton1);
this.add(jButton2);
this.add(jButton3);
this.add(jButton5);
this.add(jButton4);
this.add(jButton6);
this.add(jTextField1);
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
public void jButton6_actionPerformed(ActionEvent e) {
Globbalvar.s2 = jTextField1.getText();
double q;
double q1=Double.parseDouble(Globbalvar.s1);
double q2=Double.parseDouble(Globbalvar.s2);
switch(Globbalvar.fuhao)
{case 1:q=q1+q2;
break;
case 2:q=q1+q2;
break;
case 3:q=q1+q2;
break;
case 4:q=q1+q2;
break;
}
}
public void jButton5_actionPerformed(ActionEvent e) {
String s=jTextField1.getText();
double d=Double.parseDouble(s);
double q=d*d*d;
jTextField1.setText(d+"的立方是:"+q);
}
public void jButton1_actionPerformed(ActionEvent e) {
Globbalvar.fuhao=1;
Globbalvar.s1=jTextField1.getText();
jTextField1.setText("");
}
}
class Applet1_jButton1_actionAdapter implements ActionListener {
private Applet1 adaptee;
Applet1_jButton1_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class Applet1_jButton6_actionAdapter implements ActionListener {
private Applet1 adaptee;
Applet1_jButton6_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton6_actionPerformed(e);
}
}
class Applet1_jButton5_actionAdapter implements ActionListener {
private Applet1 adaptee;
Applet1_jButton5_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton5_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -