got problem with the positioning of the panels in the panelInput-panel. IT seems that they like to be centered.
Would really like some help...
Thanks in advance
package slutprojekt; import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; public class mainGUI { //Frames private JFrame f = new JFrame("Se Window"); //Paneler private JPanel panelMain = new JPanel(); private JPanel panelLeft = new JPanel(); private JPanel panelRight = new JPanel(); private JPanel panelInput = new JPanel(); private JPanel panelBot = new JPanel(); private JPanel panelSök = new JPanel(); private JPanel panelLabel = new JPanel(); private JPanel panelForms = new JPanel(); private JPanel panelSkicka = new JPanel(); private JPanel panelVisaTop = new JPanel(); private JPanel panelVisaCenter = new JPanel(); private JPanel panelSearch = new JPanel(); //Containers private GridBagConstraints inPut = new GridBagConstraints(); //Knappar private JButton skickaBtn = new JButton("Skicka"); private JButton visaBtn = new JButton("Visa"); private JButton sökBtn = new JButton("Sök"); //Labels private JLabel labelNamn = new JLabel("Namn: "); private JLabel labelArtist = new JLabel("Artist: "); private JLabel labelGenre = new JLabel("Genre: "); private JLabel labelÅr = new JLabel("Year: "); private JLabel showTitle = new JLabel("Inmatad data"); //Textfields private JTextField fieldNamn = new JTextField(20); private JTextField fieldArtist = new JTextField(20); private JTextField fieldGenre = new JTextField(20); private JTextField fieldÅr = new JTextField(20); private JTextField fieldSearch = new JTextField(20); //Textområden private JTextArea MusikOut = new JTextArea(); //Scrollpanes private JScrollPane scrollVisa = new JScrollPane(MusikOut); //Optionpanes private JOptionPane noTextAlert = new JOptionPane("Du måste fylla i fälten innan du skickar"); //Egna klasser Musik[] musikLista = new Musik[20]; //Nödvändiga global variabler int antal = 0; public mainGUI() { //LABEL EGENSKAPER labelNamn.setFont(new Font("sanserif",Font.PLAIN, 14)); labelArtist.setFont(new Font("sanserif",Font.PLAIN, 14)); labelGenre.setFont(new Font("sanserif",Font.PLAIN, 14)); labelÅr.setFont(new Font("sanserif",Font.PLAIN, 14)); //PANELLABEL SETUP panelLabel.setBackground(Color.CYAN); panelLabel.setPreferredSize(new Dimension(100, 300)); panelLabel.setLayout(new GridLayout(4,1)); panelLabel.add(labelNamn); panelLabel.add(labelArtist); panelLabel.add(labelGenre); panelLabel.add(labelÅr); //PANELFORMS SETUP panelForms.setBackground(Color.green); panelForms.setPreferredSize(new Dimension(300, 300)); panelForms.setLayout(new GridLayout(4,1)); panelForms.add(fieldNamn); panelForms.add(fieldArtist); panelForms.add(fieldGenre); panelForms.add(fieldÅr); //PANELSÖK SETUP panelSök.setBackground(Color.GRAY); panelSök.setPreferredSize(new Dimension(400, 175)); //PANELINPUT SETUP panelInput.setBackground(Color.RED); panelInput.setPreferredSize(new Dimension(400, 425)); panelInput.add(panelLabel); panelInput.add(panelForms); //panelInput.add(panelBot, BorderLayout.SOUTH); //panelInput.setBounds(0, 0, 550, 400); //PANELLEFT SETUP panelLeft.setBackground(Color.GREEN); panelLeft.add(panelInput, BorderLayout.NORTH); panelLeft.add(panelSök, BorderLayout.SOUTH); //PANELRIGHT SETUP panelRight.setBackground(Color.BLUE); //PANELMAIN SETUP panelMain.setLayout(new GridLayout(1, 2)); panelMain.add(panelLeft); panelMain.add(panelRight); //MAINGUI SETUP f.getContentPane().add(panelMain); } public void körFrame() { f.setPreferredSize(new Dimension(800, 600)); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { mainGUI GUI = new mainGUI(); GUI.körFrame(); } }); } }