⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datatrans.java

📁 方面
💻 JAVA
字号:
package datatrans;import java.awt.*;import java.awt.event.*;import java.applet.*;import com.borland.jbcl.layout.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: </p> * @author unascribed * @version 1.0 *//** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class datatrans extends Applet {  boolean isStandalone = false;  XYLayout xYLayout1 = new XYLayout();  Label label1 = new Label();  Button button1 = new Button();  TextField textField2 = new TextField();  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 datatrans() {  }  //Initialize the applet  public void init() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception {    label1.setText("计算sin()x=");    this.setLayout(xYLayout1);    button1.setLabel("开始计算");    button1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        button1_actionPerformed(e);      }    });    textField2.setEditable(false);    this.add(button1,  new XYConstraints(86, 54, 145, 33));    this.add(textField2,  new XYConstraints(90, 110, 188, 31));    this.add(label1, new XYConstraints(41, 21, -1, -1));    this.add(textField1,   new XYConstraints(139, 15, 144, 27));  }  //Get Applet information  public String getAppletInfo() {    return "Applet Information";  }  //Get parameter info  public String[][] getParameterInfo() {    return null;  }  void button1_actionPerformed(ActionEvent e) { String s;   //获取textField1中的内容,将其定义为字符类型     double x;  //将上面获得的字符转换为数字类型     double y;   //定义为计算结果s=textField1.getText();      x=Double.parseDouble(s);  y=Math.sin(x);textField2.setText("运行结果为:"+String.valueOf(y));  }}

⌨️ 快捷键说明

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