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

passine event from one form to other gui form  RSS feed

 
Sun Il Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if( yes == can we pass or call an event of one form from another form) {
can you give me an examole to call a button_click event of the one gui form from another form;
}
else {
any other logic to same;
}





i am just a beginner.............please help me out
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

It sounds like you might be talking about JavaScript rather than Java. Can you give us more details about exactly what you want to do?
 
Sun Il Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes



like........We have a buttton ButttonMain in parent form and ButtonChild in child form. I want to call the event ButtonChild_click of ButtonChild from ButtonMain of main form In java not in java script


can it is possible..........if yes then give me an example...........if not can we perform this functionality from any other way to call a form event from other form in java




SKM
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a few ways you could manage this.

1. If you can make the JButton (I assume you're using JButtons) on one form available to the other form you can call the doClick() method of that button to simulate it being clicked.

2. You could add the same ActionListener to both buttons.

3. You could define a method on one of the forms, and have the actionPerformed method of the two ActionListeners call it.

So the first approach makes one button fake a button click on the other, and the other two make the two buttons have the same effect. Either way, one of the forms will need a reference to the other. Here's a simplified example (using option 1):

 
Sun Il Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks sir, Matthew Browns
I was making a project .............and need this functionality .......thanks so much sir.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!