setSize(1280, 720);
Never hardcode sizes like that. Not everybody will be using the same resolution monitor. Maybe use:
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
or use the Toolkit class to get the window bounds.
The setDividerLocation( double )
method only works on a "realized" frame, which means after you have invoked pack()
or setVisible(true)
on the frame.
Or, you need to wrap code in a SwingUtilities.invokeLater()
to make sure the code executes in the proper order. Something like
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
splitPaneLeft.setDividerLocation(165);
splitPaneRight.setDividerLocation(830);
}
});
If that doesn't work then maybe each statement will need to be done in a separate invokeLater().
Same comment about the divider locations. Don't hard code the values. Maybe you can use the setDividerLocation(.25f)
method with allocates size by percentage instead of absolute value.