• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Mouse events

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic