当前位置: 技术问答>java相关
小菜鸟的问题:用jdk的java可以解释执行出一个窗体么???我的例子:
来源: 互联网 发布时间:2015-10-30
本文导语: package ETextField; package test; import java.awt.*; import java.awt.event.*; import java.awt.Graphics; public class AwtCalc extends Frame implements ActionListener { private Button[] buttons = new Button[19]; private String[] buttonText = { "...
package ETextField;
package test;
import java.awt.*;
import java.awt.event.*;
import java.awt.Graphics;
public class AwtCalc extends Frame implements ActionListener
{
private Button[] buttons = new Button[19];
private String[] buttonText = { " 1 " , " 2 ", " 3 ", " + ", " - ",
"};
private ETextField result; // 结果显示框
private String input = ""; // 用户的输入
private Label label;
private Color forecolor, // 前景色
backcolor, // 背景色
fieldcolor; // 显示框颜色
private Font font,
buttonfont;
private int oper = 0, // 记录运算过程中的运算符
oldoper = 0,
newoper = 0;
private double answer,
num1 = 0.0,
num2 = 0.0,
num3 = 0.0;
private final int ADD=1, // 用于记录运算符的常量
SUB = 2,
MULT = 3,
DIVI = 4,
POW = 5,
SQRT = 6;
private boolean firstpress = true, //是否按下第一个按键
morenums = false, //是否多个数值被输入
equals = false, //等于是否已经被按下
clearscreen = false, //是否清屏
decnumber = false, //是否输入一个浮点数
doubleclick = false; //是否双击
public AwtCalc(){
super("计算器");
//初始化颜色
buttonfont = new Font( "Courier", Font.PLAIN, 12 );
setBackground( Color.lightGray );
result = new ETextField( 125, 18 );
font = new Font( "宋体", Font.ITALIC, 10 );
label = new Label( "结果" );
label.setFont( font );
result.setBackground( Color.white );
setLayout( new FlowLayout() );
//初始化按钮
Panel mainPanel=new Panel();
mainPanel.setLayout(new GridLayout(5,1));
for ( int i = 0; i
package test;
import java.awt.*;
import java.awt.event.*;
import java.awt.Graphics;
public class AwtCalc extends Frame implements ActionListener
{
private Button[] buttons = new Button[19];
private String[] buttonText = { " 1 " , " 2 ", " 3 ", " + ", " - ",
"};
private ETextField result; // 结果显示框
private String input = ""; // 用户的输入
private Label label;
private Color forecolor, // 前景色
backcolor, // 背景色
fieldcolor; // 显示框颜色
private Font font,
buttonfont;
private int oper = 0, // 记录运算过程中的运算符
oldoper = 0,
newoper = 0;
private double answer,
num1 = 0.0,
num2 = 0.0,
num3 = 0.0;
private final int ADD=1, // 用于记录运算符的常量
SUB = 2,
MULT = 3,
DIVI = 4,
POW = 5,
SQRT = 6;
private boolean firstpress = true, //是否按下第一个按键
morenums = false, //是否多个数值被输入
equals = false, //等于是否已经被按下
clearscreen = false, //是否清屏
decnumber = false, //是否输入一个浮点数
doubleclick = false; //是否双击
public AwtCalc(){
super("计算器");
//初始化颜色
buttonfont = new Font( "Courier", Font.PLAIN, 12 );
setBackground( Color.lightGray );
result = new ETextField( 125, 18 );
font = new Font( "宋体", Font.ITALIC, 10 );
label = new Label( "结果" );
label.setFont( font );
result.setBackground( Color.white );
setLayout( new FlowLayout() );
//初始化按钮
Panel mainPanel=new Panel();
mainPanel.setLayout(new GridLayout(5,1));
for ( int i = 0; i