Example #1
0
 /** ********************************************************************** */
 public void paintComponent(Graphics g) {
   for (int i = 0; i < model.size(); i++) {
     int y = i * cell_height;
     if (y + cell_height < g.getClipY()) continue;
     else if (y > g.getClipY() + g.getClipHeight()) break;
     //
     g.translate(0, y);
     IComponent c =
         renderer.getListCellRendererComponent(
             this, model.elementAt(i), i, selection.isSelectedIndex(i), (rollover == i));
     c.setBounds(0, 0, bounds.width, cell_height);
     c.setFont(font);
     c.setEnabled(enabled);
     c.paint(g);
     g.translate(0, -y);
   }
 }
Example #2
0
 /** ********************************************************************** */
 protected void processMouseEvent(int type, int x, int y) {
   if (type == Event.MOUSE_CLICKED) {
     // Selecciona/Deselecciona.
     int index = y / cell_height;
     if (index >= 0) {
       if (!selection.isSelectedIndex(index)) selection.selectIndex(index);
       else selection.deselectIndex(index);
     }
     rollover = index;
     repaintCell(rollover);
   } else if (type == Event.MOUSE_ENTERED || type == Event.MOUSE_MOVED) {
     int r = y / cell_height;
     if (rollover != r) {
       repaintCell(rollover);
       rollover = r;
       repaintCell(rollover);
     }
   } else if (type == Event.MOUSE_EXITED) {
     repaintCell(rollover);
     rollover = -1;
   }
   //
   super.processMouseEvent(type, x, y);
 }
Example #3
0
 public void setSize(int width, int height) {
   if (min_size.x == 0 || min_size.y == 0) min_size.setLocation(width, height);
   super.setSize(Math.max(min_size.x, width), Math.max(min_size.y, height));
 }