Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Mouse events  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was trying to store circles in a vector when the mouse is clicked. However, I did not understand how to use the MouseEvent method to detect that this was happening. Can anyone help me?
 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Move .addMouseListener(new CircleListener()) into the constructor

public CircleDrawer3 ()
{
Container content = getContentPane();
// Set size, location, color and close behavior
setSize(450,350);
setLocation(300,300);

drawingPanel panel1 = new drawingPanel();
panel1.addMouseListener(new CircleListener());

content.setBackground(Color.WHITE);
content.setLayout(new BorderLayout()); // specifying layout
content.add(panel1, BorderLayout.CENTER);

setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
 
No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!