package icc.imr.soukeiki;import java.awt.*;
import java.awt.event.*;public class TFMath {
public static void main(String[] args) {
TFFrame h= new TFFrame();
h.launchFrame();
}
}class TFFrame extends Frame {
TextField num1, num2, num3; Button btnEqual, b1, b2, b3; public TFFrame() {
super("javaGUI");
} public void launchFrame() {
num1 = new TextField(10);
num2 = new TextField(10);
num3 = new TextField(15);
Label lblPlus = new Label("+");
btnEqual = new Button("計算=");
b1 = new Button("exit");
b2 = new Button("Yellow");
b3 = new Button("Green");
btnEqual.addActionListener(new MyMonitor());
b1.addActionListener(new MyMonitor());
b2.addActionListener(new MyMonitor());
b3.addActionListener(new MyMonitor());
setLayout(new FlowLayout());
add(num1);
add(lblPlus);
add(num2);
add(btnEqual);
add(num3);
add(b2);
add(b3);
add(b1);
pack();
setResizable(false);
setLocation(100, 100);
setBackground(new Color(204, 204, 255));
setVisible(true);
                addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
setVisible(false);
dispose();
System.exit(0);
}
});
} private class MyMonitor implements ActionListener {
public void actionPerformed(ActionEvent e) {
Button bn = (Button) e.getSource();
if (bn == btnEqual) {
int n1 = Integer.parseInt(num1.getText());
int n2 = Integer.parseInt(num2.getText());
num3.setText("" + (n1 + n2));
}  else if (bn == b1){
setVisible(false);
    dispose();
    System.exit(0);}
   else if (bn == b2)
setBackground(Color.yellow);
   else
setBackground(Color.green); }
}}
在这个程序中我不太明白内部类MyMonitor中的dispose();setBackground(Color.yellow);setBackground(Color.green);
方法是如何调用的,如果是产生的对象的话,为什么在前面加THIS就会报错呢。谢谢大家了。