jbuilder 100例 java源码学习,非常不错,有需要朋友下来

源代码在线查看: qchange.java~25~

软件大小: 6566 K
上传用户: xiaoexiao
关键词: jbuilder java 100 源码
下载地址: 免注册下载 普通下载 VIP

相关代码

				package untitled2;								import java.awt.*;				import java.awt.event.*;				import java.applet.*;				import javax.swing.*;				import com.borland.jbcl.layout.*;								public class qchange extends Applet {				  double c[] = {1016.04,0.4536,0.0567};				  double d[] = {1000,1,0.001};				  double mid;				  double start;				  double end;				  int n = 0;				  int m = 0;				  boolean isStandalone = false;				  JRadioButton jRadioButton1 = new JRadioButton();				  JRadioButton jRadioButton2 = new JRadioButton();				  JRadioButton jRadioButton3 = new JRadioButton();				  JRadioButton jRadioButton4 = new JRadioButton();				  JRadioButton jRadioButton5 = new JRadioButton();				  JRadioButton jRadioButton6 = new JRadioButton();				  ButtonGroup buttonGroup1 = new ButtonGroup();				  ButtonGroup buttonGroup2 = new ButtonGroup();				  JTextField text1 = new JTextField();				  JTextField text2 = new JTextField();				  JButton jButton1 = new JButton();				  JButton jButton2 = new JButton();				  XYLayout xYLayout1 = new XYLayout();				  Label label1 = new Label();				  Label label2 = new Label();				  /**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 qchange() {				  }				  /**Initialize the applet*/				  public void init() {				    try {				      jbInit();				    }				    catch(Exception e) {				      e.printStackTrace();				    }				  }				  /**Component initialization*/				  private void jbInit() throws Exception {				    jRadioButton1.setFont(new java.awt.Font("Dialog", 0, 16));				    jRadioButton1.setText("英吨");				    jRadioButton1.addItemListener(new java.awt.event.ItemListener() {				      public void itemStateChanged(ItemEvent e) {				        jRadioButton1_itemStateChanged(e);				      }				    });				    this.setLayout(xYLayout1);				    jRadioButton2.setFont(new java.awt.Font("Dialog", 0, 16));				    jRadioButton2.setText("磅");				    jRadioButton2.addItemListener(new java.awt.event.ItemListener() {				      public void itemStateChanged(ItemEvent e) {				        jRadioButton1_itemStateChanged(e);				      }				    });				    jRadioButton2.addHierarchyBoundsListener(new java.awt.event.HierarchyBoundsAdapter() {								    });				    jRadioButton3.setFont(new java.awt.Font("Dialog", 0, 16));				    jRadioButton3.setText("盎司");				    jRadioButton3.addItemListener(new java.awt.event.ItemListener() {				      public void itemStateChanged(ItemEvent e) {				        jRadioButton1_itemStateChanged(e);				      }				    });				    jRadioButton4.setFont(new java.awt.Font("Dialog", 0, 16));				    jRadioButton4.setText("吨");				    jRadioButton4.addItemListener(new java.awt.event.ItemListener() {				      public void itemStateChanged(ItemEvent e) {				        jRadioButton2_itemStateChanged(e);				      }				    });				    jRadioButton5.setFont(new java.awt.Font("Dialog", 0, 16));				    jRadioButton5.setText("千克");				    jRadioButton5.addItemListener(new java.awt.event.ItemListener() {				      public void itemStateChanged(ItemEvent e) {				        jRadioButton2_itemStateChanged(e);				      }				    });				    jRadioButton6.setFont(new java.awt.Font("Dialog", 0, 16));				    jRadioButton6.setText("克");				    jButton1.setText("-->");				    jButton1.addActionListener(new java.awt.event.ActionListener() {				      public void actionPerformed(ActionEvent e) {				        jButton1_actionPerformed(e);				      }				    });				    jButton2.setText("-->");				    jButton2.addActionListener(new java.awt.event.ActionListener() {				      public void actionPerformed(ActionEvent e) {				        jButton2_actionPerformed(e);				      }				    });				    text1.setText("0");				    text2.setText("0");				    label1.setText("英");				    label2.setText("公");				    this.add(jRadioButton1,  new XYConstraints(40, 24, -1, -1));				    this.add(jRadioButton2,  new XYConstraints(40, 56, -1, -1));				    this.add(jRadioButton3,  new XYConstraints(40, 88, -1, -1));				    this.add(jRadioButton5,  new XYConstraints(214, 56, -1, -1));				    this.add(jRadioButton4,  new XYConstraints(214, 24, -1, -1));				    this.add(jRadioButton6,  new XYConstraints(214, 88, -1, -1));				    buttonGroup1.add(jRadioButton1);				    buttonGroup1.add(jRadioButton2);				    buttonGroup1.add(jRadioButton3);				    buttonGroup2.add(jRadioButton4);				    buttonGroup2.add(jRadioButton5);				    buttonGroup2.add(jRadioButton6);				    this.add(text1,   new XYConstraints(40, 126, 176, 24));				    this.add(jButton1, new XYConstraints(219, 127, 58, 21));				    this.add(text2,  new XYConstraints(39, 165, 178, 25));				    this.add(jButton2, new XYConstraints(220, 167, 58, 21));				    this.add(label1,  new XYConstraints(8, 124, 27, 23));				    this.add(label2,  new XYConstraints(7, 165, 28, 25));				  }				  /**Get Applet information*/				  public String getAppletInfo() {				    return "Applet Information";				  }				  /**Get parameter info*/				  public String[][] getParameterInfo() {				    return null;				  }								  void jRadioButton1_itemStateChanged(ItemEvent e) {				      if (jRadioButton1.isSelected())				         n = 1;				      if (jRadioButton2.isSelected())				         n = 2;				      if (jRadioButton3.isSelected())				         n = 3;				  }								  void jRadioButton2_itemStateChanged(ItemEvent e) {				      if (jRadioButton4.isSelected())				         m = 1;				      if (jRadioButton5.isSelected())				         m = 2;				      if (jRadioButton6.isSelected())				         m = 3;				  }								  void jButton1_actionPerformed(ActionEvent e) {				      String str = text1.getText();				      if (str!=null){				        try{				           start = Double.parseDouble(str);				           switch (n){				               case 1:				                  mid = start * c[0];				                  break;				               case 2:				                  mid = start * c[1];				                  break;				               case 3:				                  mid = start * c[2];				                  break;				           }				           switch (m){				                  case 1:				                  end = mid / d[0];				                  break;				               case 2:				                  end = mid / d[1];				                  break;				               case 3:				                  end = mid / d[2];				                  break;				            }				            text2.setText(String.valueOf(end));				            }				            catch(Exception ex){}				     }				  }								void jButton2_actionPerformed(ActionEvent e) {				      String str = text2.getText();				      if (str!=null){				        try{				           start = Double.parseDouble(str);				           switch (m){				               case 1:				                  mid = start * d[0];				                  break;				               case 2:				                  mid = start * d[1];				                  break;				               case 3:				                  mid = start * d[2];				                  break;				           }				           switch (n){				                  case 1:				                  end = mid / c[0];				                  break;				               case 2:				                  end = mid / c[1];				                  break;				               case 3:				                  end = mid / c[2];				                  break;				            }				            text1.setText(String.valueOf(end));				            }				            catch(Exception ex){}				     }				  }								}			

相关资源