From b0fedc980804fda6915cea12a188142e40eea147 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Tue, 21 Jun 2011 00:28:34 +0200 Subject: Fixed QuitWarningPanel event handling and disabling of UI git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@518 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/impl/View.java | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'src/jrummikub/view/impl/View.java') diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java index 5cc1a85..a9dc46f 100644 --- a/src/jrummikub/view/impl/View.java +++ b/src/jrummikub/view/impl/View.java @@ -86,6 +86,7 @@ public class View extends JFrame implements IView { private Event1 loadFileEvent = new Event1(); private Event1 saveEvent = new Event1(); private Event quitEvent = new Event(); + private JFrame quitWarningFrame; private static int even(double d) { return 2 * (int) (d / 2); @@ -296,7 +297,9 @@ public class View extends JFrame implements IView { addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { - quitEvent.emit(); + if (isEnabled()) { + quitEvent.emit(); + } } }); @@ -318,6 +321,10 @@ public class View extends JFrame implements IView { public void componentResized(ComponentEvent e) { rescale(); } + @Override + public void componentMoved(ComponentEvent e) { + quitWarningFrame.setLocationRelativeTo(View.this); + } }); setVisible(true); @@ -343,10 +350,15 @@ public class View extends JFrame implements IView { layeredPane.add(connectPanel); quitWarningPanel = new QuitWarningPanel(); - quitWarningPanel.setVisible(false); - layeredPane.setLayer(quitWarningPanel, JLayeredPane.POPUP_LAYER); - layeredPane.add(quitWarningPanel); - + quitWarningFrame = new JFrame(); + quitWarningFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + quitWarningFrame.add(quitWarningPanel); + quitWarningFrame.setAlwaysOnTop(true); + quitWarningFrame.setUndecorated(true); + + //layeredPane.setLayer(quitWarningPanel, JLayeredPane.POPUP_LAYER); + //layeredPane.add(quitWarningPanel); + //quitWarningPanel.setVisible(true); scorePanel = new ScorePanel(); scorePanel.setVisible(false); layeredPane.setLayer(scorePanel, JLayeredPane.POPUP_LAYER); @@ -446,6 +458,9 @@ public class View extends JFrame implements IView { rescaleSubpanel(loginPanel, 1 / 3.0, 1 / 3.0, 200, 200); rescaleSubpanel(gameListPanel, 1 / 2.0, 1 / 2.0, 475, 300); rescaleSubpanel(quitWarningPanel, 1 / 2.0, 1 / 6.0, 400, 150); + quitWarningPanel.setLocation(0, 0); + quitWarningFrame.setSize(quitWarningPanel.getSize()); + quitWarningFrame.setLocationRelativeTo(this); rescaleSubpanel(connectPanel, 1 / 2.0, 1 / 6.0, 400, 150); } @@ -508,7 +523,17 @@ public class View extends JFrame implements IView { } public void showQuitWarningPanel(boolean show) { - quitWarningPanel.setVisible(show); + quitWarningFrame.setLocationRelativeTo(this); + quitWarningFrame.setVisible(show); + + setEnabled(!show); + /*mainLayer.setEnabled(!show); + menuBar.setEnabled(!show); + settingsPanel.setEnabled(!show); + loginPanel.setEnabled(!show); + scorePanel.setEnabled(!show); + gameListPanel.setEnabled(!show); + connectPanel.setEnabled(!show);*/ } @Override -- cgit v1.2.3