| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 419 人关注过本帖
标题:又通不过了
取消只看楼主 加入收藏
cnlg11349745
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2007-1-21
收藏
 问题点数:0 回复次数:1 
又通不过了

//使用CustomButton类的AveragingApplet小程序

import java.awt.*;
import java.applet.*;
import java.awt.event.*;

//<applet code=AverageApplet.class width=400 height=300></applet>

public class AverageApplet extends Applet implements ActionListener
{
public CustomAverage average;
public TextField input1,input2,display;
public Label labelTitle,label1input,label2input,label3display;

public Color newColor;
public Font newFont;
public CustomButton b1;
public int num1,num2;

public void init()
{
Panel p1;

newColor=new Color(125,0,255);
newFont=new Font("Helvetica",Font.BOLD+Font.ITALIC,18);
b1=new CustomButton("Push for Average",newColor,Color.yellow,newFont);

average=new CustomAverage();
input1=new TextField(12);
input2=new TextField(12);
display=new TextField(12);
input1.setText("0");
input2.setText("0");
display.setText("");
display.setEditable(false);
labelTitle=new Label("Average Calculator");
label1input=new Label("First Number");
label2input=new Label("Second Number");
label3display=new Label("Computed Average");

p1=new Panel(new GridLayout(8,1,10,10));
b1.addActionListener(this);
p1.add(labelTitle);p1.add(label1input);p1.add(input1);
p1.add(label2input);p1.add(input2);
p1.add(b1);p1.add(label3display);p1.add(display);add(p1);
}

public void actionPerformed(ActionEvent e)
{
display.setText(""+average.getAverage(Integer.parseInt(input1.getText()),
Integer.parseInt(input2.getText())));
}
/*
public void actionPerformed(ActionEvent e)
{
int num1,num2;
double avg;

num1=Integer.parseInt(input1.getText());
num2=Integer.parseInt(input2.getText());
avg=average.getAverage(num1,num2);
display.setText(""+avg);
}
*/

}

搜索更多相关主题的帖子: average display public import 
2007-01-22 13:12
cnlg11349745
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2007-1-21
收藏
得分:0 

知道了,谢谢!

2007-01-22 14:06
快速回复:又通不过了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015685 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved