Hey I am having some trouble with the Layout which my game will be in. I am fairly new to Java programming. I cannot get the layout to work for some reason.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.JButton; import javax.swing.ImageIcon; import javax.swing.JLabel; import java.awt.Container; import java.awt.FlowLayout; import java.awt.BorderLayout;
class GUI { public static void main(String args[]) { JFrame frame; Container contentPane; JTextField textfield; String load; String ngame; String pause; JButton button; JButton button2; JButton button3; ImageIcon soon; BorderLayout layout; JLabel label; frame = new JFrame(); frame.setTitle("Game"); load = "Load Game"; ngame = "New Game"; pause = "Pause"; button = new JButton(load); button2 = new JButton(ngame); button3 = new JButton(pause); soon = new ImageIcon("commabunnysoon.jpg"); layout = new BorderLayout(); label = new JLabel(soon); contentPane = frame.getContentPane(); contentPane.add(label, BorderLayout.CENTER); contentPane.add(button, BorderLayout.PAGE_END); contentPane.add(button2, BorderLayout.PAGE_END); contentPane.add(button3, BorderLayout.PAGE_END); contentPane.setLayout(layout); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } } |
What I am trying to do is, make it so that the image comes up on top and the buttons go on the bottom.
Thanks.