网页java代码_怎么在网页中加入java代码

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

import java.awt.*;

import java.awt.event.*;

import java.lang.*;

import javax.swing.*;

public class Counter extends JFrame{

GridLayout gl1,gl2,gl3;

Panel p0,p1,p2,p3;

JTextField tf1;

TextField tf2;

Button b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26;

StringBuffer str;

double x,y;

int z;

static double m;

public Counter(){

super("计算器");

gl1=new GridLayout(1,4,5,5);

gl2=new GridLayout(4,1,5,5);

gl3=new GridLayout(4,5,5,5);

tf1=new JTextField(27);

tf1.setHorizontalAlignment(JTextField.RIGHT);

tf1.setEnabled(true);

tf1.setText("0");

tf2=new TextField(10);

tf2.setEditable(false);

b0=new Button("Backspace");

b0.setForeground(Color.blue);

b0.addActionListener(new Bt());

b1=new Button("CE");

b1.setForeground(Color.blue);

b1.addActionListener(new Bt());

b2=new Button("C");

b2.setForeground(Color.blue);

b2.addActionListener(new Bt());

b3=new Button("MC");

b3.setForeground(Color.black);

b3.addActionListener(new Bt());

b4=new Button("MR");

b4.setForeground(Color.black);

b4.addActionListener(new Bt());

b5=new Button("MB");

b5.setForeground(Color.black);

b5.addActionListener(new Bt());

b6=new Button("M+");

b6.setForeground(Color.black);

b6.addActionListener(new Bt());

b7=new Button("7");

b7.setForeground(Color.black);

b7.addActionListener(new Bt());

b8=new Button("8");

b8.setForeground(Color.black);

b8.addActionListener(new Bt());

b9=new Button("9");

b9.setForeground(Color.black);

b9.addActionListener(new Bt());

b10=new Button("/");

b10.setForeground(Color.black);

b10.addActionListener(new Bt());

b11=new Button("Sqrt");

b11.setForeground(Color.black);

b11.addActionListener(new Bt());

b12=new Button("4");

b12.setForeground(Color.black);

b12.addActionListener(new Bt());

b13=new Button("5");

b13.setForeground(Color.black);

b13.addActionListener(new Bt());

b14=new Button("6");

b14.setForeground(Color.black);

b14.addActionListener(new Bt());

b15=new Button("*");

b15.setForeground(Color.black);

b15.addActionListener(new Bt());

b16=new Button("%");

b16.setForeground(Color.black);

b16.addActionListener(new Bt());

b17=new Button("1");

b17.setForeground(Color.black);

b17.addActionListener(new Bt());

b18=new Button("2");

b18.setForeground(Color.black);

b18.addActionListener(new Bt());

b19=new Button("3");

b19.setForeground(Color.black);

b19.addActionListener(new Bt());

b20=new Button("-");

b20.setForeground(Color.black);

b20.addActionListener(new Bt());

b21=new Button("1/X");

b21.setForeground(Color.black);

b21.addActionListener(new Bt());

b22=new Button("0");

b22.setForeground(Color.black);

b22.addActionListener(new Bt());

b23=new Button("+/-");

b23.setForeground(Color.black);

b23.addActionListener(new Bt());

b24=new Button(".");

b24.setForeground(Color.black);

b24.addActionListener(new Bt());

b25=new Button("+");

b25.setForeground(Color.black);

b25.addActionListener(new Bt());

b26=new Button("=");

b26.setForeground(Color.black);

b26.addActionListener(new Bt());

p0=new Panel();

p1=new Panel();

p2=new Panel();

p3=new Panel();

str=new StringBuffer();

p0.add(tf1);

p0.setBounds(10,25,300,45);

p1.setLayout(gl1);

p1.add(tf2);

p1.add(b0);

p1.add(b1);

p1.add(b2);

p1.setBounds(10,65,300,30);

p2.setLayout(gl2);

p2.add(b3);

p2.add(b4);

p2.add(b5);

p2.add(b6);

p2.setBounds(10,110,40,150);

p3.setLayout(gl3);

p3.add(b7);

p3.add(b8);

p3.add(b9);

p3.add(b10);

p3.add(b11);

p3.add(b12);

p3.add(b13);

p3.add(b14);

p3.add(b15);

p3.add(b16);

p3.add(b17);

p3.add(b18);

p3.add(b19);

p3.add(b20);

p3.add(b21);

p3.add(b22);

p3.add(b23);

p3.add(b24);

p3.add(b25);

p3.add(b26);

p3.setBounds(60,110,250,150);

setLayout(null);

add(p0);

add(p1);

add(p2);

add(p3);

setResizable(false);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值