/** GrafPack.java - Version 1.0 - created - 2003 */
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.geom.*;
abstractclass Shape
{
/** This is the base class for Shapes in the application. It must be subclassed */
Shape() // constructor
{
}
abstractvoid draw(Graphics g);
/** This method will draw the shape using the supplied Graphics object */
}
abstractclass Shape
{
/** This is the base class for Shapes in the application. It must be subclassed */
Shape() // constructor
{
}
abstractvoid draw(Graphics g);
/** This method will draw the shape using the supplied Graphics object */
}
publicclass GrafPack extends JFrame implements ActionListener, MouseListener
{
JMenuBar mainMenu;
JMenu fileMenu;
JMenu createMenu;
JMenu transformMenu;
JMenu colourMenu;
JMenuItem exit;
JMenuItem createSquare;
JMenuItem createCircle;
JMenuItem createRectangle;
JMenuItem createTriangle;
JMenuItem move;
JMenuItem fillRed;
JMenuItem fillGreen;
JMenuItem fillBlue;
Shape aShape = null;
Point nextPoint = null;
String command = "";
public GrafPack()
{
super("2D Drawing Package"); // call base class constructor
Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); // get screen dimensions
setBounds(0,0,size.width,size.height); // use all screen
mainMenu = new JMenuBar(); // main menu bar
fileMenu = new JMenu("File"); // main menu options
createMenu = new JMenu("Create");
transformMenu = new JMenu("Transform");
colourMenu = new JMenu("Colour");
exit = new JMenuItem("Exit"); // menu items
createSquare = new JMenuItem("Create Square");
createCircle = new JMenuItem("Create Circle");
move = new JMenuItem("Move");
fillRed = new JMenuItem("Fill Red");
fillGreen = new JMenuItem("Fill Green");
fillBlue = new JMenuItem("Fill Blue");
// Build Menus
setJMenuBar(mainMenu);
fileMenu.add(exit);
mainMenu.add(fileMenu);
mainMenu.add(createMenu);
mainMenu.add(transformMenu);
mainMenu.add(colourMenu);
createMenu.add(createSquare);
createMenu.add(createCircle);
createMenu.add(createRectangle);
createMenu.add(createTriangle);
transformMenu.add(move);
colourMenu.add(fillRed);
colourMenu.add(fillGreen);
colourMenu.add(fillBlue);
// activate action listeners
exit.addActionListener(this);
createSquare.addActionListener(this);
createCircle.addActionListener(this);
move.addActionListener(this);
// and mouse listener
addMouseListener(this);
// see the screen
setVisible(true);
// process comamnds. The command will be set by the action performed in response to menu selections
while (!command.equals("Exit"))
{
processCommand(); // act upon selected command
}
// On leaving loop, closedown
System.exit(0);
}
publicvoid mouseClicked(MouseEvent eve)
{
nextPoint = eve.getPoint(); // collect point
command =" "; // reset command that was last called.
}
;
publicvoid mouseEntered(MouseEvent e)
{
}
;
publicvoid mouseExited(MouseEvent e)
{
}
;
publicvoid mousePressed(MouseEvent e)
{
}
;
publicvoid mouseReleased(MouseEvent e)
{
}
;
publicvoid actionPerformed(ActionEvent e)
{
aShape=null; // cancel any incomplete shapes
nextPoint=null; // and any waiting points
command = e.getActionCommand(); // collect String used to define menu item's text
}
publicvoid processCommand()
{
if (command.equals("Create Square"))
{
aShape = new Square(getPoint(),getPoint()); // create the square by 2 mouse clicks
repaint(); // redraw screen
}
}
public Point getPoint()
{
Point aPoint = null; // Point to be returned
while (nextPoint==null); // wait for mouse click to change nextPoint
{
aPoint = nextPoint; // store the Point found
nextPoint=null; // reset nextPoint
return aPoint;
}
}
publicvoid paint(Graphics g)
{
// to redraw screen
super.paint(g); // repaint parent
if (aShape != null)
aShape.draw(g); // draw the shape if it exists
}
}
the problem is it returns this error. any clues what i have to do. any help much appreciated. cheers luke
shapeSquare should be declared abstract shapeCircle should be decalred abstract