提交 0b9a6517 编写于 作者: S serb

7184945: [macosx] NPE in AquaComboBoxUI since jdk7u6b17, jdk8b47

Reviewed-by: malenkov, alexsch
上级 e9761aad
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -34,7 +34,6 @@ import javax.swing.border.Border; ...@@ -34,7 +34,6 @@ import javax.swing.border.Border;
import javax.swing.event.*; import javax.swing.event.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
import javax.swing.plaf.basic.*; import javax.swing.plaf.basic.*;
import com.apple.laf.ClientPropertyApplicator;
import com.apple.laf.ClientPropertyApplicator.Property; import com.apple.laf.ClientPropertyApplicator.Property;
import apple.laf.JRSUIConstants.Size; import apple.laf.JRSUIConstants.Size;
...@@ -142,35 +141,46 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { ...@@ -142,35 +141,46 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
return new AquaComboBoxEditor(); return new AquaComboBoxEditor();
} }
class AquaComboBoxEditor extends BasicComboBoxEditor implements UIResource, DocumentListener { final class AquaComboBoxEditor extends BasicComboBoxEditor
protected AquaComboBoxEditor() { implements UIResource, DocumentListener {
AquaComboBoxEditor() {
super(); super();
editor = new AquaCustomComboTextField(); editor = new AquaCustomComboTextField();
editor.addFocusListener(this); editor.addFocusListener(this);
editor.getDocument().addDocumentListener(this); editor.getDocument().addDocumentListener(this);
} }
@Override
public void focusGained(final FocusEvent e) { public void focusGained(final FocusEvent e) {
arrowButton.repaint(); if (arrowButton != null) {
arrowButton.repaint();
}
} }
@Override
public void focusLost(final FocusEvent e) { public void focusLost(final FocusEvent e) {
arrowButton.repaint(); if (arrowButton != null) {
arrowButton.repaint();
}
} }
@Override
public void changedUpdate(final DocumentEvent e) { public void changedUpdate(final DocumentEvent e) {
editorTextChanged(); editorTextChanged();
} }
@Override
public void insertUpdate(final DocumentEvent e) { public void insertUpdate(final DocumentEvent e) {
editorTextChanged(); editorTextChanged();
} }
@Override
public void removeUpdate(final DocumentEvent e) { public void removeUpdate(final DocumentEvent e) {
editorTextChanged(); editorTextChanged();
} }
protected void editorTextChanged() { private void editorTextChanged() {
if (!popup.isVisible()) return; if (!popup.isVisible()) return;
final Object text = editor.getText(); final Object text = editor.getText();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册