86.
87. this.setLayout(new FlowLayout());
88. this.add(context);
89.
90. initWindow();
91.
92. this.setVisible(true);
93. }
94.
95. /**
96. * 初始化窗体
97. */
98. private void initWindow(){
99. context.setLayout(new BorderLayout(10,10)); 100.
101. // 显示面板
102. displayPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
103. displayPanel.add(result);
104. result.setHorizontalAlignment(JTextField.RIGHT);
105. result.setFocusable(false);
106. context.add(displayPanel,"North"); 107.
108. // 数字面板
109. numPanel.setLayout(new GridLayout(4,3,5,5));
110. for(int i=1;i<=9;i++){
111. numPanel.add(getNumberButton(i)); 112. }
113. numPanel.add(btnCE);
114. btnCE.addKeyListener(keyListener); 115. numPanel.add(getNumberButton(0)); 116.
117. btnCE.addActionListener(new ActionListener(){
118.
119. public void
actionPerformed(ActionEvent e) {
120. inputing = plus = minus = false;
121. result.setText("0");
122. result.setHorizontalAlignment(JTextField.RIGHT);