Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Actionevent  RSS feed

 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i identify an event occured when mouse clicked, is there any ActionEvent listener for this....
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clicked where? Often components have particular event listeners that are triggered in response to a mouse click, e.g. ActionListener for buttons or ItemListeners for checkboxes. If there's no particular component action you could use a MouseListener for the underlying panel.
 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when mouse clicked on button in a browser.
 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on any button in a browser, i need label(name) of the button , under browser i added mouselistener, but i couldnot find any solution
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you're asking about an applet? That's the only way Java would be involved in a browser.

You can't attach Java ActionListeners to HTML buttons.
[ October 20, 2008: Message edited by: Ulf Dittmer ]
 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
itis SWT application , is there any method for mouse clicked event in mouselistner or any listener
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would attach an ActionListener to all buttons that can receive mouseclicks.
 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i thank you for your replies, But these are dynamic buttons, they depend on the browser.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a "dynamic button"? Why can't you attach an ActionListener to them? How can they depend on the browser if it's an SWT application? You really need to TellTheDetails.
 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iam sorry for not being clear... i opened a browser using some url, and there are some buttons in that site , now when i click on any of them(button) i need to identify that button got clicked.

Thankn you
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm afraid it is becoming less clear.

Earlier you said this was an SWT application; now you're saying "some URL", which I interpret to mean an HTML page. Which one is it?

Is this a site that you are developing, so that you have control over the source code? If not, what is the point of knowing which button is clicked? As the user, you *know* which button you clicked, no?

 
Campbell Ritchie
Marshal
Posts: 55717
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you are the client and you are trying to find which button on a supplier's application was clicked? Or are you the supplier and you want to know which of your buttons was clicked?

Actually my opinion is that it you don't need to know which button was clicked at all. You add an action listener to each button, and each does something different; clicking the button takes you (indirectly) to the action, and that is what you want. Actually, Rob Prime will tell you that Actions are better than ActionListeners and you should use Actions instead; he is probably right, but I have never tried Actions yet.
 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is not a html ,yes using swt i opened a browser,


Browser b=new Browser(shell, SWT.MOZILLA);
b.setText("This is page 2");
b.setUrl("www.google.com");


b.addKeyListener( new KeyAdapter()
{
public void keyPressed(KeyEvent ke)
{
System.out.println("Key Pressed --> "+ke.character);
}
public void keyReleased( KeyEvent e )
{

System.out.println( "Key released: " + e.character );
}
} );



similarly i need for mouse clicked on button
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
satya,

I've read this thread a dozen times trying to figure out if there is a way to answer your question. I'm still at a loss. So can you answer my questions? This might help us answer yours.

1. You need to attach a mouse listener to an SWT button, true or false?

2. You need to attach a mouse listener to an HTML button that exists in the browser you launched, true or false?
 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First i thank you all ...


this is what it will be




here i'm able to get noticed which key pressed, and similarly mouse either rightclick or left click, but i need to be noticed when i click search button or any save cancel etc..(buttons) which are provided ....here.

i need to know even the name(label) of the button also, thank you and i hope now i'm clear .. thank you
[ October 20, 2008: Message edited by: Gregg Bolinger ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to answer my questions. Are you trying to detect buttons being clicked that exist on a web page inside the browser you've spawned? Please just answer this with a simple yes or no.
[ October 20, 2008: Message edited by: Gregg Bolinger ]
 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by satya satish:
yes


Finally, thank you!!

I don't think you can. Once the browser is launched, the web page loaded in it knows nothing about your SWT application and vice versa. If you wrote the web page(s) then you might be able to do some fancy client server communication stuff to send button clicks back to your SWT app but otherwise, I'd say you are out of luck.
 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you ,
no problem ......
i'm glad to meet you in this way i'm very happy ..
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!