Esempio n. 1
0
  /**
   * Adds the given NamedMediaType.
   *
   * <p>Marks the 'Any Type' as selected.
   */
  private void addMediaType(NamedMediaType type, String toolTip) {
    Icon icon = type.getIcon();
    Icon disabledIcon = null;
    Icon rolloverIcon = null;
    AbstractButton button = new JRadioButton(type.getName());
    button.putClientProperty(MEDIA, type);
    button.putClientProperty(SELECTED, icon);
    if (icon != null) {
      disabledIcon = ImageManipulator.darken(icon);
      rolloverIcon = ImageManipulator.brighten(icon);
    }
    button.putClientProperty(DESELECTED, disabledIcon);
    button.setIcon(disabledIcon);
    button.setRolloverIcon(rolloverIcon);
    button.addItemListener(HIGHLIGHTER);
    button.setBorderPainted(false);
    button.setFocusPainted(false);
    button.setContentAreaFilled(false);
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setOpaque(false);
    button.addMouseListener(CLICK_FORWARDER);
    button.setPreferredSize(new Dimension(100, 22));
    if (toolTip != null) {
      button.setToolTipText(toolTip);
    }
    GROUP.add(button);

    DitherPanel panel = new DitherPanel(DITHERER);
    panel.setDithering(false);
    panel.setLayout(new FlowLayout(FlowLayout.LEFT, 7, 1));
    panel.add(button);
    panel.addMouseListener(CLICK_FORWARDER);
    panel.setBackground(UIManager.getColor("TabbedPane.background"));
    SCHEMAS.add(panel);

    if (type.getMediaType() == MediaType.getAnyTypeMediaType()) button.setSelected(true);
    else button.setSelected(false);
  }
Esempio n. 2
0
 /** Returns the selected item's media type. */
 public MediaType getSelectedMediaType() {
   NamedMediaType nmt = getSelectedMedia();
   if (nmt == null) return null;
   return nmt.getMediaType();
 }