* fix NPE (when using Nimbus LaF )
This commit is contained in:
parent
6aa9fa8e7d
commit
c40a04857f
|
@ -97,9 +97,7 @@ public class SelectButtonTextField<T> extends JComponent {
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
|
||||||
setBorder(new EmptyBorder(1, 4, 1, 4));
|
setBorder(new EmptyBorder(1, 4, 1, 4));
|
||||||
|
|
||||||
String highlightText = SelectButtonTextField.this.getText().substring(0, ((TextFieldComboBoxUI) editor.getUI()).getEditor().getSelectionStart());
|
String highlightText = SelectButtonTextField.this.getText().substring(0, ((TextFieldComboBoxUI) editor.getUI()).getEditor().getSelectionStart());
|
||||||
|
|
||||||
// highlight the matching sequence
|
// highlight the matching sequence
|
||||||
|
@ -107,7 +105,6 @@ public class SelectButtonTextField<T> extends JComponent {
|
||||||
|
|
||||||
// use no-break, because we really don't want line-wrapping in our table cells
|
// use no-break, because we really don't want line-wrapping in our table cells
|
||||||
StringBuffer htmlText = new StringBuffer("<html><nobr>");
|
StringBuffer htmlText = new StringBuffer("<html><nobr>");
|
||||||
|
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
matcher.appendReplacement(htmlText, "<span style='font-weight: bold;'>$0</span>");
|
matcher.appendReplacement(htmlText, "<span style='font-weight: bold;'>$0</span>");
|
||||||
|
@ -115,13 +112,10 @@ public class SelectButtonTextField<T> extends JComponent {
|
||||||
matcher.appendReplacement(htmlText, "<span style='color: " + SwingUI.toHex(list.getSelectionBackground()) + "; font-weight: bold;'>$0</span>");
|
matcher.appendReplacement(htmlText, "<span style='color: " + SwingUI.toHex(list.getSelectionBackground()) + "; font-weight: bold;'>$0</span>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
matcher.appendTail(htmlText);
|
matcher.appendTail(htmlText);
|
||||||
|
|
||||||
htmlText.append("</nobr></html>");
|
htmlText.append("</nobr></html>");
|
||||||
|
|
||||||
setText(htmlText.toString());
|
setText(htmlText.toString());
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public final class SwingUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toHex(Color c) {
|
public static String toHex(Color c) {
|
||||||
return String.format("#%02x%02x%02x", c.getRed(), c.getGreen(), c.getBlue());
|
return c == null ? "inherit" : String.format("#%02x%02x%02x", c.getRed(), c.getGreen(), c.getBlue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isShiftOrAltDown(ActionEvent evt) {
|
public static boolean isShiftOrAltDown(ActionEvent evt) {
|
||||||
|
|
Loading…
Reference in New Issue