Beispiel #1
0
  protected void reflectPropertyChanges() {
    super.reflectPropertyChanges();

    Component c;

    c = gui.getItemObj(GG_ENVINFILE);
    if (c != null) {
      c.setEnabled(
          (pr.intg[PR_ENVSOURCE] == SRC_ENVFILE) || (pr.intg[PR_ENVSOURCE] == SRC_SOUNDFILE));
    }
    c = gui.getItemObj(GG_ENV);
    if (c != null) {
      c.setEnabled(pr.intg[PR_ENVSOURCE] == SRC_ENV);
    }
    c = gui.getItemObj(GG_RIGHTCHAN);
    if (c != null) {
      c.setEnabled(pr.intg[PR_ENVSOURCE] == SRC_ENV);
    }
    c = gui.getItemObj(GG_RIGHTCHANENV);
    if (c != null) {
      c.setEnabled((pr.intg[PR_ENVSOURCE] == SRC_ENV) && pr.bool[PR_RIGHTCHAN]);
    }
    //		c = gui.getItemObj( GG_AVERAGE );
    //		if( c != null ) {
    //			c.setEnabled( (pr.intg[ PR_ENVSOURCE ] == SRC_INPUT) ||
    //						  (pr.intg[ PR_ENVSOURCE ] == SRC_SOUNDFILE) );
    //		}
    c = gui.getItemObj(GG_ENVOUTFILE);
    if (c != null) {
      c.setEnabled(pr.bool[PR_ENVOUTPUT]);
    }
  }
Beispiel #2
0
  protected void reflectPropertyChanges() {
    super.reflectPropertyChanges();

    Component c;

    c = gui.getItemObj(GG_IMINPUTFILE);
    if (c != null) {
      c.setEnabled(pr.bool[PR_HASIMINPUT]);
    }
    c = gui.getItemObj(GG_IMOUTPUTFILE);
    if (c != null) {
      c.setEnabled(pr.bool[PR_HASIMOUTPUT]);
    }
  }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   final Color color = UIUtil.getTableFocusCellBackground();
   Component component;
   final Module module = value instanceof Module ? (Module) value : null;
   try {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, table.getSelectionBackground());
     component =
         super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
     if (module != null) {
       setText(
           module.getName()
               + " ("
               + FileUtil.toSystemDependentName(module.getModuleFilePath())
               + ")");
     }
     if (component instanceof JLabel) {
       ((JLabel) component).setBorder(noFocusBorder);
     }
   } finally {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color);
   }
   component.setEnabled(ProcessedModulesTable.this.isEnabled());
   if (component instanceof JLabel) {
     final Icon icon = module != null ? ModuleType.get(module).getIcon() : null;
     JLabel label = (JLabel) component;
     label.setIcon(icon);
     label.setDisabledIcon(icon);
   }
   component.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
   return component;
 }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   final Color color = UIUtil.getTableFocusCellBackground();
   Component component;
   T t = (T) value;
   try {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, table.getSelectionBackground());
     component =
         super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
     setText(t != null ? getItemText(t) : "");
     if (component instanceof JLabel) {
       ((JLabel) component).setBorder(noFocusBorder);
     }
   } finally {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color);
   }
   final MyTableModel model = (MyTableModel) table.getModel();
   component.setEnabled(
       ElementsChooser.this.isEnabled()
           && (myColorUnmarkedElements ? model.isElementMarked(row) : true));
   final ElementProperties properties = myElementToPropertiesMap.get(t);
   if (component instanceof JLabel) {
     final Icon icon =
         properties != null ? properties.getIcon() : t != null ? getItemIcon(t) : null;
     JLabel label = (JLabel) component;
     label.setIcon(icon);
     label.setDisabledIcon(icon);
   }
   component.setForeground(
       properties != null && properties.getColor() != null
           ? properties.getColor()
           : (isSelected ? table.getSelectionForeground() : table.getForeground()));
   return component;
 }
Beispiel #5
0
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   Component rendererComponent =
       super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   rendererComponent.setEnabled(ParameterTablePanel.this.isEnabled());
   return rendererComponent;
 }
 private static void setDescendantsEnabledIn(JComponent root, boolean b) {
   for (Component child : root.getComponents()) {
     child.setEnabled(b);
     if (child instanceof JComponent) {
       setDescendantsEnabledIn((JComponent) child, b);
     }
   }
 }
 public void setEnabledRecursive(Component component, boolean enabled) {
   if (component instanceof Container) {
     for (Component child : ((Container) component).getComponents()) {
       child.setEnabled(enabled);
       setEnabledRecursive(child, enabled);
     }
   }
 }
