Example #1
0
 public static void createAndShowGUI() {
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (ClassNotFoundException
       | InstantiationException
       | IllegalAccessException
       | UnsupportedLookAndFeelException ex) {
     ex.printStackTrace();
   }
   JFrame frame = new JFrame("@title@");
   frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   frame.getContentPane().add(new MainPanel());
   frame.pack();
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
Example #2
0
  public FileNameRenderer(JTable table) {
    Border b = UIManager.getBorder("Table.noFocusBorder");
    if (Objects.isNull(b)) { // Nimbus???
      Insets i = focusCellHighlightBorder.getBorderInsets(textLabel);
      b = BorderFactory.createEmptyBorder(i.top, i.left, i.bottom, i.right);
    }
    noFocusBorder = b;

    p.setOpaque(false);
    panel.setOpaque(false);

    // http://www.icongalore.com/ XP Style Icons - Windows Application Icon, Software XP Icons
    nicon = new ImageIcon(getClass().getResource("wi0063-16.png"));
    sicon =
        new ImageIcon(
            p.createImage(
                new FilteredImageSource(nicon.getImage().getSource(), new SelectedImageFilter())));

    iconLabel = new JLabel(nicon);
    iconLabel.setBorder(BorderFactory.createEmptyBorder());

    p.add(iconLabel, BorderLayout.WEST);
    p.add(textLabel);
    panel.add(p, BorderLayout.WEST);

    Dimension d = iconLabel.getPreferredSize();
    dim.setSize(d);
    table.setRowHeight(d.height);
  }
Example #3
0
  static Color getRolloverColor() {
    if (rollColor == null) {
      rollColor = getColorAlfa(UIManager.getColor("Button.focus"), 40);
    }

    return rollColor;
  }
 /**
  * Constructs and initializes this object
  *
  * @param viewerPanel the <code>JImageViewerPanel</code> this action is linked to
  * @param imageType
  */
 public ImageViewerPanelSaveAction(JImageViewerPanel viewerPanel, int imageType) {
   super(messagesBundle.getString("ImageViewerPanelSaveAction.Save_1")); // $NON-NLS-1$
   assert viewerPanel != null;
   this.imageType = imageType;
   this.viewerPanel = viewerPanel;
   putValue(
       SHORT_DESCRIPTION,
       messagesBundle.getString("ImageViewerPanelSaveAction.Save_image_to_file_2"));
   //$NON-NLS-1$
   putValue(SMALL_ICON, UIManager.getIcon("FileView.floppyDriveIcon")); // $NON-NLS-1$
 }
Example #5
0
 static Icon getOceanDisabledButtonIcon(Image image) {
   Object[] range = (Object[]) UIManager.get("Button.disabledGrayRange");
   int min = 180;
   int max = 215;
   if (range != null) {
     min = ((Integer) range[0]).intValue();
     max = ((Integer) range[1]).intValue();
   }
   ImageProducer prod =
       new FilteredImageSource(image.getSource(), new OceanDisabledButtonImageFilter(min, max));
   return new ImageIconUIResource(Toolkit.getDefaultToolkit().createImage(prod));
 }
Example #6
0
  /**
   * Draws a radial type gradient. The gradient will be drawn vertically if <code>vertical</code> is
   * true, otherwise horizontally. The UIManager key consists of five values: r1 r2 c1 c2 c3. The
   * gradient is broken down into four chunks drawn in order from the origin.
   *
   * <ol>
   *   <li>Gradient r1 % of the size from c1 to c2
   *   <li>Rectangle r2 % of the size in c2.
   *   <li>Gradient r1 % of the size from c2 to c1
   *   <li>The remaining size will be filled with a gradient from c1 to c3.
   * </ol>
   *
   * @param c Component rendering to
   * @param g Graphics to draw to.
   * @param key UIManager key used to look up gradient values.
   * @param x X coordinate to draw from
   * @param y Y coordinate to draw from
   * @param w Width to draw to
   * @param h Height to draw to
   * @param vertical Direction of the gradient
   * @return true if <code>key</code> exists, otherwise false.
   */
  static boolean drawGradient(
      Component c, Graphics g, String key, int x, int y, int w, int h, boolean vertical) {
    java.util.List gradient = (java.util.List) UIManager.get(key);
    if (gradient == null || !(g instanceof Graphics2D)) {
      return false;
    }

    if (w <= 0 || h <= 0) {
      return true;
    }

    GradientPainter.INSTANCE.paint(c, (Graphics2D) g, gradient, x, y, w, h, vertical);
    return true;
  }
Example #7
0
  static int getInt(Object key, int defaultValue) {
    Object value = UIManager.get(key);

    if (value instanceof Integer) {
      return ((Integer) value).intValue();
    }
    if (value instanceof String) {
      try {
        return Integer.parseInt((String) value);
      } catch (NumberFormatException nfe) {
      }
    }
    return defaultValue;
  }
Example #8
0
 public static void createAndShowGUI() {
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (ClassNotFoundException
       | InstantiationException
       | IllegalAccessException
       | UnsupportedLookAndFeelException ex) {
     ex.printStackTrace();
   }
   JFrame frame = new JFrame("@title@");
   frame.setIconImages(
       Arrays.asList(
           makeBufferedImage(new StarIcon(), 16, 16),
           makeBufferedImage(new StarIcon(16, 8, 5), 40, 40)));
   // frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   // frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
   frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
   frame.getContentPane().add(new MainPanel(frame));
   frame.setResizable(false);
   frame.pack();
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
  /** {@inheritDoc} */
  public void setArmed(boolean b) {
    if (isMenuItem() && UIManager.getBoolean("MenuItem.disabledAreNavigable")) {
      if ((isArmed() == b)) {
        return;
      }
    } else {
      if ((isArmed() == b) || !isEnabled()) {
        return;
      }
    }

    if (b) {
      stateMask |= ARMED;
    } else {
      stateMask &= ~ARMED;
    }

    fireStateChanged();
  }
Example #10
0
 /**
  * Resets the UI property to a value from the current look and feel.
  *
  * @see JComponent#updateUI
  */
 public void updateUI() {
   setUI((ButtonUI) UIManager.getUI(this));
 }
Example #11
0
class FileNameRenderer implements TableCellRenderer {
  private final Dimension dim = new Dimension();
  private final JPanel p =
      new JPanel(new BorderLayout()) {
        @Override
        public Dimension getPreferredSize() {
          return dim;
        }
      };
  private final JPanel panel = new JPanel(new BorderLayout());
  private final JLabel textLabel = new JLabel(" ");
  private final JLabel iconLabel;
  private final Border focusCellHighlightBorder =
      UIManager.getBorder("Table.focusCellHighlightBorder");
  private final Border noFocusBorder;
  private final ImageIcon nicon;
  private final ImageIcon sicon;

  public FileNameRenderer(JTable table) {
    Border b = UIManager.getBorder("Table.noFocusBorder");
    if (Objects.isNull(b)) { // Nimbus???
      Insets i = focusCellHighlightBorder.getBorderInsets(textLabel);
      b = BorderFactory.createEmptyBorder(i.top, i.left, i.bottom, i.right);
    }
    noFocusBorder = b;

    p.setOpaque(false);
    panel.setOpaque(false);

    // http://www.icongalore.com/ XP Style Icons - Windows Application Icon, Software XP Icons
    nicon = new ImageIcon(getClass().getResource("wi0063-16.png"));
    sicon =
        new ImageIcon(
            p.createImage(
                new FilteredImageSource(nicon.getImage().getSource(), new SelectedImageFilter())));

    iconLabel = new JLabel(nicon);
    iconLabel.setBorder(BorderFactory.createEmptyBorder());

    p.add(iconLabel, BorderLayout.WEST);
    p.add(textLabel);
    panel.add(p, BorderLayout.WEST);

    Dimension d = iconLabel.getPreferredSize();
    dim.setSize(d);
    table.setRowHeight(d.height);
  }

  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    textLabel.setFont(table.getFont());
    textLabel.setText(Objects.toString(value, ""));
    textLabel.setBorder(hasFocus ? focusCellHighlightBorder : noFocusBorder);

    FontMetrics fm = table.getFontMetrics(table.getFont());
    Insets i = textLabel.getInsets();
    int swidth =
        iconLabel.getPreferredSize().width + fm.stringWidth(textLabel.getText()) + i.left + i.right;
    int cwidth = table.getColumnModel().getColumn(column).getWidth();
    dim.width = swidth > cwidth ? cwidth : swidth;

    if (isSelected) {
      textLabel.setOpaque(true);
      textLabel.setForeground(table.getSelectionForeground());
      textLabel.setBackground(table.getSelectionBackground());
      iconLabel.setIcon(sicon);
    } else {
      textLabel.setOpaque(false);
      textLabel.setForeground(table.getForeground());
      textLabel.setBackground(table.getBackground());
      iconLabel.setIcon(nicon);
    }
    return panel;
  }
}