/** * Enables and disables this button and if an action is assigned to this button the * propertychange is forwarded to the assigned action. * * @param b the new enable-state of this button */ public void setEnabled(final boolean b) { super.setEnabled(b); if (getAction() != null) { getAction().setEnabled(b); } }
/** * Nreates an ActionButton and assigns the given action with the button. * * @param action the action. */ public ActionButton(final Action action) { setAction(action); }
final Action oldAction = getAction(); if (oldAction != null) { removeActionListener(oldAction); oldAction.removePropertyChangeListener(getPropertyChangeHandler()); unregisterKeyboardAction(k); addActionListener(newAction); newAction.addPropertyChangeListener(getPropertyChangeHandler()); setText((String) (newAction.getValue(Action.NAME))); setToolTipText((String) (newAction.getValue(Action.SHORT_DESCRIPTION))); setIcon((Icon) newAction.getValue(Action.SMALL_ICON)); setEnabled(this.action.isEnabled()); if (o instanceof Character) { final Character c = (Character) o; setMnemonic(c.charValue()); setMnemonic(c.intValue()); if (o instanceof KeyStroke) { final KeyStroke k = (KeyStroke) o; registerKeyboardAction(newAction, k, WHEN_IN_FOCUSED_WINDOW);
try { if (event.getPropertyName().equals("enabled")) { setEnabled(getAction().isEnabled()); setIcon((Icon) getAction().getValue(Action.SMALL_ICON)); setText((String) getAction().getValue (Action.NAME)); ActionButton.this.setToolTipText((String) getAction().getValue(Action.SHORT_DESCRIPTION)); final Action ac = getAction(); if (event.getPropertyName().equals(ActionDowngrade.ACCELERATOR_KEY)) { final KeyStroke oldVal = (KeyStroke) event.getOldValue(); if (oldVal != null) { unregisterKeyboardAction(oldVal); registerKeyboardAction(ac, k, WHEN_IN_FOCUSED_WINDOW); if (o instanceof Character) { final Character c = (Character) o; setMnemonic(c.charValue()); setMnemonic(c.intValue());
try { camera = Camera.open(); photoButton.setEnabled(true); } catch (Exception e) { Log.e(TAG, "No camera with exception: " + e.getMessage()); photoButton.setEnabled(false); Toast.makeText(getActivity(), "No camera detected", Toast.LENGTH_LONG).show(); photoButton.setOnClickListener(new View.OnClickListener() { try { camera = Camera.open(); photoButton.setEnabled(true); } catch (Exception e) { Log.i(TAG, "No camera: " + e.getMessage()); photoButton.setEnabled(false); Toast.makeText(getActivity(), "No camera detected", Toast.LENGTH_LONG).show();
final Action oldAction = getAction(); if (oldAction != null) { removeActionListener(oldAction); oldAction.removePropertyChangeListener(getPropertyChangeHandler()); unregisterKeyboardAction(k); addActionListener(newAction); newAction.addPropertyChangeListener(getPropertyChangeHandler()); setText((String) (newAction.getValue(Action.NAME))); setToolTipText((String) (newAction.getValue(Action.SHORT_DESCRIPTION))); setIcon((Icon) newAction.getValue(Action.SMALL_ICON)); setEnabled(this.action.isEnabled()); if (o instanceof Character) { final Character c = (Character) o; setMnemonic(c.charValue()); setMnemonic(c.intValue()); if (o instanceof KeyStroke) { final KeyStroke k = (KeyStroke) o; registerKeyboardAction(newAction, k, WHEN_IN_FOCUSED_WINDOW);
try { if (event.getPropertyName().equals("enabled")) { setEnabled(getAction().isEnabled()); setIcon((Icon) getAction().getValue(Action.SMALL_ICON)); setText((String) getAction().getValue (Action.NAME)); ActionButton.this.setToolTipText((String) getAction().getValue(Action.SHORT_DESCRIPTION)); final Action ac = getAction(); if (event.getPropertyName().equals(ActionDowngrade.ACCELERATOR_KEY)) { final KeyStroke oldVal = (KeyStroke) event.getOldValue(); if (oldVal != null) { unregisterKeyboardAction(oldVal); registerKeyboardAction(ac, k, WHEN_IN_FOCUSED_WINDOW); if (o instanceof Character) { final Character c = (Character) o; setMnemonic(c.charValue()); setMnemonic(c.intValue());
final Action oldAction = getAction(); if (oldAction != null) { removeActionListener(oldAction); oldAction.removePropertyChangeListener(getPropertyChangeHandler()); unregisterKeyboardAction(k); addActionListener(newAction); newAction.addPropertyChangeListener(getPropertyChangeHandler()); setText((String) (newAction.getValue(Action.NAME))); setToolTipText((String) (newAction.getValue(Action.SHORT_DESCRIPTION))); setIcon((Icon) newAction.getValue(Action.SMALL_ICON)); setEnabled(this.action.isEnabled()); if (o instanceof Character) { final Character c = (Character) o; setMnemonic(c.charValue()); setMnemonic(c.intValue()); if (o instanceof KeyStroke) { final KeyStroke k = (KeyStroke) o; registerKeyboardAction(newAction, k, WHEN_IN_FOCUSED_WINDOW);
try { if (event.getPropertyName().equals("enabled")) { setEnabled(getAction().isEnabled()); setIcon((Icon) getAction().getValue(Action.SMALL_ICON)); setText((String) getAction().getValue (Action.NAME)); ActionButton.this.setToolTipText((String) getAction().getValue(Action.SHORT_DESCRIPTION)); final Action ac = getAction(); if (event.getPropertyName().equals(ActionDowngrade.ACCELERATOR_KEY)) { final KeyStroke oldVal = (KeyStroke) event.getOldValue(); if (oldVal != null) { unregisterKeyboardAction(oldVal); registerKeyboardAction(ac, k, WHEN_IN_FOCUSED_WINDOW); if (o instanceof Character) { final Character c = (Character) o; setMnemonic(c.charValue()); setMnemonic(c.intValue());
/** * Nreates an ActionButton and assigns the given action with the button. * * @param action the action. */ public ActionButton(final Action action) { setAction(action); }
/** * Enables and disables this button and if an action is assigned to this button the * propertychange is forwarded to the assigned action. * * @param b the new enable-state of this button */ public void setEnabled(final boolean b) { super.setEnabled(b); if (getAction() != null) { getAction().setEnabled(b); } }
/** * Nreates an ActionButton and assigns the given action with the button. * * @param action the action. */ public ActionButton(final Action action) { setAction(action); }
/** * Enables and disables this button and if an action is assigned to this button the * propertychange is forwarded to the assigned action. * * @param b the new enable-state of this button */ public void setEnabled(final boolean b) { super.setEnabled(b); if (getAction() != null) { getAction().setEnabled(b); } }