Beispiel #8
0
  protected void reflectPropertyChanges() {
    super.reflectPropertyChanges();

    Component c;

    c = gui.getItemObj(GG_WARPMODDEPTH);
    if (c != null) {
      c.setEnabled(pr.bool[PR_WARPMOD]);
    }
    c = gui.getItemObj(GG_WARPENV);
    if (c != null) {
      c.setEnabled(pr.bool[PR_WARPMOD]);
    }
    c = gui.getItemObj(GG_OUTFREQ);
    if (c != null) {
      c.setEnabled(inRate != 0f);
    }
  }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   Component component =
       myDelegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   component.setEnabled(ElementsChooser.this.isEnabled());
   if (component instanceof JComponent) {
     ((JComponent) component).setBorder(null);
   }
   return component;
 }
  /**
   * Overriden
   * <li>to prevent the cell focus rect to be painted
   * <li>to disable ({@link Component#setEnabled(boolean)} the renderer if the Property is not
   *     editable
   */
  public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
    Object value = getValueAt(row, column);
    boolean isSelected = isCellSelected(row, column);
    Component component =
        renderer.getTableCellRendererComponent(this, value, isSelected, false, row, column);

    PropertySheetTableModel.Item item = getSheetModel().getPropertySheetElement(row);
    if (item.isProperty()) {
      component.setEnabled(item.getProperty().isEditable());
    }
    return component;
  }
