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

📄 wordchange.java~1~

📁 方面
💻 JAVA~1~
字号:
package wordchange;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 */public class wordchange extends Applet {  boolean isStandalone = false;  Label label1 = new Label();  TextField textField1 = new TextField();  Label label2 = new Label();  TextField textField2 = new TextField();  Label label3 = new Label();  TextField textField3 = new TextField();  Label label4 = new Label();  TextField textField4 = new TextField();  XYLayout xYLayout1 = new XYLayout();  Button button1 = new Button();  TextField textField5 = new TextField();  Label label5 = 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 wordchange() {  }  //Initialize the applet  public void init() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception {    label1.setText("height");    label2.setText("ColorR");    textField2.setText("                 ");    label3.setText("ColorG");    textField3.setText("               ");    label4.setText("ColorB");    this.setLayout(xYLayout1);    button1.setLabel("开始");    button1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        button1_actionPerformed(e);      }    });    textField5.setText("                            ");    label5.setText("请输入字符");    this.add(label1, new XYConstraints(16, 11, -1, -1));    this.add(textField3,    new XYConstraints(63, 36, 85, -1));    this.add(label3, new XYConstraints(13, 39, -1, -1));    this.add(textField5,  new XYConstraints(110, 83, 133, 28));    this.add(label5,  new XYConstraints(24, 85, 74, 26));    this.add(textField1,     new XYConstraints(63, 8, 88, -1));    this.add(button1, new XYConstraints(249, 85, 68, 25));    this.add(textField2,  new XYConstraints(235, 9, 82, -1));    this.add(label2, new XYConstraints(167, 9, -1, -1));    this.add(textField4,  new XYConstraints(234, 34, 85, -1));    this.add(label4, new XYConstraints(172, 34, -1, -1));  }  //Get Applet information  public String getAppletInfo() {    return "Applet Information";  }  //Get parameter info  public String[][] getParameterInfo() {    return null;  }int colorR,colorG,colorB;//组成颜色的参数变量Color thiscolor;//颜色值int height;//高度Font thisFont;//字体public void  paint(Graphics g){g.setColor(thiscolor);g.setFont(thisFont);g.drawString(textField5.getText(),50,3*height);}  void button1_actionPerformed(ActionEvent e) {String s1=textField1.getText();if(s1==null)textField1.setText("30");//默认字体高度为30try{s1=textField1.getText();height=Integer.parseInt(s1);if(height>=60){//最大高度不能超过60height=60;textField1.setText("60");}thisFont=new Font("TimesRoman",Font.ITALIC,height);} catch(Exception ee){ ee.printStackTrace(); } String s2=textField2.getText();if(s2==null)textField2.setText("0");try{s2=textField2.getText();colorR=Integer.parseInt(s2);if(colorR>255){//参数值不能超过255colorR=255;textField2.setText("255");}} catch(Exception ee){ ee.printStackTrace(); }  String s3=textField3.getText();if(s3==null)textField3.setText("0");try{s3=textField3.getText();colorG=Integer.parseInt(s3);if(colorG>255){//参数值不能超过255colorG=255;textField3.setText("255");} } catch(Exception ee){ ee.printStackTrace(); }String s4=textField4.getText();if(s4==null)textField4.setText("0");try{s4=textField4.getText();colorB=Integer.parseInt(s4);if(colorB>255){//参数值不能超过255colorB=255;textField2.setText("255");}} catch(Exception ee){ ee.printStackTrace(); }thiscolor=new Color(colorR,colorG,colorB);repaint();//重载paint()方法 }  }}

⌨️ 快捷键说明

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