开发者

Use variable through multiple frames in java

I am creating a project that with be开发者_StackOverflow社区 using multiple jFrames. There is one important variable I have that every frame needs access to. Is there a way to use this variable through all of the frames?


There are countless ways to solve this problem..

  1. Make it a static variable in some class that all of the JFrames can reference
  2. Make your own JFrame subclass and add a static field to it
  3. Make your own JFrame class and pass it into the constructor

And so on...


If you have multiple JFrames you still have one main JFrame that will create other JFrames. So declare this variable in "main" JFrame and pass it through as constructor parameter of other JFrame

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