src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 58,68 ****
public class WindowsComboBoxUI extends BasicComboBoxUI {
private static final MouseListener rolloverListener =
new MouseAdapter() {
private void handleRollover(MouseEvent e, boolean isRollover) {
! JComboBox comboBox = getComboBox(e);
WindowsComboBoxUI comboBoxUI = getWindowsComboBoxUI(e);
if (comboBox == null || comboBoxUI == null) {
return;
}
if (! comboBox.isEditable()) {
--- 58,68 ----
public class WindowsComboBoxUI extends BasicComboBoxUI {
private static final MouseListener rolloverListener =
new MouseAdapter() {
private void handleRollover(MouseEvent e, boolean isRollover) {
! JComboBox<?> comboBox = getComboBox(e);
WindowsComboBoxUI comboBoxUI = getWindowsComboBoxUI(e);
if (comboBox == null || comboBoxUI == null) {
return;
}
if (! comboBox.isEditable()) {
*** 86,109 ****
public void mouseExited(MouseEvent e) {
handleRollover(e, false);
}
! private JComboBox getComboBox(MouseEvent event) {
Object source = event.getSource();
! JComboBox rv = null;
if (source instanceof JComboBox) {
rv = (JComboBox) source;
} else if (source instanceof XPComboBoxButton) {
rv = ((XPComboBoxButton) source)
.getWindowsComboBoxUI().comboBox;
}
return rv;
}
private WindowsComboBoxUI getWindowsComboBoxUI(MouseEvent event) {
! JComboBox comboBox = getComboBox(event);
WindowsComboBoxUI rv = null;
if (comboBox != null
&& comboBox.getUI() instanceof WindowsComboBoxUI) {
rv = (WindowsComboBoxUI) comboBox.getUI();
}
--- 86,109 ----
public void mouseExited(MouseEvent e) {
handleRollover(e, false);
}
! private JComboBox<?> getComboBox(MouseEvent event) {
Object source = event.getSource();
! JComboBox<?> rv = null;
if (source instanceof JComboBox) {
rv = (JComboBox) source;
} else if (source instanceof XPComboBoxButton) {
rv = ((XPComboBoxButton) source)
.getWindowsComboBoxUI().comboBox;
}
return rv;
}
private WindowsComboBoxUI getWindowsComboBoxUI(MouseEvent event) {
! JComboBox<?> comboBox = getComboBox(event);
WindowsComboBoxUI rv = null;
if (comboBox != null
&& comboBox.getUI() instanceof WindowsComboBoxUI) {
rv = (WindowsComboBoxUI) comboBox.getUI();
}
*** 120,130 ****
Object source = null;
if ("componentOrientation" == propertyName
&& (source = e.getSource()) instanceof JComboBox
&& ((JComboBox) source).getUI() instanceof
WindowsComboBoxUI) {
! JComboBox comboBox = (JComboBox) source;
WindowsComboBoxUI comboBoxUI = (WindowsComboBoxUI) comboBox.getUI();
if (comboBoxUI.arrowButton instanceof XPComboBoxButton) {
((XPComboBoxButton) comboBoxUI.arrowButton).setPart(
(comboBox.getComponentOrientation() ==
ComponentOrientation.RIGHT_TO_LEFT)
--- 120,130 ----
Object source = null;
if ("componentOrientation" == propertyName
&& (source = e.getSource()) instanceof JComboBox
&& ((JComboBox) source).getUI() instanceof
WindowsComboBoxUI) {
! JComboBox<?> comboBox = (JComboBox) source;
WindowsComboBoxUI comboBoxUI = (WindowsComboBoxUI) comboBox.getUI();
if (comboBoxUI.arrowButton instanceof XPComboBoxButton) {
((XPComboBoxButton) comboBoxUI.arrowButton).setPart(
(comboBox.getComponentOrientation() ==
ComponentOrientation.RIGHT_TO_LEFT)
*** 271,281 ****
&& xp.isSkinDefined(comboBox, Part.CP_READONLY)) {
// On vista for READNLY ComboBox
// color for currentValue is the same as for any other item
// mostly copied from javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue
! ListCellRenderer renderer = comboBox.getRenderer();
Component c;
if ( hasFocus && !isPopupVisible(comboBox) ) {
c = renderer.getListCellRendererComponent(
listBox,
comboBox.getSelectedItem(),
--- 271,281 ----
&& xp.isSkinDefined(comboBox, Part.CP_READONLY)) {
// On vista for READNLY ComboBox
// color for currentValue is the same as for any other item
// mostly copied from javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue
! ListCellRenderer<Object> renderer = comboBox.getRenderer();
Component c;
if ( hasFocus && !isPopupVisible(comboBox) ) {
c = renderer.getListCellRendererComponent(
listBox,
comboBox.getSelectedItem(),
*** 382,392 ****
/**
* {@inheritDoc}
* @since 1.6
*/
@Override
! protected ListCellRenderer createRenderer() {
XPStyle xp = XPStyle.getXP();
if (xp != null && xp.isSkinDefined(comboBox, Part.CP_READONLY)) {
return new WindowsComboBoxRenderer();
} else {
return super.createRenderer();
--- 382,392 ----
/**
* {@inheritDoc}
* @since 1.6
*/
@Override
! protected ListCellRenderer<Object> createRenderer() {
XPStyle xp = XPStyle.getXP();
if (xp != null && xp.isSkinDefined(comboBox, Part.CP_READONLY)) {
return new WindowsComboBoxRenderer();
} else {
return super.createRenderer();
*** 461,471 ****
*/
@Deprecated
@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class WindowsComboPopup extends BasicComboPopup {
! public WindowsComboPopup( JComboBox cBox ) {
super( cBox );
}
protected KeyListener createKeyListener() {
return new InvocationKeyHandler();
--- 461,471 ----
*/
@Deprecated
@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class WindowsComboPopup extends BasicComboPopup {
! public WindowsComboPopup( JComboBox<Object> cBox ) {
super( cBox );
}
protected KeyListener createKeyListener() {
return new InvocationKeyHandler();
*** 521,531 ****
/**
* {@inheritDoc}
*/
@Override
public Component getListCellRendererComponent(
! JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
Component rv =
--- 521,531 ----
/**
* {@inheritDoc}
*/
@Override
public Component getListCellRendererComponent(
! JList<?> list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
Component rv =