• Post Reply Bookmark Topic Watch Topic
  • New Topic

mouse event  RSS feed

 
Serban Alex
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to create a simple window with a button that when it is pressed to show a new windows with a ok confirmation in it. here is what i have don until now:


so... I don't know how to trigger the event to open the window.
From the stage where I'm in what is the simplest solution.

Thank you.... and sorry for newbienes.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you want to handle a JButton action (click) -- not a mouse event. To do this, you need to implement an ActionListener, and "register" it with the JButton (so that when the button is clicked, it sends a message to the listener, which is coded to do something in response to the click).

See Tutorial - How to Use Buttons....
 
Serban Alex
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've tried something else:



I want to display in lb the text of the radio button but the event doesn't seem to be trigered. What is the problem... and how can I fix my program?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Serban Alex:
...I want to display in lb the text of the radio button but the event doesn't seem to be trigered. What is the problem... and how can I fix my program?

You want your ActionListener to listen for messages from the buttons. So instead of adding an ActionListener to the TextField (lb), add the listener to each of the buttons (a, b, and c)...

a.addActionListener(new actiune2(lb,a));
b.addActionListener(new actiune2(lb,b));
c.addActionListener(new actiune2(lb,c));
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this topic to the Swing forum. Please continue this discussion there.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!