I'm trying to build a simple layout, with :
** first row is consisted of : 3 JComboboxes. ** second row of one JTextArea ** third row of 3 buttons. However, I'm getting this weird layout :
How can I make everything seem without all these insanse gaps, and set a sensible height to the components (it seems it takes up the whole frame currently for some reason)?
My code :
mainFrame.setSize(500,600); mainFrame.setLayout(new GridLayout(0,1,0,0)); mainFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent){ System.exit(0); } }); JPanel datePanel = new JPanel(new GridLayout(1,3,0,0)); String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" }; JComboBox petList = new JComboBox( petStrings ); JComboBox petList2 = new JComboBox( petStrings ); JComboBox petList3 = new JComboBox( petStrings ); datePanel.add( petList ); datePanel.add( petList2 ); datePanel.add( petList3 ); mainFrame.add( datePanel ); JPanel controlPanel = new JPanel(); controlPanel.setLayout(new FlowLayout()); final JTextArea commentTextArea = new JTextArea("",7,25); JScrollPane scrollPane = new JScrollPane(commentTextArea); controlPanel.add(scrollPane); mainFrame.add(controlPanel); JPanel buttonsPanel = new JPanel( new GridLayout(0,1,10,10) ); buttonsPanel.add( new JButton("x") ); buttonsPanel.add( new JButton("y") ); buttonsPanel.add( new JButton("z") ); mainFrame.add( buttonsPanel ); 
GridLayoutandGridBagLayout