public static void main(String[] args) throws Exception {
JFrame frame = new JFrame();
JPanel panel = new JPanel(new BorderLayout());
JDesktopPane desktop = new JDesktopPane();
desktop.setSize(500, 500);
JInternalFrame iframe = new JInternalFrame("chooser");
// chooser erstellen!
final JColorChooser chooser = new JColorChooser();
JButton btn = new JButton("Print color");
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(chooser.getColor());
}
});
// chooser dem panel hinzufügen
panel.add(BorderLayout.CENTER, chooser);
panel.add(BorderLayout.PAGE_END, btn);
iframe.add(panel);
iframe.setSize(500, 500);
iframe.setVisible(true);
desktop.add(iframe);
frame.setContentPane(desktop);
frame.setBounds(300, 300, 700, 700);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}