GridBagLayout problems with align
Hi, guys. Im quite new in Java and specially in GUI. Im using GridBagLayout and I have one problem all my components aligning to center but I need to left and top. How I can do that? How I can set minimum and maximum size of my application(for ex. I have app. with size 500*300 but I want set min. size 400*200 and max. size 600*400)?
Can you give me an advice where I can search and how I can change view of my components (font, size, color, shape)?
Code :
public class gui extends JFrame {
gui(){
super("Grid Bag L.");
JFrame frame = new JFrame("test_");
GridBagLayout g = new GridBagLayout();
frame.setLayout(g);
GridBagConstraints c = new GridBagConstraints();
frame.setSize(500, 200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
String[] w= {"", "", ""};
JComboBox box= new JComboBox(w);
g.setConstraints(box,c);
frame.add(box,new GridBagConstraints(0,0,5,1,0.0,0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.CENTER, new Insets(5,5,5,5),0,0));
..................
Re: GridBagLayout problems with align
Quote:
Originally Posted by
lugaru
Can you give me an advice where I can search and how I can change view of my components (font, size, color, shape)?
Please see the following, and note that layouts can be nested (one JPanel with one layout within another with a different layout)
http://docs.oracle.com/javase/tutori...ut/visual.html
Re: GridBagLayout problems with align
Quote:
Originally Posted by
lugaru
Hi, guys. Im quite new in Java and specially in GUI. Im using GridBagLayout and I have one problem all my components aligning to center but I need to left and top. How I can do that?
Use GridBagConstraints.anchor property.
Quote:
Originally Posted by
lugaru
How I can set minimum and maximum size of my application(for ex. I have app. with size 500*300 but I want set min. size 400*200 and max. size 600*400)?
component.setMinimumSize(), component.setMaximumSize()
Quote:
Originally Posted by
lugaru
Can you give me an advice where I can search and how I can change view of my components (font, size, color, shape)?
component.setFont(), component.setBackground(), component.setForeground()
Spring 3