Избавьтесь от всего использования setBounds(...)
и рассмотрите возможность использования BoxLayout для основной JPanel:
public DeeLiteControlPanel() {
// setBounds(0, 140, 250, 550);
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
например,
import java.awt.*;
import javax.swing.*;
@SuppressWarnings("serial")
public class DeeLiteControlPanel extends JPanel {
public DeeLiteControlPanel() {
// setBounds(0, 140, 250, 550);
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
JPanel dataGroup = createGroupWithName("Data");
add(dataGroup);
JButton loadBtn = new JButton("Load data");
dataGroup.add(loadBtn);
JPanel viewGroup = createGroupWithName("View");
viewGroup.setLayout(new BorderLayout(5, 5));
add(viewGroup);
JButton skyBtn = new JButton("View from sky");
viewGroup.add(skyBtn, BorderLayout.NORTH);
final JToggleButton chaseBtn = new JToggleButton("Chase Vehicle");
viewGroup.add(chaseBtn, BorderLayout.EAST);
JComboBox _vehicleList = new JComboBox();
_vehicleList.setEditable(false);
viewGroup.add(_vehicleList, BorderLayout.WEST);
JButton fitToWinBtn = new JButton("Fit to Window");
viewGroup.add(fitToWinBtn, BorderLayout.SOUTH);
JPanel formattingGroup = createGroupWithName("Formatting");
formattingGroup.setMinimumSize(new Dimension(250, 20));
formattingGroup.setLayout(new GridLayout(5, 0));
add(formattingGroup);
final JCheckBox showSurface = new JCheckBox("Show surface");
showSurface.setSelected(true);
formattingGroup.add(showSurface);
final JCheckBox showTerrain = new JCheckBox("Show terrain");
showTerrain.setSelected(true);
formattingGroup.add(showTerrain);
final JCheckBox showVehicleStatus = new JCheckBox("Show vehicle status");
showVehicleStatus.setSelected(true);
formattingGroup.add(showVehicleStatus);
JPanel pnl = createGroupWithName("Depth Stretch");
formattingGroup.add(pnl);
JSlider slider = new JSlider(0, 10);
pnl.add(slider);
}
public static JPanel createGroupWithName(String name) {
JPanel pnl = new JPanel();
pnl.setBorder(BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), name));
pnl.setMinimumSize(new Dimension(250, 30));
return pnl;
}
private static void createAndShowGui() {
DeeLiteControlPanel mainPanel = new DeeLiteControlPanel();
JFrame frame = new JFrame("DeeliteControlPanel");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGui();
}
});
}
}