Пример #1
0
  /** Flashes the visual bell. This class has no other public API. */
  public void flash() {
    if (GuiUtilities.isMacOs()) {
      // Mac OS has a system-wide "visual bell" that looks much better than ours.
      // You can turn this on in the Universal Access preference pane, by checking "Flash the screen
      // when an alert sound occurs".
      // We can take advantage of Apple's hard work if the user has this turned on by "actually"
      // ringing the bell.
      // This doesn't change our "no noise pollution" policy, if you ignore the very unlikely race
      // condition.
      ArrayList<String> result = new ArrayList<String>();
      ArrayList<String> errors = new ArrayList<String>();
      int status =
          ProcessUtilities.backQuote(
              null,
              new String[] {
                "defaults",
                "-currentHost",
                "read",
                "Apple Global Domain",
                "com.apple.sound.beep.flash"
              },
              result,
              errors);
      if (status == 0 && errors.size() == 0 && result.size() == 1 && result.get(0).equals("1")) {
        Toolkit.getDefaultToolkit().beep();
        return;
      }
    }

    setBellVisibility(true);
    timer.restart();
  }
  private void initKeyboardEquivalent() {
    String key = "TAB";
    boolean shifted = (indexDelta == -1);

    boolean tabDoesNotWork = true;
    if (tabDoesNotWork || GuiUtilities.isMacOs()) {
      key = (indexDelta == -1) ? "OPEN_BRACKET" : "CLOSE_BRACKET";
      shifted = true;
    }

    putValue(ACCELERATOR_KEY, GuiUtilities.makeKeyStroke(key, shifted));
  }