GUI: search: show all tag bars
authorNiki Roo <niki@nikiroo.be>
Wed, 17 Apr 2019 16:46:27 +0000 (18:46 +0200)
committerNiki Roo <niki@nikiroo.be>
Wed, 17 Apr 2019 16:46:27 +0000 (18:46 +0200)
src/be/nikiroo/fanfix/reader/ui/GuiReaderSearch.java

index 0046e89e4ad375671de88cae65f9d6eb85dc0fb8..c421ba6b006a43425aa735f6f1a0a4cc38ee95eb 100644 (file)
@@ -48,6 +48,7 @@ public class GuiReaderSearch extends JFrame {
        private int maxPage;
 
        private JPanel tagBars;
+       private List<JComboBox> combos;
 
        private JComboBox comboSupportTypes;
        private JTabbedPane searchTabs;
@@ -144,6 +145,8 @@ public class GuiReaderSearch extends JFrame {
        }
 
        private JPanel createByTagSearchPanel() {
+               combos = new ArrayList<JComboBox>();
+
                JPanel byTag = new JPanel();
                tagBars = new JPanel();
                tagBars.setLayout(new BoxLayout(tagBars, BoxLayout.Y_AXIS));
@@ -260,6 +263,8 @@ public class GuiReaderSearch extends JFrame {
                        final SearchableTag selected) {
                tags.add(0, null);
 
+               final int comboIndex = combos.size();
+
                final JComboBox combo = new JComboBox(
                                tags.toArray(new SearchableTag[] {}));
                combo.setSelectedItem(selected);
@@ -298,6 +303,11 @@ public class GuiReaderSearch extends JFrame {
                                final SearchableTag tag = (SearchableTag) combo
                                                .getSelectedItem();
                                if (tag != null) {
+                                       while (comboIndex + 1 < combos.size()) {
+                                               JComboBox combo = combos.remove(comboIndex + 1);
+                                               tagBars.remove(combo);
+                                       }
+
                                        addTagBar(tag, new Runnable() {
                                                @Override
                                                public void run() {