Reputation: 305
I'm developing an application for a deposit ATM. Almost everyone has used one of these at least once in their life so it's safe to say you know what I'm talking about.
I'm currently doing the GUI and I think I should use multiple JFrames.
My reasons:
What I dislike:
I get a screen flicker when switching from one frame to another. This might not be related to the general topic of the question and might just be because I'm disposing of frames everytime the program switches away from them instead of setting them to be invisible.
Any thoughts on the subject are welcome.
Upvotes: 0
Views: 105
Reputation: 2383
You should use a single JFrame
, and have multiple JPanel
s for the various "screens" you want to show. To change "screen", just remove from the JFrame
the JPanel
currently shown and add the new one.
EDIT:
To make the switch, you can use CardLayout
as LayoutManager of your frame. It shows one panel at a time and allows you to easily switch between them.
Upvotes: 3
Reputation: 73538
It's no real advantage to use multiple JFrame
s, when you can use a single one and have multiple content panes for it.
This should prevent any useless flickering and make sure that only one of your "screens" is visible at the same time.
Upvotes: 1