brushes.addMouseListener(this);
    private JPanel createShapePanel() {        // Brush presets        brushes = new BrushBrowser();        brushes.addMouseListener(this);        JScrollPane brushScrollPane = new JScrollPane(brushes);        brushScrollPane.setPreferredSize(new Dimension(100, 100));        brushes.addPropertyChangeListener(this);        brushes.setSelectedBrush(myBrush);        JPanel presets = new JPanel();        presets.setBorder(BorderFactory.createCompoundBorder(                    BorderFactory.createTitledBorder("Presets"),                    BorderFactory.createEmptyBorder(0, 5, 5, 5)));        presets.setLayout(new GridLayout(1, 1));        presets.add(brushScrollPane);        // Brush size        brushSize = new IntegerSpinner(1, 1);        if (myBrush != null) {            brushSize.setValue(myBrush.getBounds().width);        }        brushSize.addChangeListener(this);        brushSize.setToolTipText("Sets the size of the brush in tiles");        // Number of affected layers        affectLayers = new IntegerSpinner(myBrush.getAffectedLayers(),1);        affectLayers.addChangeListener(this);        // Randomize tile placement        cbRandomBrush = new JCheckBox("Random");        cbRandomBrush.setToolTipText(                "Make brush paint randomly within the shape area");        cbRandomBrush.addItemListener(this);        sRandomAmount = new JSlider();        sRandomAmount.setPreferredSize(new Dimension(                    50, sRandomAmount.getPreferredSize().height));        sRandomAmount.setToolTipText(                "The amount of area to fill with randomness");        sRandomAmount.addChangeListener(this);        // Brush options section        JPanel opts = new VerticalStaticJPanel();        opts.setLayout(new GridBagLayout());        opts.setBorder(BorderFactory.createCompoundBorder(                    BorderFactory.createTitledBorder("Options"),                    BorderFactory.createEmptyBorder(0, 5, 5, 5)));        GridBagConstraints c = new GridBagConstraints();        c.fill = GridBagConstraints.NONE;        c.anchor = GridBagConstraints.NORTHWEST;        c.weightx = 0;        c.insets = new Insets(0, 0, 5, 0);        opts.add(new JLabel("Brush size: "), c);        c.gridy = 1;        opts.add(new JLabel("Affected layers: "), c);        c.gridy = 2;        opts.add(cbRandomBrush, c);        c.gridy = 0; c.gridx = 1; c.weightx = 0.3;        c.fill = GridBagConstraints.HORIZONTAL;        opts.add(brushSize, c);        c.gridy = 1;        opts.add(affectLayers, c);        c.gridy = 2;        opts.add(sRandomAmount, c);        JPanel shapePanel = new JPanel();        shapePanel.setLayout(new BoxLayout(shapePanel, BoxLayout.Y_AXIS));        shapePanel.add(presets);        shapePanel.add(opts);        return shapePanel;    }