Much better bootup process for GUI

- GUI is now centered and 1024x800 by default
- SplashScreen stays on top
- SplashScreen loads image faster
This commit is contained in:
Fabian Becker 2014-10-17 19:17:34 +02:00
parent a0ea08dfbe
commit 5a75df616b
2 changed files with 15 additions and 28 deletions

View File

@ -332,7 +332,7 @@ public class Main extends JFrame implements OptimizationStateListener {
/* Create main frame with GridBagLayout */
setTitle(EvAInfo.productName);
setLayout(new GridBagLayout());
setMinimumSize(new Dimension(800, 600));
setMinimumSize(new Dimension(1024, 800));
/* Creates the desktopPane for Plot/Text Output */
desktopPane = new JExtDesktopPane();
@ -358,13 +358,6 @@ public class Main extends JFrame implements OptimizationStateListener {
// TODO: use setIconImages (for better support of multiple icons when changing programs etc.)
setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
try {
Thread.sleep(200);
} catch (Exception e) {
System.out.println("Error" + e.getMessage());
}
LoggingPanel logPanel = new LoggingPanel();
logPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
@ -373,6 +366,8 @@ public class Main extends JFrame implements OptimizationStateListener {
createActions();
setSize(800, 600);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((int) ((screenSize.width - this.getWidth()) / 2), (int) ((screenSize.height - this.getHeight()) / 2.5));
/* Create a new ConfigurationPanel (left side) */
configurationPane = new JPanel(new GridBagLayout());
@ -476,15 +471,6 @@ public class Main extends JFrame implements OptimizationStateListener {
configurationPane.setVisible(true);
}
if (!(this.isVisible())) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((int) ((screenSize.width - this.getWidth()) / 2), (int) ((screenSize.height - this.getHeight()) / 2.5));
this.pack();
this.setSize(screenSize);
this.setVisible(true);
this.setVisible(true);
}
// if this message is omitted, the stupid scroll pane runs to
// the end of the last line which is ugly for a long class path
LOGGER.info("EvA2 ready");

View File

@ -7,13 +7,23 @@ import javax.swing.*;
import java.awt.*;
class SplashScreen extends Frame {
class SplashScreen extends JWindow {
private static final long serialVersionUID = 1281793825850423095L;
private String imgLocation;
public SplashScreen(String imgLoc) {
imgLocation = imgLoc;
BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader.getBytesFromResourceLocation(imgLocation, true);
ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes));
JLabel splashLabel = new JLabel(ii);
this.add(splashLabel);
this.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation(screenSize.width / 2 - this.getSize().width / 2, screenSize.height / 2 - this.getSize().height / 2);
setAlwaysOnTop(true);
}
/**
@ -26,16 +36,7 @@ class SplashScreen extends Frame {
* dispatch thread.
*/
public void splash() {
JWindow splashWindow = new JWindow(this);
BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader.getBytesFromResourceLocation(imgLocation, true);
ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes));
JLabel splashLabel = new JLabel(ii);
splashWindow.add(splashLabel);
splashWindow.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
splashWindow.setLocation(screenSize.width / 2 - splashWindow.getSize().width / 2, screenSize.height / 2 - splashWindow.getSize().height / 2);
splashWindow.setVisible(true);
this.setVisible(true);
}
}