tooltips: more checks
authorNiki Roo <niki@nikiroo.be>
Fri, 1 May 2020 14:07:40 +0000 (16:07 +0200)
committerNiki Roo <niki@nikiroo.be>
Fri, 1 May 2020 14:07:40 +0000 (16:07 +0200)
src/be/nikiroo/fanfix_swing/gui/BooksPanel.java
src/be/nikiroo/fanfix_swing/gui/PropertiesFrame.java

index 7842e7d8d779965c9e9c72c6bf738673e5dc94e2..def758215ddccb8b2ea0455cd96beefe2a8cbaa1 100644 (file)
@@ -250,10 +250,10 @@ public class BooksPanel extends ListenerPanel {
                                        @Override
                                        public Window generateTooltip(BookInfo book,
                                                        boolean undecorated) {
-                                               if (book != null && book.getMeta() != null) {
+                                               MetaData meta = book == null ? null : book.getMeta();
+                                               if (meta != null) {
                                                        PropertiesFrame tooltip = new PropertiesFrame(
-                                                                       Instance.getInstance().getLibrary(),
-                                                                       book.getMeta());
+                                                                       Instance.getInstance().getLibrary(), meta);
                                                        tooltip.setUndecorated(undecorated);
                                                        return tooltip;
                                                }
index 9c00b5e0d3e52bc9cce5c7fa00133e659d821126..634555f49243e87649b4316478db64160bc98b40 100644 (file)
@@ -43,10 +43,12 @@ public class PropertiesFrame extends JDialog {
        public void setVisible(boolean b) {
                super.setVisible(b);
 
-               int titleBarHeight = Math
-                               .abs(getContentPane().getHeight() - getHeight());
+               if (b) {
+                       int titleBarHeight = Math
+                                       .abs(getContentPane().getHeight() - getHeight());
 
-               this.setSize(600, desc.getHeight() + titleBarHeight);
+                       this.setSize(600, desc.getHeight() + titleBarHeight);
+               }
        }
 
        @Override