File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes drawing in graphics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "drawing in graphics" Watch "drawing in graphics" New topic
Author

drawing in graphics

Shae Oommen
Greenhorn

Joined: Apr 12, 2006
Posts: 13
I am trying to draw a number of circles and a line. The circles are drawn by clicking the mouse button whereever it needs to be placed. Once the circles are drawn, I can right click the mouse to disable circle drawing and enable line drawing. But the circles disappear. When i draw the circles, it comes without any problem. Same with line. But both dont appear on the screen together.

public void this_mouseClicked(MouseEvent e) {//opened
if(vector_drawing_enabled) {//line drawing
if(e.getButton() == MouseEvent.BUTTON1) {
if(!drawing_active) {
drawing_active = true;
repaint();
}//closed
else {
last_point.setLocation(current_point);
vector_list.add(new Point2d(last_point));
fireEvent();
}//closed
}//closed
else if(e.getButton() == MouseEvent.BUTTON2 || e.getButton() == MouseEvent.BUTTON3) {
drawing_active = false;
fireEvent();
}//closed
}//vector drawing closed
if(obstacle_drawing_enabled)//circle drawing
{
if(e.getButton() == MouseEvent.BUTTON1) {
last_point.setLocation(current_point);
obstacle_points.add(new Point2d(last_point));
fireEvent();
}//closed if
if(e.getButton() == MouseEvent.BUTTON2 || e.getButton() == MouseEvent.BUTTON3) {
obstacle_drawing_enabled =false;
vector_drawing_enabled = true;

//fireEvent();
}//else if closed

}//obstacle drawing closed

}//mouseclicked closed


Please help
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Well, I would imagine the problem is in your paint()/paintComponent() method, not here. The paint method is probably just not drawing circles when you're in line-entering mode.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: drawing in graphics