Esempio n. 1
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);
  }
Esempio n. 2
0
  /**
   * Uses a ImageFilter to return a cropped version of the image. Hopefully useful when handling
   * tilesets.
   */
  public static Image getTile(Image tileset, int x1, int x2, int y1, int y2, int scale) {
    JPanel producer = new JPanel();
    // Crop tileset to grab tile
    ImageFilter cropper = new CropImageFilter(x1, y1, x2 - x1, y2 - y1);
    Image cropped = producer.createImage(new FilteredImageSource(tileset.getSource(), cropper));

    return scaleImage(cropped, scale);
  }