better positioning of dialog on the screen
authorSvjatoslav Agejenko <n0@big-laptop.(none)>
Wed, 8 Aug 2012 18:01:48 +0000 (21:01 +0300)
committerSvjatoslav Agejenko <n0@big-laptop.(none)>
Wed, 8 Aug 2012 18:01:48 +0000 (21:01 +0300)
src/main/java/eu/svjatoslav/instantlauncher/FileAssociationManager.java
src/main/java/eu/svjatoslav/instantlauncher/Main.java
src/main/java/eu/svjatoslav/instantlauncher/MainFrame.java
src/main/java/eu/svjatoslav/instantlauncher/menu/Menu.java
src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java

index 47572b8..5c3cc51 100755 (executable)
@@ -70,7 +70,7 @@ public class FileAssociationManager {
                 InstantLauncher.exitProgram();
 
             } catch (final IOException e) {
-                ExceptionDialog.showException(e);
+                new ExceptionDialog(e);
             }
 
             return true;
index acab4e3..aede86b 100755 (executable)
@@ -10,7 +10,7 @@ public class Main {
             final InstantLauncher instantLauncher = new InstantLauncher();
             instantLauncher.run();
         } catch (final Exception e) {
-            ExceptionDialog.showException(e);
+            new ExceptionDialog(e);
         }
     }
 
index 8e3dd3a..cdd351c 100755 (executable)
@@ -2,7 +2,6 @@ package eu.svjatoslav.instantlauncher;
 
 import java.awt.BorderLayout;
 import java.awt.Dimension;
-import java.awt.Point;
 import java.awt.event.WindowEvent;
 import java.awt.event.WindowListener;
 
@@ -12,45 +11,11 @@ import eu.svjatoslav.instantlauncher.menu.MultiLevelMenu;
 
 public class MainFrame {
 
-    public static class FrameWindowListener implements WindowListener {
-
-        @Override
-        public void windowActivated(final WindowEvent e) {
-        }
-
-        @Override
-        public void windowClosed(final WindowEvent e) {
-        }
-
-        @Override
-        public void windowClosing(final WindowEvent e) {
-            InstantLauncher.exitProgram();
-        }
-
-        @Override
-        public void windowDeactivated(final WindowEvent e) {
-        }
-
-        @Override
-        public void windowDeiconified(final WindowEvent e) {
-        }
-
-        @Override
-        public void windowIconified(final WindowEvent e) {
-        }
-
-        @Override
-        public void windowOpened(final WindowEvent e) {
-        }
-
-    }
-
     private JFrame frame;
 
     private boolean isShowing;
 
     public static final Dimension CONTENT_PANEL_SIZE = new Dimension(1100, 850);
-    public static final Point INITIAL_LOCATION = new Point(100, 30);
 
     private final InstantLauncher instantLauncher;
 
@@ -73,20 +38,50 @@ public class MainFrame {
 
             buildContentPane();
 
-            frame.setSize(CONTENT_PANEL_SIZE);
-            frame.setVisible(true);
-            frame.setLocation(INITIAL_LOCATION);
-
             // registor window listener
             final FrameWindowListener windowListener = new FrameWindowListener();
             frame.addWindowListener(windowListener);
 
             // maximize window
             frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
+            frame.setVisible(true);
 
             isShowing = true;
         }
 
     }
 
+    public static class FrameWindowListener implements WindowListener {
+
+        @Override
+        public void windowActivated(final WindowEvent e) {
+        }
+
+        @Override
+        public void windowClosed(final WindowEvent e) {
+        }
+
+        @Override
+        public void windowClosing(final WindowEvent e) {
+            InstantLauncher.exitProgram();
+        }
+
+        @Override
+        public void windowDeactivated(final WindowEvent e) {
+        }
+
+        @Override
+        public void windowDeiconified(final WindowEvent e) {
+        }
+
+        @Override
+        public void windowIconified(final WindowEvent e) {
+        }
+
+        @Override
+        public void windowOpened(final WindowEvent e) {
+        }
+
+    }
+
 }
