This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes HELP2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "HELP2" Watch "HELP2" New topic
Author

HELP2

Jose Carrillo
Greenhorn

Joined: Nov 13, 2003
Posts: 17
hi I'm creating a program that draw a oval,line,and a rect. but I'm having this problem please can somebody help me
mouseDraw is not abstract and does not override abstract method mouseClicked(java.awt.event.MouseEvent) in java.awt.event.MouseListener
public class mouseDraw extends JApplet implements MouseListener, MouseMotionListener, ActionListener
^
mouseDraw.java:85: missing method body, or declare abstract
public void mouseReleased(MouseEvent e);
^
mouseDraw.java:89: missing method body, or declare abstract
public void mousePressed(MouseEvent e);

please here is my code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class mouseDraw extends JApplet implements MouseListener, MouseMotionListener, ActionListener
{
private int mouseX, mouseY, mouseY1, mouseX1;
private JButton[] buttons = new JButton[3];
private JPanel controlPanel, drawPanel;
private int shape;
public void init()
{
buttons[0] = new JButton("Line");
buttons[1] = new JButton("Rectangle");
buttons[2] = new JButton("Oval");
buttons[0].setBackground(Color.red);
controlPanel = new JPanel();
controlPanel.setLayout(new FlowLayout());
controlPanel.setBackground(Color.orange);
drawPanel = new JPanel();
drawPanel.setBackground(new Color(0xffffcc));
for (int i=0; i<3; i++)
controlPanel.add(buttons[i]);
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
pane.add(controlPanel, BorderLayout.NORTH);
pane.add(drawPanel, BorderLayout.CENTER);
for (int i=0; i<3; i++)
buttons[i].addActionListener(this);
addMouseListener(this);
addMouseMotionListener(this);
}
public void paint(Graphics g)
{
super.paint(g);
int x = Math.min(mouseX1, mouseX);
int y = Math.min(mouseY1, mouseY);
g.setColor(Color.blue);
int w = (int)Math.abs(mouseX1 - mouseX);
int h = (int)Math.abs(mouseY1 - mouseY);
switch (shape)
{
case 0: g.drawLine(mouseX1, mouseY1, mouseX, mouseY);
break;
case 1: g.drawRect(x, y, w, h);
break;
case 2: g.drawOval(x, y, w, h);
break;
}
}
public void mouseMoved(MouseEvent e)
{
mouseX = e.getX();
mouseY = e.getY();
showStatus("Mouse is moved to (" + mouseX + mouseY + ")");
}
public void mouseDragged(MouseEvent e)
{
mouseX = e.getX();
mouseY = e.getY();
showStatus("Mouse is moved to (" + mouseX + mouseY + ")");
repaint();
}
public void mouseEntered(MouseEvent e)
{
}
public void mouseExited(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e);
{
}
public void mousePressed(MouseEvent e);
{
mouseX1 = mouseX;
mouseY1 = mouseY;
}
public void actionPerformed(ActionEvent e)
{
for (int i=0; i<3; i++)
{
buttons[i].setBackground(Color.lightGray);
if (e.getSource() == buttons[i])
{
shape = i;
buttons[i].setBackground(Color.red);
}
}
}
}
please help me
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
jose,
Just remove the semi-colons at the end of the lines:
mouseReleased and mousePressed
Then create empty method:
mouseClicked
and your program will compile.
Regards,
Manfred.
 
 
subject: HELP2
 
Similar Threads
HELP
Please Help?
HELP 5
Help 3
Hello