Beispiel #11
0
  /** Creating buttons with coordinates and action listeners */
  private MyButton createButton() {
    // The new buttons counters -
    // will be translates to coordinates
    if (counterX >= size) {
      counterX = 0;
      counterY++;
    }

    MyButton button = new MyButton();

    // set buttons coordinates
    button.x = counterX++;
    button.y = counterY;

    // The buttons properties adjustment
    button.setPreferredSize(new Dimension(50, 50));
    button.setFont(new Font("Dialog", Font.PLAIN, 72));

    // Action listener
    button.addActionListener(
        e -> {
          game.move(new Move(button.x, button.y));
          game.isGameOver();
          button.setText(game.getField()[button.x][button.y] > 0 ? "X" : "O");
          button.setEnabled(false);
          statusStr.setText(game.getState().toString());

          // If the game is over
          // disable all unselected buttons
          if (game.getState().equals(GameState.X_WINS)
              || game.getState().equals(GameState.O_WINS)) {

            for (Component b : gameField.getComponents()) {
              b.setEnabled(false);
            }
          }
        });

    // System.out.println("button " + button.x + " " + button.y);

    return button;
  }
  private JPanel getMixerOptionsPanel() {
    if (mixerOptionsPanel == null) {
      mixerOptionsPanel = new JPanel();
      mixerOptionsPanel.setBorder(
          BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Mixer"));

      mixerOptionsPanel.setLayout(new GridBagLayout());
      GridBagConstraints c = new GridBagConstraints();

      c.anchor = GridBagConstraints.NORTHWEST;
      c.fill = GridBagConstraints.NONE;
      c.weightx = 1;

      c.insets = new Insets(8, 4, 0, 0);
      mixerOptionsPanel.add(new JLabel("Select mixer:"), c);

      c.gridy = 1;
      mixerOptionsPanel.add(getMixerComboBox(), c);

      c.gridy = 2;
      mixerOptionsPanel.add(getMixerDefaultButton(), c);

      c.insets = new Insets(16, 4, 0, 0);
      c.gridy = 3;
      mixerOptionsPanel.add(new JLabel("Enable mixer features:"), c);

      c.insets = new Insets(6, 0, 0, 0);
      c.gridy = 4;
      mixerOptionsPanel.add(getEnableMixerVolumeCheckBox(), c);

      c.insets = new Insets(0, 0, 0, 0);
      c.gridy = 5;
      mixerOptionsPanel.add(getEnableMixerPanCheckBox(), c);

      if (AudioSystem.getMixerInfo().length == 0) {
        for (Component child : mixerOptionsPanel.getComponents()) {
          child.setEnabled(false);
        }
      }
    }
    return mixerOptionsPanel;
  }
  private JPanel getSoundOptionsPanel() {
    if (soundOptionsPanel == null) {
      soundOptionsPanel = new JPanel();
      soundOptionsPanel.setBorder(
          BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Sound Effects"));

      soundOptionsPanel.setLayout(new GridBagLayout());
      GridBagConstraints c = new GridBagConstraints();

      c.fill = 1;
      c.weightx = 1;
      c.anchor = GridBagConstraints.NORTHWEST;

      c.gridwidth = GridBagConstraints.REMAINDER;
      soundOptionsPanel.add(getEnableSoundCheckBox(), c);
      soundOptionsPanel.add(getEnableGunshotCheckBox(), c);
      soundOptionsPanel.add(getEnableBulletHitCheckBox(), c);
      soundOptionsPanel.add(getEnableRobotDeathCheckBox(), c);
      soundOptionsPanel.add(getEnableWallCollisionCheckBox(), c);
      soundOptionsPanel.add(getEnableRobotCollisionCheckBox(), c);

      c.insets = new Insets(10, 0, 0, 10);
      c.gridwidth = 1;
      c.fill = 0;
      c.weighty = 1;
      c.weightx = 0;
      soundOptionsPanel.add(getEnableAllSoundsButton(), c);
      c.weightx = 1;
      c.gridwidth = GridBagConstraints.REMAINDER;
      soundOptionsPanel.add(getDisableAllSoundsButton(), c);

      if (AudioSystem.getMixerInfo().length == 0) {
        for (Component child : soundOptionsPanel.getComponents()) {
          child.setEnabled(false);
        }
      }
    }
    return soundOptionsPanel;
  }
 private void setEnableStatusOfComponentsOfPanel(JPanel parentPanel, boolean enableStatus) {
   Component[] components = parentPanel.getComponents();
   for (Component component : components) {
     component.setEnabled(enableStatus);
   }
 }
 public void setEnabled(boolean b) {
   super.setEnabled(b);
   for (Component c : getComponents()) {
     c.setEnabled(b);
   }
 }
Beispiel #16
0
  /**
   * Standard constructor.
   *
   * @param type Type that you are going to be creating and editor for.
   * @param readOnly Set to true to create a read-only customizer.
   */
  public DynamicCustomizer(Class type, boolean readOnly) {
    super(new GridBagLayout());
    _readOnly = readOnly;
    _type = type;

    LabelFieldGBC gbc = new LabelFieldGBC();
    try {
      BeanInfo info = Introspector.getBeanInfo(type);
      // Set up pretty display stuff.
      setBorder(BorderFactory.createTitledBorder(info.getBeanDescriptor().getDisplayName()));
      setToolTipText(info.getBeanDescriptor().getShortDescription());

      // Get the properties and sort them.
      PropertyDescriptor[] props = info.getPropertyDescriptors();
      Arrays.sort(props, new PropertyComparator());
      for (int i = 0; i < props.length; i++) {
        // Ignore the "class" property, if it is provided.
        if (props[i].getName().equals("class")) continue;
        // Create a label for the field.
        JLabel label = new JLabel(props[i].getDisplayName() + ":");

        // Lookup the editor.
        PropertyEditor editor = getEditorForProperty(props[i]);

        // Add a listener to the editor so we know when to update
        // the bean's fields.
        editor.addPropertyChangeListener(_eListener);

        // XXX What we need to do right here is provide a component
        // that makes use of the "paintable" capability of the editor.
        Component comp = editor.getCustomEditor();
        if (comp == null) {
          comp = new JLabel("<No editor available.>");
          ((JLabel) comp).setBorder(BorderFactory.createEtchedBorder());
        }

        // See if it is a read-only property. If so, then just
        // display it.
        if (_readOnly || props[i].getWriteMethod() == null) {
          comp.setEnabled(false);
        }

        // Setup the accellerator key.
        label.setLabelFor(comp);
        label.setDisplayedMnemonic(label.getText().charAt(0));

        // Set the tool tip text, if any.
        String tip = props[i].getShortDescription();
        if (tip != null) {
          label.setToolTipText(tip);
          if (comp instanceof JComponent) {
            ((JComponent) comp).setToolTipText(tip);
          }
        }

        // Add the label and fields.
        add(label, gbc.forLabel());
        add(comp, gbc.forField());

        // Set the mappings between editor and property, etc. for
        // quick lookup later.
        _prop2Editor.put(props[i], editor);
        _editor2Prop.put(editor, props[i]);
      }
      // Filler...
      add(new JLabel(), gbc.forLastLabel());

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }