From: Niki Roo Date: Thu, 28 Mar 2019 08:00:50 +0000 (+0100) Subject: full selection X-Git-Tag: fanfix-swing-0.0.1~12^2~183 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=574d709a282747a775b02fbaef01d26076cfec60;p=fanfix-swing.git full selection --- diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderFrame.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderFrame.java index 131ab050..e207023d 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderFrame.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderFrame.java @@ -4,7 +4,6 @@ import java.awt.BorderLayout; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.WindowEvent; import java.io.File; diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderMainPanel.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderMainPanel.java index 51922789..cfd1e947 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderMainPanel.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderMainPanel.java @@ -9,6 +9,8 @@ import java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; @@ -179,6 +181,13 @@ class GuiReaderMainPanel extends JPanel { books = new TreeMap(); + addFocusListener(new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + focus(); + } + }); + pane.setVisible(false); final Progress pg = new Progress(); final String typeF = type; @@ -197,12 +206,12 @@ class GuiReaderMainPanel extends JPanel { public void run() { if (status == Status.READY) { helper.createMenu(true); + pane.setVisible(true); if (typeF == null) { addBookPane(true, false); } else { addBookPane(typeF, true); } - pane.setVisible(true); } else { helper.createMenu(false); validate(); @@ -316,6 +325,8 @@ class GuiReaderMainPanel extends JPanel { openBook(book); } }); + + focus(); } /** @@ -649,6 +660,27 @@ class GuiReaderMainPanel extends JPanel { refreshBooks(); } }); + + focus(); + } + + /** + * Focus the first {@link GuiReaderGroup} we find. + */ + private void focus() { + GuiReaderGroup group = null; + Map books = this.books; + if (books.size() > 0) { + group = books.values().iterator().next(); + } + + if (group == null) { + group = bookPane; + } + + if (group != null) { + group.requestFocusInWindow(); + } } /**