aspose file tools*
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
Author

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.
HTH
Ashish Hareet
Andrew Lit
Ranch Hand

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

into

but nothing changed.
anand pillai
Greenhorn

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();
panel.setBorder(BorderFactory.createEmptyBorder(30,30,100,30));
panel1.setLayout(new GridLayout(1,2));
panel.setLayout(new GridLayout( 2, 1));
panel1.add(button);
panel1.add(button1);
panel2.add(label);
panel.add(panel1);
panel.add(panel2);
return panel;
Anand
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem with label