java简单计算器的程序~~高手帮忙修改

来源:百度知道 编辑:UC知道 时间:2024/05/14 12:29:57
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
class Window extends JFrame
{
public Window()
{
super("计算器");
setBounds(100,100,330,220);
addWindowListener
(
new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
setLayout(null);
}
}
class Jbutton extends JButton
{
public Jbutton(String str1,int x1,int y1)
{
super(str1);
setBounds(x1,y1,50,30);
}
}
class Jlabel extends JLabel
{
public Jlabel(String str2,int x2,int y2)
{
super(str2);
setBounds(x2,y2,50,20);
}
public Jlabel(int x2,int y2,int k,int g)
{
super();
setBounds(x2,y2,k,g);
setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"操作数&结果"));
}
}
class JtextField extends JTextFiel

好好看看事件是怎么回事吧。

修改如下:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
class Window extends JFrame
{
public Window()
{
super("计算器");
setBounds(100,100,330,220);
addWindowListener
(
new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
setLayout(null);
}
}
class Jbutton extends JButton
{
public Jbutton(String str1,int x1,int y1)
{
super(str1);
setBounds(x1,y1,50,30);
}
}
class Jlabel extends JLabel
{
public Jlabel(String str2,int x2,int y2)
{
super(str2);
setBounds(x2,y2,50,20);
}
public Jlabel(int x2,int y2,int k,int g)
{
super();
setBounds(x2,y2,k,g);
setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder()