From 16ea1260d3d8a49fe1cd7d1a20e78c0e13628401 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Fri, 1 May 2020 16:07:40 +0200 Subject: [PATCH] tooltips: more checks --- src/be/nikiroo/fanfix_swing/gui/BooksPanel.java | 6 +++--- src/be/nikiroo/fanfix_swing/gui/PropertiesFrame.java | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/be/nikiroo/fanfix_swing/gui/BooksPanel.java b/src/be/nikiroo/fanfix_swing/gui/BooksPanel.java index 7842e7d8..def75821 100644 --- a/src/be/nikiroo/fanfix_swing/gui/BooksPanel.java +++ b/src/be/nikiroo/fanfix_swing/gui/BooksPanel.java @@ -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; } diff --git a/src/be/nikiroo/fanfix_swing/gui/PropertiesFrame.java b/src/be/nikiroo/fanfix_swing/gui/PropertiesFrame.java index 9c00b5e0..634555f4 100644 --- a/src/be/nikiroo/fanfix_swing/gui/PropertiesFrame.java +++ b/src/be/nikiroo/fanfix_swing/gui/PropertiesFrame.java @@ -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 -- 2.27.0