0

I have two frames, Frame A and Frame B. Now, how the frame A will know when a button on Frame B is pressed?

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
DavidODW
  • 417
  • 4
  • 16

1 Answers1

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
  • 1
    yes 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
  • 1
    Design pattern is the correct term. thanks for the edit. And yes snakeDoc good elaboration – ford prefect Nov 05 '13 at 15:38