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

源代码在线查看: math.java~8~

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

相关代码

				package untitled1;								import java.awt.*;				import java.awt.event.*;				import java.applet.*;				import com.borland.jbcl.layout.*;								public class math extends Applet {				  private double x1[],x2[];				  private double y1[],y2[];				  boolean isStandalone = false;				  XYLayout xYLayout1 = new XYLayout();				  Choice choice1 = new Choice();				  Label label1 = 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 math() {				  }				  /**Initialize the applet*/				  public void init() {				    try {				      jbInit();				    }				    catch(Exception e) {				      e.printStackTrace();				    }				    x1 = new double[360];				    y1 = new double[360];				    x2 = new double[400];				    y2 = new double[400];				    for(int i=0;i				       x1[i] = 2*Math.PI *i/360;				       y1[i] = Math.sin(x1[i]);				       x1[i] = x1[i]*20+50;				       y1[i] = y1[i]*50+100;				    }				    for(int i=0;i				       x2[i] = -2+0.01*i;				       y2[i] = Math.exp(x2[i]);				       x2[i] = x2[i]*20+150;				       y2[i] = y2[i]*45+20;				    }				  }				  public void paint(Graphics g){				    switch(choice1.getSelectedIndex()){				     case 0:				       for(int i=0;i				          g.drawLine((int)x1[i],(int)y1[i],(int)x1[i+1],(int)y1[i+1]);				       }				     case 1:				       for(int i=0;i				          g.drawLine((int)x2[i],(int)y2[i],(int)x2[i+1],(int)y2[i+1]);				       }				    }				  }				  /**Component initialization*/				  private void jbInit() throws Exception {				    this.setLayout(xYLayout1);				    label1.setFont(new java.awt.Font("Dialog", 0, 16));				    label1.setText("图形");				    choice1.setFont(new java.awt.Font("Dialog", 0, 16));				    choice1.addItemListener(new java.awt.event.ItemListener() {				      public void itemStateChanged(ItemEvent e) {				        choice1_itemStateChanged(e);				      }				    });				    this.add(choice1, new XYConstraints(131, 13, 79, 24));				    choice1.addItem("正弦");				    choice1.addItem("指数");				    this.add(label1,   new XYConstraints(68, 13, 49, 25));				  }				  /**Get Applet information*/				  public String getAppletInfo() {				    return "Applet Information";				  }				  /**Get parameter info*/				  public String[][] getParameterInfo() {				    return null;				  }								  void choice1_itemStateChanged(ItemEvent e) {				      repaint();				  }				}			

相关资源