isaric
isaric

Reputation: 305

Maybe a good reason to use multiple JFrames, if not open to suggestions

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:

  1. Each frame is set to respond to certain, different conditions - smart card reader sends a signal, timeout occurs, click occurs, different parts of the machine send various signals to which the app must respond and display an appropriate message
  2. Since this is an embedded device the user has zero ability to interact with the os of the machine beyond using this one program. I think this sets aside considerations of esthethics - multiple windows in taskbar.
  3. The Fullscrean mode does a great job of conceiling everything else going on in the background.

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

Answers (2)

lodo
lodo

Reputation: 2383

You should use a single JFrame, and have multiple JPanels 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

Kayaman
Kayaman

Reputation: 73538

It's no real advantage to use multiple JFrames, 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

Related Questions