From 7afbbed8e0cef27a47dd7599aadc5c2c814c7dea Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Wed, 8 Aug 2012 21:01:48 +0300 Subject: [PATCH] better positioning of dialog on the screen --- .../FileAssociationManager.java | 2 +- .../eu/svjatoslav/instantlauncher/Main.java | 2 +- .../svjatoslav/instantlauncher/MainFrame.java | 73 ++++++++-------- .../svjatoslav/instantlauncher/menu/Menu.java | 84 +++++++++---------- .../instantlauncher/menu/MultiLevelMenu.java | 4 +- 5 files changed, 80 insertions(+), 85 deletions(-) diff --git a/src/main/java/eu/svjatoslav/instantlauncher/FileAssociationManager.java b/src/main/java/eu/svjatoslav/instantlauncher/FileAssociationManager.java index 47572b8..5c3cc51 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/FileAssociationManager.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/FileAssociationManager.java @@ -70,7 +70,7 @@ public class FileAssociationManager { InstantLauncher.exitProgram(); } catch (final IOException e) { - ExceptionDialog.showException(e); + new ExceptionDialog(e); } return true; diff --git a/src/main/java/eu/svjatoslav/instantlauncher/Main.java b/src/main/java/eu/svjatoslav/instantlauncher/Main.java index acab4e3..aede86b 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/Main.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/Main.java @@ -10,7 +10,7 @@ public class Main { final InstantLauncher instantLauncher = new InstantLauncher(); instantLauncher.run(); } catch (final Exception e) { - ExceptionDialog.showException(e); + new ExceptionDialog(e); } } diff --git a/src/main/java/eu/svjatoslav/instantlauncher/MainFrame.java b/src/main/java/eu/svjatoslav/instantlauncher/MainFrame.java index 8e3dd3a..cdd351c 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/MainFrame.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/MainFrame.java @@ -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) { + } + + } + } diff --git a/src/main/java/eu/svjatoslav/instantlauncher/menu/Menu.java b/src/main/java/eu/svjatoslav/instantlauncher/menu/Menu.java index f14caef..a99c7c0 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/menu/Menu.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/menu/Menu.java @@ -48,46 +48,6 @@ public class Menu { buildContentPanel(directory); }; - /** - *
-     * Assign specific colors to:
-     *    Directory
-     *    Executable file
-     *    Non executable file
-     * 
- */ - 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; } + /** + *
+     * Assign specific colors to:
+     *    Directory
+     *    Executable file
+     *    Non executable file
+     * 
+ */ + 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); } } diff --git a/src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java b/src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java index fa200da..9485528 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java @@ -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()); -- 2.20.1