index f14caef..a99c7c0 100755 (executable)
@@ -48,46 +48,6 @@ public class Menu {
         buildContentPanel(directory);
     };
 
-    /**
-     * <pre>
-     * Assign specific colors to:
-     *    Directory
-     *    Executable file
-     *    Non executable file
-     * </pre>
-     */
-    public static Color getFileColor(final File file, final boolean selected) {
-        if (file.isDirectory()) {
-            if (selected) {
-                return BUTTON_BG_DIRECTORY_SELECTED;
-            } else {
-                return BUTTON_BG_DIRECTORY;
-            }
-        }
-
-        if (file.isFile()) {
-            if (file.canExecute()) {
-                if (selected) {
-                    return BUTTON_BG_EXECUTABLE_FILE_SELECTED;
-                } else {
-                    return BUTTON_BG_EXECUTABLE_FILE;
-                }
-            } else {
-                if (selected) {
-                    return BUTTON_BG_NONEXECUTABLE_FILE_SELECTED;
-                } else {
-                    return BUTTON_BG_NONEXECUTABLE_FILE;
-                }
-            }
-        }
-
-        if (selected) {
-            return BUTTON_BG_LINK_SELECTED;
-        } else {
-            return BUTTON_BG_LINK;
-        }
-    }
-
     public void addMenuListener(final MenuListener menuListener) {
         menuListeners.add(menuListener);
     }
@@ -184,6 +144,46 @@ public class Menu {
         this.selectedFile = selectedFile;
     }
 
+    /**
+     * <pre>
+     * Assign specific colors to:
+     *    Directory
+     *    Executable file
+     *    Non executable file
+     * </pre>
+     */
+    public static Color getFileColor(final File file, final boolean selected) {
+        if (file.isDirectory()) {
+            if (selected) {
+                return BUTTON_BG_DIRECTORY_SELECTED;
+            } else {
+                return BUTTON_BG_DIRECTORY;
+            }
+        }
+
+        if (file.isFile()) {
+            if (file.canExecute()) {
+                if (selected) {
+                    return BUTTON_BG_EXECUTABLE_FILE_SELECTED;
+                } else {
+                    return BUTTON_BG_EXECUTABLE_FILE;
+                }
+            } else {
+                if (selected) {
+                    return BUTTON_BG_NONEXECUTABLE_FILE_SELECTED;
+                } else {
+                    return BUTTON_BG_NONEXECUTABLE_FILE;
+                }
+            }
+        }
+
+        if (selected) {
+            return BUTTON_BG_LINK_SELECTED;
+        } else {
+            return BUTTON_BG_LINK;
+        }
+    }
+
     public static class ButtonMouseListener implements MouseListener {
 
         JButton parentButton;
@@ -207,7 +207,7 @@ public class Menu {
                     parentMenu.notifyAlternativeEventListeners(file);
                 }
             } catch (final Exception ex) {
-                ExceptionDialog.showException(ex);
+                new ExceptionDialog(ex);
             }
         }
 
@@ -228,7 +228,7 @@ public class Menu {
                     }
                 }
             } catch (final Exception ex) {
-                ExceptionDialog.showException(ex);
+                new ExceptionDialog(ex);
             }
         }
 
index fa200da..9485528 100755 (executable)
@@ -120,7 +120,7 @@ public class MultiLevelMenu implements MenuListener {
                     Runtime.getRuntime().exec(c);
                     InstantLauncher.exitProgram();
                 } catch (final IOException e) {
-                    ExceptionDialog.showException(e);
+                    new ExceptionDialog(e);
                 }
 
             } else {
@@ -147,7 +147,7 @@ public class MultiLevelMenu implements MenuListener {
                 InstantLauncher.exitProgram();
 
             } catch (final IOException e) {
-                ExceptionDialog.showException(e);
+                new ExceptionDialog(e);
             }
         } else {
             chosenFile.setExecutable(!chosenFile.canExecute());