From 415c74543f4cdb92b32b495ac73c961f4f377387 Mon Sep 17 00:00:00 2001 From: Niki Date: Wed, 17 Apr 2019 11:06:01 +0200 Subject: [PATCH] java 1.6 compat fix --- .../fanfix/reader/ui/GuiReaderSearch.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) 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); -- 2.27.0