How to create with Intellij and swing interface tab like functionality? - java

I have a task to create a desktop app and I decided to use Swing as I have some experience with it. Also I am using Intllij and I noticed it have a form creator visual interface so I want to use it because its easier.
Samples of my interface is attached here. Its not hard but I dont know which controls to use in order to make something like this. On startup I need to have some text on the right side of the window, then on press on different button on the left to change that text with some other controls like fields labels check boxes etc. Its bit like tabs but I cannot use the JTabbedPane because it become with too different design. Could you advice me which controls to use and how to use them in order to achieve this design ?
Here is the design:

Also I am using Intllij and I noticed it have a form creator visual interface so I want to use it because its easier.
It isn't easier as you end up spending time learning the IDE instead of learning Swing. Any code that is generated will not be maintainable if you ever need to switch to a different IDE.
Learn how to create/maintain the GUI forms manually.
, then on press on different button on the left to change that text with some other controls like fields labels check boxes etc
Start with the standard BorderLayout for the frame. Then you create a panel with your buttons to display on the left. You create a second panel that uses a CardLayout in the CENTER of the BorderLayout. Then when you click a button you swap the panel that is displayed in the CENTER.
Read the section from the Swing tutorial on Layout Managers. There are sections on:
How to Use BorderLayout
How to Use CardLayout
to get your started with working examples.

If you are creating a commercial application(rather then as a leaning experience) consider using JIDE Common Layer as the MultiplePageDialog provides the functionality you seem to be describing:
In this case a series of buttons on the left controlling a panel on the right

Related

How to get my components to resize properly with JFrame Netbeans?

I'm trying to make all my components to resize properly with JFrame Netbeans, but if I put the auto resizing to my components, it has like a margin between them, and if I try to put them together, it messes up the components , and I need them to be touching each other.
Thanks!
Double-click on the extra space between the components: it should open a dialog where you can change its size.
You can also click the extra space, and use the mouse wheel.
Netbeans form designer is very powerful and handy when you master it, but it requires some effort at first, especially for large user interfaces. If not already done, take some time to follow this tutorial: https://netbeans.apache.org/kb/docs/java/quickstart-gui.html
Also, if your user interface is large, it's better to break it in several smaller panels. You can design each panel independently with the form designer.

How to navigate between applet forms?

I want to create an applet with first form have multiple button, each button takes me to another form to perform a specific task.
How to do that using a Java applet?
There are lots of different ways to do this. The details depend on what exact effect and feel you are after. For example:
A CardLayout in the CENTER controlled by a JList (the menu) in the LINE_START of a BorderLayout.
A JTabbedPane, though that doesn't quite fit the use-case here.
For a blocking component, look to a free floating modal JDialog or a JOptionPane. This encourages the user to concentrate on one 'transaction' (e.g. new|edit|delete) at a time.
Non modal dialogs for when the user can have multiple dialogs/transactions open in parallel.
...
See also
A Visual Guide to Layout Managers
A Visual Guide to Swing Components (Java Look and Feel) (currently an HTTP 401 error here..).
More on using layout managers or combinations of them1, along with layout padding & borders for white space2.

Revamp Panel Based UI to JTabbed Panes

I have developed a simple music player in Java which can play any given playlist or simple mp3 song.
For now i have worked all things out in plain JPanels. GUI doesn't look neat.
I need to revamp the GUI using tabbed pane. How this can be achieved using existing JPanels without affecting current functionality?
Also, i am not able to figure out shall i go for Tabbed Pane or Card Layout?
http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html
Because a tabbed pane provides its own GUI, using a tabbed pane is simpler than using the CardLayout class.
"Also, i am not able to figure out shall i go for Tabbed Pane or Card Layout?"
It really depends on your preference of the look of your program. The two layouts perform very similarly, though CardLayout is a little bit more code, though at all not difficult. If you don't want the tab look, which I don't see why you would, for a game, then go with CardLayout
"How this can be achieved using existing JPanels without affecting current functionality? "
You need to create separate JPanel for each containment of whatever components you want in each tab. Then just add those JPanel to the JTabbedPane. It shouldn't break any functionality, just the look. Components from another panel should not be affected, you just won't be able to see any changes made, unless that other panel is in view.
If you want to go with CardLayout you can look at the tutorial

How do I refresh a GUI in Java?

I have a general question that is Java related.
I am writing an application that has a GUI menu. I am trying to change one part of the GUI menu based on the selection of a Radio button.
Do I need to:
Redraw the whole window or just update that part with:
setVisible(true)?
If I just use the statement from #1 above .. the GUI is fine -- until I move the mouse over it and then I see the previous button choice. What am I doing wrong?
Swing components have a repaint(), revalidate(), and doLayout() method. One of those should probably be able to redraw whichever pieces you want. However, doLayout is not something that you should be taking responsibility for, that's the layout engines responsibility.
You may also want to check out this post, the first response has a pretty good explanation, and links to an article with more detail.
In terms of the second part of your question, I'm not sure, but we may need to see some code to get an idea. Is the 'replaced area' actually being removed from the view?
..in my application the user select which device platform type they want top test (that choice is a set of two radio buttons on the left). When the user selects either Android or iOS, the center grouping of check boxes changes to reflect a group of android devices they can test or a group of iOS devices that they can test.
Put a panel in the 'center grouping'.
Use a CardLayout for the panel.
Add both iOS & Android controls to the panel with the card layout.
Flip between them as needed.
Call revalidate() on the top level component.

How to make child dialog popped-up from and embedded into the parent window by double clicking it in Java SWing?

I want a main window with several child widgets and I want the child widget to be shown in the main frame at the same time and they can coordinate with each other to layout through the main
window area. When I double click the child widget it can pop-up and when double click again it can embed back.
I have done this in QT by QDockWidget before and I've learned that the JavaDocking Framework can achieve this, but I want to know whether it can be done just by SWing framework?
If you're asking for full featured docking, you should probably edit your question title to reflect that.
Docking is pretty complicated as it involves dynamic layout, drag-n-drop, and many other things. You could roll your own, essentially with nested JSplitPane and JTabbedPane and a lot of time.
Besides JavaDocking, consider the open source (MIT licensed) FlexDock, or the commercial JIDE Docking.

Categories

Resources