It's not a secret anymore!
The moose likes Swing / AWT / SWT and the fly likes problem with label Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem with label" Watch "problem with label" New topic

problem with label

Andrew Lit
Ranch Hand

Joined: Jul 01, 2002
Posts: 135
Hi, this is what i have

when i resize my frame, buttuns are being centered, but my label - no. Label stays on the left of the frame. Why is it so? What changes should i make?
thank you in advance
Ashish Hareet
Ranch Hand

Joined: Jul 14, 2001
Posts: 375
Hi Andrew,
Go thru the code snippet provided in the docs & you'll get an idea about what's going wrong or try adding another component to "panel" & you'll realise why your label is not being centered.
Ashish Hareet
Andrew Lit
Ranch Hand

Joined: Jul 01, 2002
Posts: 135
I chaged the line


but nothing changed.
anand pillai

Joined: May 26, 2003
Posts: 1
Hi Andrew,
I have added two more panels to solve ur problem , no it works as u wish

JPanel panel = new JPanel();
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
panel1.setLayout(new GridLayout(1,2));
panel.setLayout(new GridLayout( 2, 1));
return panel;
I agree. Here's the link:
subject: problem with label
It's not a secret anymore!