KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > synth > SynthComboPopup


1 /*
2  * @(#)SynthComboPopup.java 1.7 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.swing.plaf.synth;
9
10 import javax.swing.*;
11 import javax.swing.event.*;
12 import javax.swing.plaf.basic.*;
13 import java.awt.*;
14 import java.awt.event.*;
15 import java.beans.PropertyChangeListener JavaDoc;
16 import java.beans.PropertyChangeEvent JavaDoc;
17 import java.io.Serializable JavaDoc;
18
19
20 /**
21  * Synth's ComboPopup.
22  *
23  * @version 1.7, 12/19/03
24  * @author Scott Violet
25  */

26 class SynthComboPopup extends BasicComboPopup {
27     public SynthComboPopup( JComboBox combo ) {
28         super(combo);
29     }
30
31     /**
32      * Configures the list which is used to hold the combo box items in the
33      * popup. This method is called when the UI class
34      * is created.
35      *
36      * @see #createList
37      */

38     protected void configureList() {
39         list.setFont( comboBox.getFont() );
40         list.setCellRenderer( comboBox.getRenderer() );
41         list.setFocusable( false );
42         list.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
43         int selectedIndex = comboBox.getSelectedIndex();
44         if ( selectedIndex == -1 ) {
45             list.clearSelection();
46         }
47         else {
48             list.setSelectedIndex( selectedIndex );
49         list.ensureIndexIsVisible( selectedIndex );
50         }
51         installListListeners();
52     }
53 }
54
Popular Tags