예제 #1
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);
 }
예제 #2
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);
   }
 }
예제 #3
0
 /** Hace scroll hasta el índice seleccionado. */
 public void scrollToSelectedIndex() {
   scrollTo(selection.getSelectedIndex());
 }