コード例 #1
0
 private void selectFirst() {
   Iterator<ItemViewObject> iter = manager.iterator();
   if (iter.hasNext()) {
     InventoryItemViewObject current = (InventoryItemViewObject) iter.next();
     setSelected(current);
   }
 }
コード例 #2
0
  /// *
  public void paintComponent(Graphics g) { // change to render(Graphics g, int x, int y) ?
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;
    Iterator<ItemViewObject> iter = manager.iterator();
    offset =
        Config.instance().INVENTORY_IMAGE_HEIGHT
            + this.titleLabel.getHeight(); // going to need to find a better way to get an offset
    while (iter.hasNext()) {
      InventoryItemViewObject current = (InventoryItemViewObject) iter.next();
      if (current.isSelected) {
        // Border b = BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.ORANGE,
        // Color.ORANGE);
        // b.paintBorder(current, g2d, 0, offset, viewWidth,
        // Config.instance().INVENTORY_IMAGE_HEIGHT);
        g2d.setColor(new Color(255, 255, 255, 80));
        g2d.fillRect(0, offset, viewWidth, Config.instance().INVENTORY_IMAGE_HEIGHT);
        // current.paintComponent(g2d, 20, offset, viewWidth, viewHeight); //this paintComponent
        // method is in the InventoryItemViewObject class
        current.paintComponent(
            g2d,
            (viewWidth / 4) - Config.instance().INVENTORY_IMAGE_WIDTH - (viewWidth / 12),
            offset,
            viewWidth,
            viewHeight); // this paintComponent method is in the InventoryItemViewObject class

      } else {
        // current.paintComponent(g2d, 20, offset, viewWidth, viewHeight); //this paintComponent
        // method is in the InventoryItemViewObject class
        current.paintComponent(
            g2d,
            (viewWidth / 4) - Config.instance().INVENTORY_IMAGE_WIDTH - (viewWidth / 12),
            offset,
            viewWidth,
            viewHeight); // this paintComponent method is in the InventoryItemViewObject class
      }
      offset = offset + Config.instance().INVENTORY_IMAGE_HEIGHT + 2;
    }
    Toolkit.getDefaultToolkit().sync(); // purpose?
  }