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

源代码在线查看: develop.java~28~

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

相关代码

				package choiceupdate;								import java.awt.*;				import java.awt.event.*;				import java.applet.*;				import com.borland.jbcl.layout.*;								public class develop extends Applet {				  boolean isStandalone = false;				  String str1,str2,str3;				  XYLayout xYLayout1 = new XYLayout();				  Choice choice1 = new Choice();				  TextField text1 = new TextField();				  TextField text2 = new TextField();				  TextField text3 = new TextField();				  Label label1 = new Label();				  Label label2 = new Label();				  Label label3 = new Label();				  Label label4 = 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 develop() {				  }				  /**Initialize the applet*/				  public void init() {				    try {				      jbInit();				    }				    catch(Exception e) {				      e.printStackTrace();				    }				  }				  /**Component initialization*/				  private void jbInit() throws Exception {				    this.setLayout(xYLayout1);				    choice1.setFont(new java.awt.Font("Dialog", 0, 16));				    choice1.addItemListener(new java.awt.event.ItemListener() {				      public void itemStateChanged(ItemEvent e) {				        choice1_itemStateChanged(e);				      }				    });				    label1.setFont(new java.awt.Font("Dialog", 0, 16));				    label1.setText("图形");				    label2.setFont(new java.awt.Font("Dialog", 0, 16));				    label2.setText("高度(半径)");				    label3.setFont(new java.awt.Font("Dialog", 0, 16));				    label3.setText("长度");				    label4.setFont(new java.awt.Font("Dialog", 0, 16));				    label4.setText("角度");												    text1.setText("10");				    text1.addFocusListener(new java.awt.event.FocusAdapter() {				      public void focusLost(FocusEvent e) {				        text1_focusLost(e);				      }				    });				    text2.setText("10");				    text2.addFocusListener(new java.awt.event.FocusAdapter() {				      public void focusLost(FocusEvent e) {				        text2_focusLost(e);				      }				    });				    text3.setText("10");				    text3.addFocusListener(new java.awt.event.FocusAdapter() {				      public void focusLost(FocusEvent e) {				        text3_focusLost(e);				      }				    });								    this.add(choice1,  new XYConstraints(137, 12, 81, 21));				    choice1.addItem("圆形");				    choice1.addItem("方形");				    choice1.addItem("弧形");				    this.add(text1,   new XYConstraints(137, 40, 60, -1));				    this.add(text2,   new XYConstraints(137, 70, 60, -1));				    this.add(text3,     new XYConstraints(137, 100, 60, -1));				    this.add(label1,   new XYConstraints(76, 12, 54, -1));				    this.add(label2,        new XYConstraints(28, 40, 102, -1));				    this.add(label3,    new XYConstraints(76, 70, 54, -1));				    this.add(label4,    new XYConstraints(76, 100, 54, -1));				  }				  /**Get Applet information*/				  public String getAppletInfo() {				    return "Applet Information";				  }				  /**Get parameter info*/				  public String[][] getParameterInfo() {				    return null;				  }								  void choice1_itemStateChanged(ItemEvent e) {				        repaint();				  }				  public void paint(Graphics g){				      g.clearRect(100,150,200,150);				      g.setColor(Color.red);				      switch(choice1.getSelectedIndex() ){				         case 0:				               str1=text1.getText() ;				               str2=text2.getText() ;				             if (str1==null)				                str1="1";				             if (str2==null)				                str2="1";				             try{				                int h=Integer.parseInt(str1);				                int w=Integer.parseInt(str2);				                g.drawOval(100,150,w,h);				             }				             catch(Exception e) {				                e.printStackTrace();				             }				          case 1:				              str1=text1.getText() ;				              str2=text2.getText() ;				             if (str1==null)				                str1="1";				             if (str2==null)				                str2="1";				             try{				                int h=Integer.parseInt(str1);				                int w=Integer.parseInt(str2);				                g.drawRect(100,150,w,h);				             }				             catch(Exception e) {				                e.printStackTrace();				             }				          case 2:				               str1=text1.getText() ;				               str2=text2.getText() ;				               str3=text3.getText() ;				             if (str1==null)				                str1="1";				             if (str2==null)				                str2="1";				             if (str3==null)				                str3="1";				             try{				                int h=Integer.parseInt(str1);				                int w=Integer.parseInt(str2);				                int a=Integer.parseInt(str3);				                g.drawArc(100,150,w,h,0,a);				             }				             catch(Exception e) {				                e.printStackTrace();				             }				         }				    }								  void text1_focusLost(FocusEvent e) {				     repaint();				  }																  void text3_focusLost(FocusEvent e) {				     repaint();				  }								  void text2_focusLost(FocusEvent e) {				     repaint();				  }																}			

相关资源