Possible Duplicate:
What does the "Multiple markers" mean?
package test2;
import java.awt.*;
import java.awt.event.*;
public class MyDrawing3Demo extends Frame{
Panel p1,p2;
Button red,green,blue,large,small,clear,allClear;
MyCanvas2 can;
public MyDrawing3Demo(){
super("::MyDrawing3Demo::");
p1 = new Panel();
p1.setBackground(Color.blue);
add(p1,"North");
p2 = new Panel(){
public Insets getInsets(){
return new Insets(40,20,20,20);
}
};
p2.setBackground(Color.darkGray);
add(p2,"Center");
p1.add(red = new Button("Red"));
p1.add(green = new Button("Green"));
p1.add(blue = new Button("Blue"));
p1.add(large = new Button("Large"));
p1.add(small = new Button("Small"));
p1.add(clear = new Button("Clear"));
p1.add(allClear = new Button("All Clear"));
MyHandler2 my = new MyHandler2(); // ERROR! Multiple Markers at this line
red.addActionListener(my);
green.addActionListener(my);
blue.addActionListener(my);
large.addActionListener(my);
small.addActionListener(my);
clear.addActionListener(my);
allClear.addActionListener(my);
can = new MyCanvas2();
can.setSize(300,300);
can.setBackground(Color.white);
p2.add(can);
can.addMouseMotionListener(my);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
class MyHandler2 extends MouseMotionAdapter implements ActionListener
{
public void mouseDragged(MouseEvent e){
can.x = e.getX();
can.y = e.getY();
can.repaint();
}
public void actionPerformed(ActionEvent e){
Object o = e.getSource();
if(o == red){
can.cr = Color.red;
}else if(o == blue){
can.cr = Color.blue;
}else if(o == green){
can.cr = Color.green;
}else if(o == large){
if(can.w <20){
can.w++;
can.h++;
}
}else if(o == small){
if(can.w >2){
can.w--;
can.h--;
}
}else if(o == clear){
can.cr = can.getBackground();
}else if(o == allClear){
can.flag = 1;
can.repaint();
}
}
}
}
public static void main(String[] args){
MyDrawing3Demo d = new MyDrawing3Demo();
d.setSize(500,500);
d.setVisible(true);
}
}
class MyCanvas2 extends Canvas{
/**
*
*/
private static final long serialVersionUID = -2856701740289022957L;
int x=-13,y=-13,w=7,h=7;
Color cr = Color.black;
int flag = 0;
public void update(Graphics g){
paint(g);
}
public void paint(Graphics g){
if(flag == 0){
g.setColor(cr);
g.fillOval(x,y,w,h);
}else if (flag == 1){
g.clearRect(0,0,300,300);
flag = 0;
}
}
}
It means there are two errors on this line. It’s because the type you used is unknown to the compiler. The declaration of your class
MyHandler2is done inside the constructor, you should move it outside. That is, move the braket before main to right before the declaration of the class.