Question

I would like to ask if SpringLayout can do anything like absolute position because I think absolute position have problem when I maximize the frame and what do I have to use if I need to set JMenu and JToolBar and JTextField and JTable all in one line in order?

I tried to use Borderlayout but it give me very big JTextField. I tried Gridlayout it give also big JTextField I need it big but not as big as it shows up.

Was it helpful?

Solution

can SpringLayout do all the job

No. It is neither designed, nor intended to do 'all the job'.

Java GUIs might have to work on a number of platforms, on different screen resolutions & using different PLAFs. As such they are not conducive to exact placement of components. To organize the components for a robust GUI, instead use layout managers, or combinations of them1, along with layout padding & borders for white space2.

OTHER TIPS

For absolute positioning, don't use a layout manager at all.

However, that's not really recommended. Usually you should use a layout that would scale.

See also this thread for more discussion.

i found note writing by java says

Note: This lesson covers writing layout code by hand, which can be challenging. If you are not interested in learning all the details of layout management, you might prefer to use the GroupLayout layout manager combined with a builder tool to lay out your GUI. One such builder tool is the NetBeans IDE. Otherwise, if you want to code by hand and do not want to use GroupLayout, then GridBagLayout is recommended as the next most flexible and powerful layout manager

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top