sp.setPreferredSize(new Dimension(150, 150));
    private void init() {        // image list        imageList = new JList();        imageList.setCellRenderer(new ImageCellRenderer());        imageList.setLayoutOrientation(JList.HORIZONTAL_WRAP);        imageList.addListSelectionListener(this);        JScrollPane sp = new JScrollPane();        sp.getViewport().setView(imageList);        // image panel        JPanel image_panel = new JPanel();        image_panel.setLayout(new BoxLayout(image_panel, BoxLayout.Y_AXIS));        imageLabel = new JLabel(new ImageIcon());        horizFlipCheck = new JCheckBox("Flip horizontally",            (imageOrientation & 1) == 1);        horizFlipCheck.addActionListener(this);        vertFlipCheck = new JCheckBox("Flip vertically",            (imageOrientation & 2) == 2);        vertFlipCheck.addActionListener(this);        rotateCheck = new JCheckBox("Rotate",            (imageOrientation & 4) == 4);        rotateCheck.addActionListener(this);        image_panel.add(imageLabel);        image_panel.add(horizFlipCheck);        image_panel.add(vertFlipCheck);        image_panel.add(rotateCheck);        // buttons        bOk = new JButton("OK");        bOk.addActionListener(this);        bCancel = new JButton("Cancel");        bCancel.addActionListener(this);        JPanel buttons = new VerticalStaticJPanel();        buttons.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));        buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));        buttons.add(bCancel);        buttons.add(bOk);        // main panel        JPanel mainPanel = new JPanel();        mainPanel.setLayout(new GridBagLayout());        GridBagConstraints c = new GridBagConstraints();        c.fill = GridBagConstraints.BOTH;        c.weightx = 1; c.weighty = 1;        mainPanel.add(sp, c);        c.weightx = 0; c.gridx = 1;        mainPanel.add(image_panel, c);        c.gridx = 0; c.weighty = 0; c.gridy = 1; c.gridwidth = 2;        mainPanel.add(buttons, c);        getContentPane().add(mainPanel);        getRootPane().setDefaultButton(bOk);    }