cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { color = null; dispose(); } });
    private void init() {        ImageViewPanel imagePanel = new ImageViewPanel(image);        imagePanel.addMouseListener(this);        imagePanel.addMouseMotionListener(this);        setTitle("Color Chooser");        color = new Color(255, 103, 139);  //Evil pink        colorPanel = new JPanel();        colorPanel.setPreferredSize(new Dimension(25, 25));        colorPanel.setBackground(color);        bCancel = new JButton("Cancel");        bCancel.addActionListener(this);        JScrollPane imageScrollPane = new JScrollPane(imagePanel);        imageScrollPane.setAutoscrolls(true);        VerticalStaticJPanel mainPanel = new VerticalStaticJPanel();        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));        mainPanel.add(imageScrollPane);        JPanel buttonPanel = new JPanel(new GridBagLayout());        GridBagConstraints c = new GridBagConstraints();        c.gridx = 0;        c.gridy = 0;        c.weightx = 1;        c.fill = GridBagConstraints.HORIZONTAL;        buttonPanel.add(colorPanel);        c.gridx = 1;        buttonPanel.add(Box.createRigidArea(new Dimension(25, 5)));        c.gridx = 2;        buttonPanel.add(bCancel);        mainPanel.add(buttonPanel);        setContentPane(mainPanel);    }