I cant figure out how to use java gui / layouts? - java

how can I make a gui interface with everything in order I know the borderlayout, flowlayout and gridlayout but what is panel? im so confused please help in visual basic I just dragged and dropped. im using netbeans 7.1, I can do layouts and stuff the problem is its so confusing to make all these panels and stuff and (x, y) axis where to place them I want the gui nice and neat

how can I make a gui interface with everything in order
For a single column or row, see GridLayout1 & BoxLayout2, as well as JToolBar3 & JList4.
See 'How To Use':
GridLayout
BoxLayout
JToolBar
JList

Have you seen these examples http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html ?

I was used to creating java GUI with manual coding, I mean not the drag and dropped that auto-generates the codes, so it was a lot easier for me to switch with GUI designer such as Window Builder plugin for Eclipse or the built-in swing designer of NetBeans.
I suggest you to start with the basic of Layout Managers with manual coding. Here's a good link... http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html
Start with the easiest: FlowLayout, GridLayout, and BorderLayout. These layouts are usually applied to JPanel, which is a lower level container (JFrame being the top-level container)

Related

Can't scale and move components in IntelliJ

I can't scale and move components in IntelliJ with its GridLayout. The problem is when I move/scale components they don't move to the exact place.
Picture (But I think you'd better check the vid out)
I uploaded a video on youtube
Here it is https://www.youtube.com/watch?time_continue=9&v=X6CF7TJ7GJg (sorry for a non-english speech)
You should learn how Java Swing Layouts work. Most layout managers do not allow you to place the components where you want (there is so called Null-layout, but it's not supported by IntelliJ IDEA).
You normally use splits, spacers and constraints to define where the components will appear and how they will resize when the form is resized.

Java Layoutmanagers & WindowBuilder Pro

I'm having the problem that I don't like the way all layout managers position elements for the whole window.
I'm using the WindowBuilder Pro plugin for Eclipse to design the gui.
Either I support resizing of the window and use a layout manager (crappy positioning) or I choose the absolute one which allows me to place everything wherever I want but it's non-resizable and hard to maintain.
What's the trick in getting what you want using layout managers? How can I keep more control of the placements? Using panels and nested layout managers?

Java Swing GUI Size under cross-platform

I have a swing gui which has proper JPanel and JDialog size on windows platform with screen size from 13inch to 15inch. What I refer as proper size is that all the components in JPanel and messages at JDialog are properly shown.
However, when running under Ubuntu linux with Genome/Kde desktop, I find the not all components or messages are fully shown and it appears that either width or height is not enough and the GUI interface is cropped
Anybody has ideas of how to fix it?
To have consistent UIs in multiple platforms you have to use LayoutManagers.
http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html
There are several graphical editors that support creating swing user interfaces using LayoutMaganers. One example is WindowBuilder for Eclipse: http://www.eclipse.org/windowbuilder/
Call Window.pack() for your JDialog before showing it to make the window just big enough to fit all the components in it. This requires that you are using layout managers.

Regarding swing containers

I was doing a research, I have the below application in that we have the following swing layout..
Now the thing is that this same ting I want to develop I was using swing designer of google framework ..
Please advise me what container layout and extras other things do I need t build this same forat through swing designer and I aslo later want to customize it.
As I understand, your problem is resizing two buttons equally? Well, I'd use Mig Layout, create two columns, that will scale 50% each.

What type of Java / Swing Layout can do Docking and or Anchoring?

I'm new to Java coming from .Net . Java seems to have lots of Layout Managers to choose from. Which one can anchor like in .Net and which one can dock like in .Net?
Thanks!
I have not used .Net, but if I understand you correctly, the Docking layout manager is provided by the BorderLayout.
A BorderLayout has 4 borders (North, South, East, West) and a Center panel. A JToolBar that has been set to Floatable, can float, or can be docked to one of the 4 borders of the border layout.
From what I have just read about the anchor layout, and how it resizes as the screen resizes (i.e. the percentage of space allocated to the component), then the Swing equivalent is the GridBagLayout. It is extremely configurable and capable, but many people find it difficult to get to grips with.
JToolBar is one such component, as shown in How to Use Tool Bars.
You can find all the layout manager well described here A Visual Guide to Layout Managers and chose the one the better fits your needs (I don't know how anchor/dock work in .Net). I find pretty useful GroupLayout together with components preferred size and SpringLayout if you need to design a complex layout (but SpringLayout is usually verbose and a bit annoying to maintain).
The most similar environment to winforms in Java is the GroupLayout(aka Matisse). It works much like the winforms designer in visual studio. It is not meant to be hand coded, but is built to be used by tools. The most popular IDE that uses the GroupLayout is Netbeans, but other implementations exist for Eclipse and possibly IntelliJ.
FreeLayout, used by the Matisse GUI builder in the NetBeans IDE: that's what you're looking for.
(You don't want to code FreeLayout by hand: that is a layout meant for code-generating WYSIWYG visual designers like Matisse.)

Categories

Resources