JAVA基础题希望各位朋友帮个忙
package dome;
import javax.swing.*;
import java.awt.*;
import java.awt.Event;
public class Textpanel extends JPanel
{
public Textpanel()
{
JButton yellow=new JButton("yellow");
JButton blue=new JButton("blue");
JButton green=new JButton("green");
add(yellow);
add(blue);
add(green);
ColorAction yellowAction=new ColorAction(Color.yellow);
ColorAction blueAction=new ColorAction(Color.blue);
ColorAction greenAction=new ColorAction(Color.green);
yellow.addActionListener(yellowAction);
blue.addActionListener(blueAction);
green.addActionListener(greenAction);
}
private class ColorAction implements ActionListener
{
private Color temp;
public ColorAction(Color c)
{
temp=c;
}
public void actionPerformen(ActionEvent e)
{
setBackground(temp);
}
}
}
谁能告诉我 内部类的setBackground();是从哪里来的?
我实现ActionListener接口时候会报错这是为什么?