紧急求援!!!java初学者的小问题!!!!马上给分!! !
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ShapeTestFrame extends JFrame {
public ShapeTestFrame()
{
setTitle( "ShapeTest ");
setSize(WIDTH, HEIGHT);
Container contentPane = getContentPane();
final ShapePanel panel = new ShapePanel(); //此处 ShapePanel 无法解析为类型
contentPane.add(panel, BorderLayout.CENTER);
final JComboBox comboBox = new JComboBox();
comboBox.addItem(new LineMaker()); //此处 LineMaker无法解析为类型
comboBox.addItem(new RectangleMaker());//此处 RectangleMaker 无法解析为类型
comboBox.addItem(new RoundRectangleMaker());//此处 RoundRectangleMaker无法解析为类型
comboBox.addItem(new EllipseMaker());//此处 EllipseMaker 无法解析为类型
comboBox.addItem(new ArcMaker());//此处 ArcMaker 无法解析为类型
comboBox.addItem(new PolygonMaker());//此处 PolygonMaker 无法解析为类型
comboBox.addItem(new QuadCurveMaker());//此处 QuadCurveMaker 无法解析为类型
comboBox.addItem(new CubicCurveMaker());//此处 CubicCurveMaker 无法解析为类型
comboBox.addActionListener(new
ActionListener()
{
public void actionPerformed(ActionEvent event)
{
ShapeMaker shapeMaker =
(ShapeMaker)comboBox.getSelectedItem();//此处 ShapeMaker 无法解析为类型
panel.setShapeMaker(shapeMaker);
}
});
contentPane.add(comboBox, BorderLayout.NORTH);
}
private static final int WIDTH = 300;
private static final int HEIGHT = 300;
}
------解决方案--------------------ShapePanel ,LineMaker,RectangleMaker,EllipseMakerd等类都是用户自定义类,如果这是全部代码的话,肯定出问题。应该给出这些类的具体实现啊。