fix crumbsbread refresh on display/hide
authorNiki Roo <niki@nikiroo.be>
Sat, 25 Apr 2020 11:04:28 +0000 (13:04 +0200)
committerNiki Roo <niki@nikiroo.be>
Sat, 25 Apr 2020 11:04:28 +0000 (13:04 +0200)
src/be/nikiroo/fanfix_swing/gui/MainFrame.java

index bc281937268e8067d3b3290e2e1307e2380de6f9..b43b6dda8b016ed0feaf0abb2790c46e1c6d3859 100644 (file)
@@ -13,6 +13,7 @@ import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
 import javax.swing.JSplitPane;
+import javax.swing.SwingUtilities;
 
 import be.nikiroo.fanfix_swing.gui.book.BookInfo;
 import be.nikiroo.fanfix_swing.gui.importer.ImporterFrame;
@@ -29,6 +30,7 @@ public class MainFrame extends JFrame {
        private ImporterFrame importer = new ImporterFrame();
        
        private List<JComponent> modeItems = new ArrayList<JComponent>();
+       private JSplitPane crumbsbreadPane;
        private boolean sidePanel;
        private boolean detailsPanel;
 
@@ -76,6 +78,18 @@ public class MainFrame extends JFrame {
 
                                books.loadData(sources, authors, tags);
                                details.setBook(book);
+                               
+                               if (crumbsbreadPane != null) {
+                                       SwingUtilities.invokeLater(new Runnable() {
+                                               @Override
+                                               public void run() {
+                                                       if (crumbsbreadPane != null) {
+                                                               crumbsbreadPane.revalidate();
+                                                               crumbsbreadPane.repaint();
+                                                       }       
+                                               }
+                                       });
+                               }
                        }
                });
                books.addActionListener(new ActionListener() {
@@ -219,6 +233,7 @@ public class MainFrame extends JFrame {
                for (JComponent comp : modeItems) {
                        this.remove(comp);
                }
+               crumbsbreadPane = null;
                modeItems.clear();
                
                if (sidePanel && !detailsPanel) {
@@ -237,13 +252,28 @@ public class MainFrame extends JFrame {
                        this.add(split);
                } else if (!sidePanel && detailsPanel) {
                        goBack.setVertical(true);
-                       JSplitPane other = split(goBack, details, false, 0.5, 1);
+                       JSplitPane other = split(goBack, details, false, 0.5, 0);
                        JSplitPane split = split(other, books, true, 0.5, 0);
+                       crumbsbreadPane = split;
                        modeItems.add(split);
                        this.add(split);
                }
-               
+
                this.revalidate();
                this.repaint();
+               
+               SwingUtilities.invokeLater(new Runnable() {
+                       @Override
+                       public void run() {
+                               browser.revalidate();
+                               browser.repaint();
+                               books.revalidate();
+                               books.repaint();
+                               details.revalidate();
+                               details.repaint();
+                               goBack.revalidate();
+                               goBack.repaint();
+                       }
+               });
        }
 }