author | alexsch |
Wed, 25 Sep 2013 17:08:31 +0400 | |
changeset 20168 | 137788883a22 |
parent 12405 | 3a06b392a805 |
child 23010 | 6dadb192ad81 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.swing.plaf.synth; |
|
27 |
||
28 |
import javax.swing.*; |
|
12405
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
29 |
import javax.swing.plaf.ComboBoxUI; |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
30 |
import javax.swing.plaf.basic.BasicComboPopup; |
2 | 31 |
import java.awt.*; |
32 |
||
33 |
||
34 |
/** |
|
35 |
* Synth's ComboPopup. |
|
36 |
* |
|
37 |
* @author Scott Violet |
|
38 |
*/ |
|
39 |
class SynthComboPopup extends BasicComboPopup { |
|
40 |
public SynthComboPopup( JComboBox combo ) { |
|
41 |
super(combo); |
|
42 |
} |
|
43 |
||
44 |
/** |
|
45 |
* Configures the list which is used to hold the combo box items in the |
|
46 |
* popup. This method is called when the UI class |
|
47 |
* is created. |
|
48 |
* |
|
49 |
* @see #createList |
|
50 |
*/ |
|
12405
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
51 |
@Override |
2 | 52 |
protected void configureList() { |
53 |
list.setFont( comboBox.getFont() ); |
|
54 |
list.setCellRenderer( comboBox.getRenderer() ); |
|
55 |
list.setFocusable( false ); |
|
56 |
list.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); |
|
57 |
int selectedIndex = comboBox.getSelectedIndex(); |
|
58 |
if ( selectedIndex == -1 ) { |
|
59 |
list.clearSelection(); |
|
60 |
} |
|
61 |
else { |
|
62 |
list.setSelectedIndex( selectedIndex ); |
|
63 |
list.ensureIndexIsVisible( selectedIndex ); |
|
64 |
} |
|
65 |
installListListeners(); |
|
66 |
} |
|
12405
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
67 |
|
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
68 |
/** |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
69 |
* @inheritDoc |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
70 |
* |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
71 |
* Overridden to take into account any popup insets specified in |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
72 |
* SynthComboBoxUI |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
73 |
*/ |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
74 |
@Override |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
75 |
protected Rectangle computePopupBounds(int px, int py, int pw, int ph) { |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
76 |
ComboBoxUI ui = comboBox.getUI(); |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
77 |
if (ui instanceof SynthComboBoxUI) { |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
78 |
SynthComboBoxUI sui = (SynthComboBoxUI) ui; |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
79 |
if (sui.popupInsets != null) { |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
80 |
Insets i = sui.popupInsets; |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
81 |
return super.computePopupBounds( |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
82 |
px + i.left, |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
83 |
py + i.top, |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
84 |
pw - i.left - i.right, |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
85 |
ph - i.top - i.bottom); |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
86 |
} |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
87 |
} |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
88 |
return super.computePopupBounds(px, py, pw, ph); |
3a06b392a805
7158712: Synth Property "ComboBox.popupInsets" is ignored
rupashka
parents:
5506
diff
changeset
|
89 |
} |
2 | 90 |
} |