void editColor() { Color c = background ? Toolbar.getBackgroundColor() : Toolbar.getForegroundColor(); ColorChooser cc = new ColorChooser((background ? "Background" : "Foreground") + " Color", c, false); c = cc.getColor(); if (background) Toolbar.setBackgroundColor(c); else Toolbar.setForegroundColor(c); }
public ExecuteVisualizer() { // Set textarea properties jtaInstructions.setWrapStyleWord(true); jtaInstructions.setLineWrap(true); jtaInstructions.setEditable(false); // Set ExecuteVisualizer frame layout and add components to the frame setLayout(new BorderLayout(5, 10)); add(jtaInstructions, BorderLayout.CENTER); add(jbtStart, BorderLayout.SOUTH); // Set Options frame attributes optionsFrame.setSize(250, 350); optionsFrame.setTitle("Options"); optionsFrame.setResizable(false); optionsFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Set VisualizerFrame attributes vFrame.setSize(800, 475); vFrame.setTitle("Beats visualized"); vFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); vFrame.setLocationRelativeTo(null); // Set colorChoose frame attributes colorChooser.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ColorChooser newContentPane = new ColorChooser(); newContentPane.setOpaque(true); // content panes must be opaque colorChooser.setContentPane(newContentPane); colorChooser.setResizable(false); // Add listener to button which will open Options, VisualizerFrame // and colorChoose frame, and close the current frame jbtStart.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { optionsFrame.setVisible(true); vFrame.setVisible(true); colorChooser.pack(); colorChooser.setVisible(true); dispose(); } }); }
@Nullable public Component getTableCellEditorComponent( JTable table, Object value, boolean isSelected, int row, int column) { myValue = ((MyTableModel) table.getModel()).getRegistryValue(row); if (myValue.asColor(null) != null) { final Color color = ColorChooser.chooseColor( table, "Choose color", ((RegistryValue) value).asColor(Color.WHITE)); if (color != null) { myValue.setValue(color.getRed() + "," + color.getGreen() + "," + color.getBlue()); } return null; } else if (myValue.isBoolean()) { myCheckBox.setSelected(myValue.asBoolean()); myCheckBox.setBackground(table.getBackground()); return myCheckBox; } else { myField.setText(myValue.asString()); myField.setBorder(null); myField.selectAll(); return myField; } }