📄 applet1.java~11~
字号:
package ifexample;import java.awt.*;import java.awt.event.*;import java.applet.*;import com.borland.jbcl.layout.*;public class Applet1 extends Applet { double result = 1; double y,x; int mul; boolean isStandalone = false; Button button1 = new Button(); XYLayout xYLayout1 = new XYLayout(); TextField textField1 = new TextField(); /**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 { button1.setFont(new java.awt.Font("Dialog", 0, 20)); button1.setLabel("确定"); button1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { button1_actionPerformed(e); } }); this.setLayout(xYLayout1); textField1.setFont(new java.awt.Font("Dialog", 0, 20)); this.add(textField1, new XYConstraints(126, 51, 83, 35)); this.add(button1, new XYConstraints(127, 96, 80, -1)); } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } /**Get parameter info*/ public String[][] getParameterInfo() { return null; } void button1_actionPerformed(ActionEvent e) { String str1 = textField1.getText() ; x = Double.parseDouble(str1); result=1; for (int i=1;i<=10;i++){ mul = 1; y = 1; for (int j=1;j<=i;j++){ mul = mul*j; y = y*x; } result+=y/mul; } repaint(); } public void paint(Graphics g){ g.drawString("结果是:"+String.valueOf(result),100,200); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -