源程序代码:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class CalculationTest{
public static void main(String [] argv)
{
EventQueue.invokeLater(new Runnable(){
public void run()
{
JFrame frame=new CalculationFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
}
}
class CalculationFrame extends JFrame{
public CalculationFrame()
{
setTitle("计算机 made by 蓝月追风");
CalculationPanel panel=new CalculationPanel();
add(panel);
this.setSize(300, 350);
}
}
class CalculationPanel extends JPanel
{
public CalculationPanel()
{
this.setLayout(new GridLayout(2,1));
JPanel buttonPanel=new ButtonPanel();
JPanel showPanel=new ShowPanel();
add(showPanel);
add(buttonPanel);
}
private class ShowPanel extends JPanel
{
ShowPanel()
{
panel=new JPanel();
down=new JTextArea(1,10);
up=new JTextArea(1,10);
panel.setLayout(new GridLayout(2,1));
panel.ateLineBorder(Color.BLACK, 1));
down.setEditable(false);
down.setFont(new Font("Serifs",Font.BOLD,25));
up.setEditable(false);
// lastShow.d);
// showArea.setBackground(Color.BLUE);
down.setEditable(false);
down.setText("0");
panel.setPreferredSize(new Dimension(210,75));
panel.add(up);
panel.add(down);
add(panel);
ateEmptyBorder(5, 3, 1, 3));
}
private JPanel panel;
}
private class ButtonPanel extends JPanel
{
public ButtonPanel()
{
有趣的java小程序 start=true;
equals=false;
total=true;
result=0;
button=new JButton[17];
ActionListener NA=new numberAction();
ActionListener CA=new commendAction();
GridBagLayout gridbag=new GridBagLayout();
setLayout(gridbag);
GridBagConstraints gbc;
int gridx,gridy,gridwidth,gridheight,anchor,fill,ipadx,ipady;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论