Layout for Java Multi window appliciation - java

I need to know how to select a layout for a java swing application with multiple windows.
It has a dashboard kind home or main window with few icons(12 or more) on it. Clicking on an icon it will open a complex window on top of it then the main window is no longer visible. There will be another home icon to get back to main window on new view. Complex in the sense the opened window will have a tabbed layout. What i need to know is what layout should I use for this purpose.
Card layout and layered layout are the candidates I suppose. Or should I use separate frames or is there some other option available.
If the window can take the full screen and position the icons on it zooming appropriately according to the screen size would be great.
I'm glad if you can provide me a reference to a sample code.
Thank you in advance for helping me out.

I suppose you want to hide home screen when user opens another screen, and show it again when user clicks something like "Home" button.
For similar thing, I used JLayeredPane. It essentially allows you to sat Z-order for your components. In this case, you would have a JPanel for each screen you want to show, and you need to place it inside JLayeredPane, with home screen being initially on top. When you want to show another screen, you set it's layer to be topmost.

Related

How to create dynamic wizard?

I am making project with GUI. The thing is, that I have a button and what I need to do is that after clicking this button I need to change Frame layout. For example, like when you are installing some program and you click "next" button, the Frame layout changes and you can see some different content. Basicly, dynamic wizard.
I have tried use another Frame, but it opens in another window and that is not what I want. I want to open it in the same window.
Another thing I have tried is set visibility of these components I don't want to be displayed to false, but I find it unprofessional and it is overlook in making a desing, when I have components over themselfs.
So do you guys have any idea? Thank you.
Most of the times for a wizard like GUI, you should have JFrame and a set of JPanels. In each step you can pass the shared data as constructor arguments to each panel, and when you are making one of them invisible and make another one visible, you can get some date from the previous step panel and pass it to the next step panel(if needed).
It is very common that your panels extend the JPanel and have some argument in their constructor(s). You use these data for initializing your panel and managing the state of the overall progress.
There is no a total plan for all situations. So you should decide what to do which is best fit for your case.
Try not to have multiple JFrames.
Hope this would be helpful.

Is it possible to switch from screen to screen by just using one JFrame?

Is it possible to switch from screen to screen by just using one JFrame?
Do i need to create another JFrame or use JPanels and turn it on/off on button presses to create an illusion of jumping from screen to screen?
Or is there any other more efficient way to do this with other containers like
JDesktopPane, JLayeredPane, JInternalFrame and etc in netbeans ide?
What is the purpose and difference in usage of Swing Containers & Swing Windows?
When to use Containers and when to use windows?
By the way, i'm trying to build an Inventory System App Interface.
you can use JInternalFrame which is make how many child Frames you want in a JFrame and you can do also iconified,closable,resizable ... by make them true in child Frames until you can use JPanel instead of JFrame and switch between them(child Frame's) by just one click!
Edited------------
For Example:
JInternalFrame jInternalFrame = new JInternalFrame("Hello!",true,true,true,false);
jInternalFrame.setSize(160,200);
getContentPane().add(jInternalFrame);
jInternalFrame.add(panel);
jInternalFrame.setVisible(true);
And when you click the back button, it will return to the initial menu without popping out a dialog or changing the size or location of the window.
Sound like you can use a CardLayout. Read the section from the Swing tutorial on How to Use Card Layout for more information and examples.

What is the name of this Swing component?

I want to put one toolbar type component in which there will be one button which when pressed the toolbar should expand, size of the form increases and it contains some components like text area and label that user can see and once again when the button is pressed the toolbar is minimized and the size of the form decreases.
Can anybody tell me how to accomplish this?
e.g; like in windows 7 in my computer there is one toolbar called "Hard Disk Drives". When we press on it it shows all the drives and when we again press it it hides it.
SwingX has a collapsible panel control that I think should do what you want.
Also take a look at How to have Collapsable/Expandable JPanel in Java Swing.
Some alternatives:
You can add a JButon to a JToolBar. In your button's ActionListener, open a JOptionPane containing your components. This example illustrates some possibilities.
For a more advanced view, consider Outline, illustrated here.

Constant dialog-like functionality on a particular portion of a screen in a Java Swing application - is JDialog functionality the way to go?

To expand upon the headline :
I have a screen (my main window, an encapsulated JFrame) that's going to be created most likely with a GridBagLayout, because I need a grid whose cells are to be differently-sized rectangles. In one of these rectangles will be a malleable dialog-like functionality, with different options depending on the context of the application.
My question is, are custom JDialogs the way to go here? Or do I simply want a reusable JPanel that has the particular buttons I want displayed or disabled depending on the context? I hope this is clear; thanks. -B.
Go with the JPanel solution.
JDialog is a heavy-weight, top-level container, meaning it's window is managed by the system and cannot be embedded as a child of another component.

Busy graphic on a tab of a JTabbedPane

does anybody know of any open source implementation of a JTabbedPane in which I can set a busy graphic (say spinning ball) on the tab, while I load something into the tab - much like the spinner on Firefox tabs.
I realize I could do this by hand by creating an animated GIF and setting it as an icon on the tab - but i was hoping that there'd be something that already did this.
Netbeans supports busy-icons when you create a new Desktop Application.
I zipped them and uploaded them.
Here is the link.
With this icons you can make a thread witch update the icon by calling.
JTabbedPane.setIconAt(int tabnumber, Icon icon);
See the method documentation: javax.swing.JTabbedPane.setIconAt(int index, Icon icon).
Hope this helps
I'd stick to the GIF89a idea. You'll need the single images, that are displayed in the animation, anyway, so why not wrapping them up into GIF89a (assuming that swing supports animated GIF on tabs) instead of flipping them manually (and fighting the Swing threading challenge)

Categories

Resources