This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

drawing in graphics

 
Shae Oommen
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic