Link to home
Start Free TrialLog in
Avatar of Zolf
ZolfFlag for United Arab Emirates

asked on

java application which will respond to clicks on the image

i want to create a java application which will respond to clicks on the image.i want to know any tutorial or help i can get to get started with it.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Put the image in a JLabel and add a MouseListener to the label
label = new JLabel(new ImageIcon("x.jpg"));
label.addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent e) {
            // Respond
      }
});
yuou could use a JButton with an ActionListener.
Avatar of Zolf

ASKER


      thanks for your replies.let me explain in more details.for example i get
      an image of a stero system and if i clcik on the play button it should play
      ,if i click on the stop button it should stop playing....so on.
You need to add buttons maybe over the image? If so, implement your own JPanel and override the paintComponent method to display the image
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zolf

ASKER



shivspk those sites do not open which you mentioned.do they open for you???
:-)