Hello im implementing my firs split pane view and it doesn't seem to be working for me and i get the following output...

Here is the code.
//Create Album Panel
albumPanel.setLayout(new FlowLayout());
//Add List view
albumList.setMinimumSize (new Dimension(150,150));
albumPanel.add(new JScrollPane(albumList));
//Add Text Area
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setEditable(false);
textArea.setMinimumSize (new Dimension(150,150));
albumPanel.add(textArea);
//Split Pane
JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, albumList, textArea);
albumPanel.add(splitpane, BorderLayout.CENTER);
You have set your albumPanel layout to FlowLayout but you try and use a BorderLayout constants when adding to the JSplitPane:
albumPanel.add(splitpane, BorderLayout.CENTER);
you should rather set the albumPanel layout to BorderLayout via new BorderLayout()
Also it is not a good idea for you to set the size of your components let the LayoutManager's do it for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With