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; } } 请参考

TNAHosting($5/月)4核/12GB/500GB/15TB/芝加哥机房

TNAHosting是一家成立于2012年的国外主机商,提供VPS主机及独立服务器租用等业务,其中VPS主机基于OpenVZ和KVM架构,数据中心在美国芝加哥机房。目前,商家在LET推出芝加哥机房大硬盘高配VPS套餐,再次刷新了价格底线,基于OpenVZ架构,12GB内存,500GB大硬盘,支持月付仅5美元起。下面列出这款VPS主机配置信息。CPU:4 cores内存:12GB硬盘:500GB月流...

Megalayer促销:美国圣何塞CN2线路VPS月付48元起/香港VPS月付59元起/香港E3独服月付499元起

Megalayer是新晋崛起的国外服务器商,成立于2019年,一直都处于稳定发展的状态,机房目前有美国机房,香港机房,菲律宾机房。其中圣何塞包括CN2或者国际线路,Megalayer商家提供了一些VPS特价套餐,譬如15M带宽CN2线路主机最低每月48元起,基于KVM架构,支持windows或者Linux操作系统。。Megalayer技术团队行业经验丰富,分别来自于蓝汛、IBM等知名企业。Mega...

RAKsmart推出7.59美元/月,云服务器产品Cloud Server,KVM架构1核1G内存40G硬盘1M带宽基础配置

近期RAKsmart上线云服务器Cloud Server产品,KVM架构1核1G内存40G硬盘1M带宽基础配置7.59美元/月!RAKsmart云服务器Cloud Server位于美国硅谷机房,下单可选DIY各项配置,VPC网络/经典网络,大陆优化/精品网线路,1-1000Mbps带宽,支持Linux或者Windows操作系统,提供Snap和Backup。RAKsmart机房是一家成立于2012年...

javaapplet为你推荐
c语言论坛求C语言学习的论坛,或者网站,谢谢youtube创始人世界第一大网站是什么?腾讯合作伙伴大会腾讯的合作伙伴都有腾讯合作伙伴大会从微信同程旅行买的机票怎么打印电子发票?医院排队系统医院排队叫号系统有哪些功能?动画分镜头脚本求份《仙剑奇侠传5》剧情动画分镜头脚本 越多越好flushesno-show rate是什么data什么意思c语言 data的作用卡发短信为什么我的手机卡不能发短信mpeg4格式什么是MPEG4视频格式
域名注册使用godaddy 外国服务器 kddi 512av idc是什么 世界测速 空间租赁 网购分享 789 中国域名 腾讯网盘 香港ip 发证机构 vim ddos攻击工具 电脑主机启动不了 天翼云主机 新浪轻博客 免费论坛空间 魔兽世界服务器维护 更多