コード例 #1
0
 protected void onPropertyChange(
     JXHeader h, String propertyName, Object oldValue, final Object newValue) {
   if ("title".equals(propertyName)) {
     titleLabel.setText(h.getTitle());
   } else if ("description".equals(propertyName)) {
     descriptionPane.setText(h.getDescription());
   } else if ("icon".equals(propertyName)) {
     imagePanel.setIcon(h.getIcon());
   } else if ("enabled".equals(propertyName)) {
     boolean enabled = h.isEnabled();
     titleLabel.setEnabled(enabled);
     descriptionPane.setEnabled(enabled);
     imagePanel.setEnabled(enabled);
   } else if ("titleFont".equals(propertyName)) {
     titleLabel.setFont((Font) newValue);
   } else if ("descriptionFont".equals(propertyName)) {
     descriptionPane.setFont((Font) newValue);
   } else if ("titleForeground".equals(propertyName)) {
     titleLabel.setForeground((Color) newValue);
   } else if ("descriptionForeground".equals(propertyName)) {
     descriptionPane.setForeground((Color) newValue);
   } else if ("iconPosition".equals(propertyName)) {
     resetLayout(h);
   }
 }
コード例 #2
0
  protected void installDefaults(JXHeader h) {
    gradientLightColor = UIManager.getColor("JXHeader.startBackground");
    if (gradientLightColor == null) {
      // fallback to white
      gradientLightColor = Color.WHITE;
    }
    gradientDarkColor = UIManager.getColor("JXHeader.background");
    // for backwards compatibility (mostly for substance and synthetica,
    // I suspect) I'll fall back on the "control" color if JXHeader.background
    // isn't specified.
    if (gradientDarkColor == null) {
      gradientDarkColor = UIManager.getColor("control");
    }

    Painter p = h.getBackgroundPainter();
    if (p == null || p instanceof PainterUIResource) {
      h.setBackgroundPainter(createBackgroundPainter());
    }

    // title properties
    Font titleFont = h.getTitleFont();
    if (titleFont == null || titleFont instanceof FontUIResource) {
      titleFont = UIManager.getFont("JXHeader.titleFont");
      // fallback to label font
      titleLabel.setFont(titleFont != null ? titleFont : UIManager.getFont("Label.font"));
    }

    Color titleForeground = h.getTitleForeground();
    if (titleForeground == null || titleForeground instanceof ColorUIResource) {
      titleForeground = UIManager.getColor("JXHeader.titleForeground");
      // fallback to label foreground
      titleLabel.setForeground(
          titleForeground != null ? titleForeground : UIManager.getColor("Label.foreground"));
    }

    titleLabel.setText(h.getTitle());

    // description properties
    Font descFont = h.getDescriptionFont();
    if (descFont == null || descFont instanceof FontUIResource) {
      descFont = UIManager.getFont("JXHeader.descriptionFont");
      // fallback to label font
      descriptionPane.setFont(descFont != null ? descFont : UIManager.getFont("Label.font"));
    }

    Color descForeground = h.getDescriptionForeground();
    if (descForeground == null || descForeground instanceof ColorUIResource) {
      descForeground = UIManager.getColor("JXHeader.descriptionForeground");
      // fallback to label foreground
      descriptionPane.setForeground(
          descForeground != null ? descForeground : UIManager.getColor("Label.foreground"));
    }

    descriptionPane.setText(h.getDescription());
  }