I have had a reasonable amount of experience in Java SWING development and trying to simplify updates to the program. I have a basic menu (group of JButtons) which I would like at the top of every window (JFrame) displayed, instead of trying to maintain these buttons on each individual Frame I was wondering if it was possible to create one JPanel and “import” it into multiple JFrames, similar to how you can “include” in php (Bad example but best I can think of)
Added after suggestion from first response
I currently have a JPanel on my frame titled topPanel and for the initiation of this I have:
topMenuPane = new menuPanel();
where menuPanel is a class extending JPanel however the buttons and values in the menuPanel class are not displaying in the JFrame.
You could…
Extend
JFrameand create a base frame all you applications must use.For – Easy to maintain; centralized implementation; other developers don’t need to remember to do the “setup”
Against – Tightly coupled to an implementation, may not be easy to extend for other developers (that might need to use the API).
Use a “WindowFactory” that generated the
JFramethat all you applications use to generate there base frames.For – Easy to maintain; centralized implementation; other developers don’t need to remember to do the “setup”
Against – There is still the possibility that other developers may “choose” to not use it