I have two frames, Frame A and Frame B. Now, how the frame A will know when a button on Frame B is pressed?
Asked
Active
Viewed 524 times
0
-
1Frame A won't know, Frame B has to notify this to Frame A somewhere. – Luiggi Mendoza Nov 05 '13 at 15:30
-
Are they in the same class file? – Levenal Nov 05 '13 at 15:32
-
[The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/597657) – Eng.Fouad Nov 05 '13 at 15:36
1 Answers
1
It won't. I would consider a design pattern such as mvc: http://tomdalling.com/blog/software-design/model-view-controller-explained/
You need to have some sort of background construction to allow for the jFrames to communicate. MVC allows changes in the information for one jFrame to affect another. It's a little conceptually complex but appears to be a generally accepted form for creating user interfaces. There are a lot of resources out there to help you learn the correct form

LuigiEdlCarno
- 2,410
- 2
- 21
- 37

ford prefect
- 7,096
- 11
- 56
- 83
-
1yes MVC is usually the way people go with something like this. Frame A would notify via an ActionListener the Controller (class), which then decides what to do with the action notification, and if appropriate, forwards it off to Frame B to perform some function.Think of the Controller as the Traffic Guard for your program. – SnakeDoc Nov 05 '13 at 15:37
-
1Design pattern is the correct term. thanks for the edit. And yes snakeDoc good elaboration – ford prefect Nov 05 '13 at 15:38