• Post Reply Bookmark Topic Watch Topic
  • New Topic

java dynamic event

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a question about dynamic event.
I have two classes , one is socket server, another is a JFrame which has a JButton. Server is waiting for client socket, once it gets info, it needs to generate an event for the JButton , and then place the event into event queue. I forget how to generate a custom event.
How to do this? Thanks
//the coding is like this
public class Socket{
method(){
// waiting for client socket
Event e = new Event();
aJFrame.placeEventIntoEventQueue(e);
}
}
class aJFrame{
// event for JButton, something like this
public action(ButtonEvent e){
......
}
}
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a reference to the button you can call doClick() on it in the aFrame... you don't even have to send an event to the aFrame, just call a method on it to tell it to fire the button.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!