I'm just doing my personal project that draws a basic map using Swing.
I have many issues but the worst one is that the position of JLable
s changes every time I
- Resize the frame
- Set them invisible and visible again (setvisible(false)->setvisible(true))
- Move the screen to another tab 'Map 2' and come back to Map 1 (The frame has
JTabbedPane
)
It's sad that I don't have enough reputation to upload images :(
all the JLable
s are located on the top of the JPanel
.
It's like
Before
.-----------------------------------------------
.-----------------------------------------------
.---------Label1-----------------------------
.-----------------------------------------------
.------------------Label2--------------------
.-----------------------------------------------
.-------------------------------Label3-------
.-----------------------------------------------
.-----------------------------------------------
.-----------------------------------------------
After
.-----------------------------------------------
.---------Label1 Label2 Label3-----------
.-----------------------------------------------
.-----------------------------------------------
.-----------------------------------------------
.-----------------------------------------------
.-----------------------------------------------
.-----------------------------------------------
.-----------------------------------------------
.-----------------------------------------------
I also tried using setLocation(new Point(x,y));
after resizing happens but nothing came out.
Any tips will be appreciated. :)