Why does the following code, placed alone in the constructor of a JPanel
subclass, produce a proportional empty space to the left of the split_pane
but above mQueryField
?
mMessageArea = new JTextArea ();
JScrollPane message_pane = new JScrollPane (mMessageArea);
mTableView = new JTable ();
mTableView.setFillsViewportHeight (true);
JScrollPane table_pane = new JScrollPane (mTableView);
JSplitPane split_pane = new JSplitPane (JSplitPane.VERTICAL_SPLIT,
message_pane, table_pane);
mQueryField = new JTextField ();
mQueryField.setMaximumSize (new Dimension (Short.MAX_VALUE, 20));
setLayout (new BoxLayout (this, BoxLayout.Y_AXIS));
add (split_pane);
add (mQueryField);
EDIT - SSCCE:
import java.awt.Dimension;
import javax.swing.*;
public class SSCCE extends JPanel
{
private JTextArea mMessageArea;
private JTable mTableView;
private JTextField mQueryField;
public SSCCE ()
{
mMessageArea = new JTextArea ();
JScrollPane message_pane = new JScrollPane (mMessageArea);
mTableView = new JTable ();
mTableView.setFillsViewportHeight (true);
JScrollPane table_pane = new JScrollPane (mTableView);
JSplitPane split_pane = new JSplitPane (JSplitPane.VERTICAL_SPLIT,
message_pane, table_pane);
mQueryField = new JTextField ();
mQueryField.setMaximumSize (new Dimension (Short.MAX_VALUE, 20));
setLayout (new BoxLayout (this, BoxLayout.Y_AXIS));
add (split_pane);
add (mQueryField);
}
public static void main (String[] args)
{
JFrame frame = new JFrame ();
frame.add (new SSCCE ());
frame.setVisible (true);
frame.pack ();
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
}
}