From: Niki Date: Wed, 17 Apr 2019 09:06:01 +0000 (+0200) Subject: java 1.6 compat fix X-Git-Tag: fanfix-swing-0.0.1~12^2~132 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=415c74543f4cdb92b32b495ac73c961f4f377387;p=fanfix-swing.git java 1.6 compat fix --- diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderSearch.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderSearch.java index cfe241c0..172f0fa8 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderSearch.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderSearch.java @@ -49,7 +49,7 @@ public class GuiReaderSearch extends JFrame { private JPanel tagBars; - private JComboBox comboSupportTypes; + private JComboBox comboSupportTypes; private JTabbedPane searchTabs; private JTextField keywordsField; private JButton submitKeywords; @@ -75,7 +75,7 @@ public class GuiReaderSearch extends JFrame { } supportType = supportTypes.isEmpty() ? null : supportTypes.get(0); - comboSupportTypes = new JComboBox( + comboSupportTypes = new JComboBox( supportTypes.toArray(new SupportType[] {})); comboSupportTypes.addActionListener(new ActionListener() { @Override @@ -251,31 +251,27 @@ public class GuiReaderSearch extends JFrame { final SearchableTag selected) { tags.add(0, null); - final JComboBox combo = new JComboBox( + final JComboBox combo = new JComboBox( tags.toArray(new SearchableTag[] {})); combo.setSelectedItem(selected); - // We want to pass it a String - @SuppressWarnings({ "rawtypes" }) final ListCellRenderer basic = combo.getRenderer(); - combo.setRenderer(new ListCellRenderer() { + combo.setRenderer(new ListCellRenderer() { @Override public Component getListCellRendererComponent( - JList list, SearchableTag value, + JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Object displayValue = value; - if (value == null) { + if (value instanceof SearchableTag) { + displayValue = ((SearchableTag)value).getName(); + } else { displayValue = "Select a tag..."; cellHasFocus = false; isSelected = false; - } else { - displayValue = value.getName(); } - // We willingly pass a String here - @SuppressWarnings("unchecked") Component rep = basic.getListCellRendererComponent(list, displayValue, index, isSelected, cellHasFocus);