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;
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;
books = new TreeMap<String, GuiReaderGroup>();
+ addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ focus();
+ }
+ });
+
pane.setVisible(false);
final Progress pg = new Progress();
final String typeF = type;
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();
openBook(book);
}
});
+
+ focus();
}
/**
refreshBooks();
}
});
+
+ focus();
+ }
+
+ /**
+ * Focus the first {@link GuiReaderGroup} we find.
+ */
+ private void focus() {
+ GuiReaderGroup group = null;
+ Map<String, GuiReaderGroup> books = this.books;
+ if (books.size() > 0) {
+ group = books.values().iterator().next();
+ }
+
+ if (group == null) {
+ group = bookPane;
+ }
+
+ if (group != null) {
+ group.requestFocusInWindow();
+ }
}
/**