javaapplet做一个java applet程序
javaapplet 时间:2021-06-29 阅读:(
)
如何编写一个java applet
import java.applet.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class jj extends Applet //implements ActionListener
{
JLabel l1;
JLabel l2;
JTextField t1;
JTextField t2;
JButton button; public void init()
{
resize(1000,70);
l1=new JLabel("请输入单词:");
t1=new JTextField(10);
l1=new JLabel("大写的单词为:");
t2=new JTextField(10);
button=new JButton("大写");
l1.setFont(new Font("宋体",Font.BOLD,30));
l1.setForeground(Color.green);
t1.setFont(new Font("宋体",Font.BOLD,30));
t1.setForeground(Color.black);
t2.setFont(new Font("宋体",Font.BOLD,30));
t2.setForeground(Color.blue);
button.setFont(new Font("宋体",Font.BOLD,30));
button.setForeground(Color.black);
l2.setFont(new Font("宋体",Font.BOLD,30));
l2.setForeground(Color.red);// btn.addActionListener(this); this.add(l1);
this.add(t1);
this.add(button);
this.add(l2);
this.add(t2);
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==button)
{
String str=t1.getText().toUpperCase();
t2.setText(str);
}
}
});
}}编写java applet 程序
随便写了个 功能实现了
public class Trapezoidal {
private double upWeight;
private double height;
private double downWeight;
public Trapezoidal(double upWeight,double height,double downWeight){
setHeight(height);
setDownWeight(downWeight);
setUpWeight(upWeight);
}
public double getUpWeight() {
return upWeight;
}
public void setUpWeight(double upWeight) {
this.upWeight = upWeight;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public double getDownWeight() {
return downWeight;
}
public void setDownWeight(double downWeight) {
this.downWeight = downWeight;
}
public String count(){
return Double.toString((getDownWeight()+getUpWeight())*getHeight()/2);
}
}
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
.sun.xml.internal.fastinfoset.algorithm.IEEE754FloatingPointEncodingAlgorithm;
public class TestApp extends JFrame{
private JFrame jf = new JFrame();
private JPanel jp = new JPanel();
private JLabel jl1,jl2,jl3;
private JButton jb1;
private JTextField jtf1,jtf2,jtf3,jtf4;
public TestApp(){
jl1 = new JLabel("上底");
jl2 = new JLabel("下底");
jl3 = new JLabel("高");
jtf1 = new JTextField();
jtf2 = new JTextField();
jtf3 = new JTextField();
jtf4 = new JTextField("结果");
jb1 = new JButton("计算");
jp.setLayout(new GridLayout(4, 2));
jp.add(jl1);
jp.add(jtf1);
jp.add(jl2);
jp.add(jtf2);
jp.add(jl3);
jp.add(jtf3);
jp.add(jb1);
jp.add(jtf4);
jf.add(jp);
jf.setVisible(true);
jf.setSize(400, 300);
jb1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
double str1 = Double.valueOf(jtf1.getText());
double str2 = Double.valueOf(jtf2.getText());
double str3 = Double.valueOf(jtf3.getText());
jtf4.setText(new Trapezoidal(str1, str3, str2).count());
System.out.println(new Trapezoidal(str1, str3, str2).count());
}
});
}
public static void main(String[] args) {
// TODO Auto-generated method stub
TestApp ta = new TestApp();
}
}做一个java applet程序
import java.awt.*;
import java.applet.*;
public class ComplexNumber {
double m_dRealPart;
double m_dImaginPart;
public ComplexNumber() {
this(0, 0);
}
public ComplexNumber(double r, double i) {
m_dRealPart = r;
m_dImaginPart = i;
}
public double getRealPart() {
return m_dRealPart;
}
public void setRealPart() {
this.m_dRealPart = m_dRealPart;
}
public double getImaginaryPart() {
return m_dImaginPart;
}
public void setImaginaryPart(double m_dImaginPart) {
this.m_dImaginPart = m_dImaginPart;
}
public plexAdd(double c) {
plexAdd(new ComplexNumber(c, 0));
}
public plexAdd(ComplexNumber c) {
m_dRealPart += c.getRealPart();
m_dImaginPart += c.getImaginaryPart();
return this;
}
public plexMinus(double c) {
plexMinus(new ComplexNumber(c, 0));
}
public plexMinus(ComplexNumber c) {
m_dRealPart -= c.getRealPart();
m_dImaginPart -= c.getImaginaryPart();
return this;
}
public plexMulti(double c) {
plexMulti(new ComplexNumber(c, 0));
}
public plexMulti(ComplexNumber c) {
double r = m_dRealPart * c.getRealPart() - m_dImaginPart * c.getImaginaryPart();
double i = m_dImaginPart * c.getRealPart() + m_dRealPart * c.getImaginaryPart();
m_dRealPart = r;
m_dImaginPart = i;
return this;
}
public String toString() {
String res = m_dRealPart + "";
if(m_dImaginPart != 0) {
res += "+" + m_dImaginPart + "i";
}
return res;
}
}
请参考
hypervmart怎么样?hypervmart是一家国外主机商,成立于2011年,提供虚拟主机、VPS等,vps基于Hyper-V 2012 R2,宣称不超售,支持linux和windows,有荷兰和英国2个数据中心,特色是1Gbps带宽、不限流量。现在配置提高,价格不变,性价比提高了很多。(数据中心不太清楚,按以前的记录,应该是欧洲),支持Paypal付款。点击进入:hypervmart官方网...
georgedatacenter这次其实是两个促销,一是促销一款特价洛杉矶E3-1220 V5独服,性价比其实最高;另外还促销三款特价vps,georgedatacenter是一家成立于2019年的美国VPS商家,主营美国洛杉矶、芝加哥、达拉斯、新泽西、西雅图机房的VPS、邮件服务器和托管独立服务器业务。georgedatacenter的VPS采用KVM和VMware虚拟化,可以选择windows...
GigsGigsCloud是一家成立于2015年老牌国外主机商,提供VPS主机和独立服务器租用,数据中心包括美国洛杉矶、中国香港、新加坡、马来西亚和日本等。商家VPS主机基于KVM架构,绝大部分系列产品中国访问速度不错,比如洛杉矶机房有CN2 GIA、AS9929及高防线路等。目前Los Angeles - SimpleCloud with Premium China DDOS Protectio...
javaapplet为你推荐
财务系统软件现在企业里一般用什么财务软件的啊ae序列号ae序列号外国最火开放的直播app手机上看国外电视直播软件哪个好scriptmanagerajax ToolkitScriptManager与ScriptManager的区别flash实例FLASH中实例是个什么概念,真心期待着!!!期待好心人,感恩!希望大家多讨论举报非法网站如何举报非法网站?音乐代码网页中怎么写自动播放mp3音乐的代码java程序员招聘女java程序员好找工作嘛网络安全密钥一般路由器是网络安全密钥是多少yui3yui 3 月9日 出的专辑的情报
fc2最新域名 怎么注册域名 济南域名注册 中文域名查询 免费域名空间申请 免费vps n点虚拟主机管理系统 日本软银 2017年万圣节 发包服务器 双11秒杀 域名接入 卡巴斯基是免费的吗 lick 免费的域名 广州服务器托管 美国asp空间 godaddy中文 防盗链 wannacry勒索病毒 更多