ColorPanel类在哪个包中呀?下面的程序怎么运行起来老是说ColorPanel错误呀?
大家帮忙看看,谢谢!!
代码:package exm7_22;import java.awt.* ;
import java.awt.event.* ;
import java.awt.Frame;public class TestDialog extends Frame {
Button change = new Button("Change Color") ;
ColorPanel m ;
Button b = new Button("确定") ;
Dialog my ;
public TestDialog()
{
super("Parent");
setLayout(new FlowLayout());
m = new ColorPanel();
add(change);
change.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
my = new Dialog(TestDialog.this , "Select color " , true) ;
my.setLayout(new BorderLayout());
my.add("Center", m);
my.add("South", b);
my.setSize(300, 200);
my.setVisible(true);
}
});
setSize(300,300) ;
setVisible(true) ;
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
my.dispose();
setBackground(m.NegativeArraySizeException.getBackground()) ;
}
}) ;
}
public static void main(String a[])
{
new TestDialog() ; }
}错误提示:
"TestDialog.java": cannot find symbol; symbol : class ColorPanel, location: class exm7_22.TestDialog at line 22, column 4
"TestDialog.java": cannot find symbol; symbol : class ColorPanel, location: class exm7_22.TestDialog at line 29, column 16
大家帮忙看看,谢谢!!
代码:package exm7_22;import java.awt.* ;
import java.awt.event.* ;
import java.awt.Frame;public class TestDialog extends Frame {
Button change = new Button("Change Color") ;
ColorPanel m ;
Button b = new Button("确定") ;
Dialog my ;
public TestDialog()
{
super("Parent");
setLayout(new FlowLayout());
m = new ColorPanel();
add(change);
change.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
my = new Dialog(TestDialog.this , "Select color " , true) ;
my.setLayout(new BorderLayout());
my.add("Center", m);
my.add("South", b);
my.setSize(300, 200);
my.setVisible(true);
}
});
setSize(300,300) ;
setVisible(true) ;
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
my.dispose();
setBackground(m.NegativeArraySizeException.getBackground()) ;
}
}) ;
}
public static void main(String a[])
{
new TestDialog() ; }
}错误提示:
"TestDialog.java": cannot find symbol; symbol : class ColorPanel, location: class exm7_22.TestDialog at line 22, column 4
"TestDialog.java": cannot find symbol; symbol : class ColorPanel, location: class exm7_22.TestDialog at line 29, column 16
不过好像我还没有看到ColorPanel这个类呢。
我知道颜色的应该是JColorChooser
楼主试试