if (comboBox.getSelectedIndex() != -1) list.setSelectedIndex(comboBox.getSelectedIndex());   JScrollBar scrollbar = scroller.getVerticalScrollBar(); int selectedIndex = comboBox.getSelectedIndex(); if (selectedIndex > comboBox.getMaximumRowCount()) scrollbar.setValue(getPopupHeightForRowCount(selectedIndex));   super.show(comboBox, 0, cbBounds.height);
list.ensureIndexIsVisible(list.getSelectedIndex()); setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled()); show(comboBox, bounds.x, bounds.y);
  public void show()  {    Rectangle cbBounds = comboBox.getBounds();    // popup should have same width as the comboBox and should be hight anough    // to display number of rows equal to 'maximumRowCount' property    int popupHeight = getPopupHeightForRowCount(comboBox.getMaximumRowCount());    scroller.setPreferredSize(new Dimension(cbBounds.width, popupHeight));    pack();    // Highlight selected item in the combo box's drop down list    if (comboBox.getSelectedIndex() != -1)      list.setSelectedIndex(comboBox.getSelectedIndex());    //scroll scrollbar s.t. selected item is visible    JScrollBar scrollbar = scroller.getVerticalScrollBar();    int selectedIndex = comboBox.getSelectedIndex();    if (selectedIndex > comboBox.getMaximumRowCount())      scrollbar.setValue(getPopupHeightForRowCount(selectedIndex));    // location specified is relative to comboBox    super.show(comboBox, 0, cbBounds.height);  }