Exemplo n.º 1
0
  private void initComponents() {
    feeField = new JFloatField(account.getCurrencyNode());

    feeButton = new JButton(Resource.getIcon("/jgnash/resource/document-properties.png"));
    feeButton.setMargin(new Insets(0, 0, 0, 0));

    feeButton.addActionListener(this);
    feeButton.setFocusPainted(false);

    if (ThemeManager.isLookAndFeelNimbus()) {
      NimbusUtils.reduceNimbusButtonMargin(feeButton);
      feeButton.setIcon(
          NimbusUtils.scaleIcon(Resource.getIcon("/jgnash/resource/document-properties.png")));
    }
  }
Exemplo n.º 2
0
  public static int getNimbusFontSize() {
    Preferences p = Preferences.userNodeForPackage(ThemeManager.class);

    int preferredSize = p.getInt(NIMBUS_FONT_SIZE, 0);

    // if the returned value is zero, determine the default base font size
    // and save it
    if (preferredSize == 0) {

      LookAndFeel old = UIManager.getLookAndFeel();

      try {
        UIManager.setLookAndFeel(new NimbusLookAndFeel());
        preferredSize = NimbusUtils.getBaseFontSize();

        p.putInt(NIMBUS_FONT_SIZE, preferredSize);

        UIManager.setLookAndFeel(old);
      } catch (Exception e) {
        Logger.getLogger(ThemeManager.class.getName()).log(Level.SEVERE, e.toString(), e);
      }
    }

    return preferredSize;
  }
Exemplo n.º 3
0
  private static void setLookAndFeel(final String lookAndFeel) {
    Preferences pref = Preferences.userNodeForPackage(ThemeManager.class);
    String theme = pref.get(THEME, DEFAULT_THEME);

    try {
      Class<?> lafClass = Class.forName(lookAndFeel);
      Object lafInstance = lafClass.newInstance();

      if (lafInstance instanceof SubstanceSkin) {
        UIManager.put(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS, Boolean.TRUE);

        if (isSubstanceAnimationsEnabled()) {
          AnimationConfigurationManager.getInstance().setTimelineDuration(animationDuration);
        } else {
          AnimationConfigurationManager.getInstance().setTimelineDuration(0);
        }

        SubstanceLookAndFeel.setSkin(lookAndFeel);
      } else if (lafInstance instanceof NimbusLookAndFeel) {
        UIManager.setLookAndFeel((LookAndFeel) lafInstance);
        NimbusUtils.changeFontSize(getNimbusFontSize());
      } else if (lafInstance instanceof MetalLookAndFeel) {
        UIManager.setLookAndFeel((LookAndFeel) lafInstance);
        setTheme(theme);
      } else if (lafInstance instanceof LookAndFeel) {
        UIManager.setLookAndFeel((LookAndFeel) lafInstance);
      }
    } catch (final ClassNotFoundException
        | InstantiationException
        | IllegalAccessException
        | UnsupportedLookAndFeelException e) {
      Logger.getLogger(ThemeManager.class.getName()).log(Level.WARNING, null, e);
    }
  }