Ejemplo n.º 1
0
  public static Color getColor(String selectTitle, Color color) {
    JColorChooser chooser = getInstance();
    if (instance == null) return null;

    instance.setColor(color);
    JColorChooser.createDialog(VisualDCT.getInstance(), selectTitle, true, instance, null, null)
        .setVisible(true);
    return chooser.getColor();
  }
Ejemplo n.º 2
0
  /**
   * Handle action events coming from the buttons.
   *
   * @param evt, the associated ActionEvent.
   */
  public void actionPerformed(ActionEvent evt) {
    Object source = evt.getSource();

    if (source instanceof JButton) {
      if (source == pbSave) {
        chosen = tcc.getColor();
        onCancel();
      } else {
        onCancel();
      }
    }
  }
Ejemplo n.º 3
0
  @Override
  public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (EDIT.equals(cmd)) {
      // The user has clicked the cell, so bring up the dialog.
      button.setBackground(currentColor);
      dialog.setVisible(true);

      fireEditingStopped(); // Make the renderer reappear.

    } else { // User pressed dialog's "OK" button.
      currentColor = colorChooser.getColor();
    }
  }
Ejemplo n.º 4
0
  /**
   * Display a dialog which can be used to select a color
   *
   * @param dialogTitle
   * @param defaultColor The currently selected color
   * @return The color the user selected, or null if none/cancelled
   */
  public static Color showColorChooserDialog(String dialogTitle, Color defaultColor) {

    Color color = null;
    JColorChooser chooser = new JColorChooser();
    chooser.setColor(defaultColor);
    while (true) {

      int response =
          JOptionPane.showConfirmDialog(
              IGV.getMainFrame(), chooser, dialogTitle, JOptionPane.OK_CANCEL_OPTION);

      if ((response == JOptionPane.CANCEL_OPTION) || (response == JOptionPane.CLOSED_OPTION)) {
        return null;
      }

      color = chooser.getColor();
      if (color == null) {
        continue;
      } else {
        break;
      }
    }
    return color;
  }
Ejemplo n.º 5
0
 /**
  * <br>
  * 方法说明:事件监听。用户选择颜色触发 <br>
  * 输入参数:ChangeEvent e 用户选择事件 <br>
  * 返回类型:
  */
 public void stateChanged(ChangeEvent e) {
   Color newColor = tcc.getColor(); // 获取用户选择的颜色
   banner.setForeground(newColor);
 }
Ejemplo n.º 6
0
 public void actionPerformed(ActionEvent e) {
   color = chooser.getColor();
 }
Ejemplo n.º 7
0
 /** 設定された色 */
 public Color getColorValue() {
   return customColorChooser.getColor();
 }
Ejemplo n.º 8
0
 /** ActionListener interface. Sets the color from the JColorChooser. */
 public void actionPerformed(ActionEvent e) {
   color = chooser.getColor();
   setPreviewColor(color);
   isOK = true;
 }
Ejemplo n.º 9
0
 public ColorTracker(JColorChooser c) {
   chooser = c;
   preview = new ColorRect(chooser.getColor());
 }
Ejemplo n.º 10
0
 /** Action listener for the OK button in the color chooser. */
 public void actionPerformed(ActionEvent e) {
   // ok button in color chooser was pressed.
   this.setColor(colorChooser.getColor());
   super.fireActionPerformed(e);
 }