I am using netbeans. I want to place one JLabel exactly over another JLabel (contained in a JPanel which is in turn in a JFrame). Net beans just wont allow it and keeps repositioning the labels. I saw it allows this only in a Null layout for the panel. Netbeans by default uses group layout. Is there a way to acheive this? Or must I use null layout?
Asked
Active
Viewed 5,863 times
3 Answers
3
use
OverlayLayout
set proper
LayoutManager
toJLabel
, then (nowJLabel
is contianer) put there anotherJLabel

mKorbel
- 109,525
- 20
- 134
- 319
-
+1 for OverlayLayout - [example](http://www.java2s.com/Code/Java/Swing-JFC/LayoutOverlaySample.htm) – Reimeus Aug 14 '13 at 15:41
-
@mKorbel Making JLabel a container is good. But since netbeans does not have such a layout, I must code by hand. Is there another way? (sorry not that this wasnt a good answer !) – user2670866 Aug 14 '13 at 16:52
-
1not it wasn't in the case that you are GuiBuilder prisonier, you save 5minutes with many hours to fixing standard ideas somewhere hidden in setting for Swing Framework, or isn't possible, up to you – mKorbel Aug 14 '13 at 16:59
0
Use layout manager to 'null', it would be helpful to you for setting your gui wherever you want.

Soe Win
- 11
- 1
- 3
-
Actually this advice goes the opposite of what you saying, regarding setting layout to `null`. Just read the first paragraph below the heading of [Absolute Positioning](http://docs.oracle.com/javase/tutorial/uiswing/layout/none.html), that might can give you the idea :-) – nIcE cOw Aug 14 '13 at 16:41
0
Write click on the JFrame
Set Layout > Null Layout
now you can place JLabel over another one.

Dumindu
- 9
- 1