From 842ce2be4c095a002c275d9ec30788c99df5fb6a Mon Sep 17 00:00:00 2001 From: phib Date: Wed, 24 Mar 2010 01:55:27 +0000 Subject: [PATCH] Fix CFrame positioning on multiple monitors when opened from main menu. Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2975622 --- client/src/org/compiere/apps/AEnv.java | 5 +++-- .../src/org/compiere/apps/AMenuStartItem.java | 6 +++--- client/src/org/compiere/apps/AWindow.java | 13 ++++++++++++- client/src/org/compiere/apps/ProcessDialog.java | 17 ++++++++++++++++- .../src/org/compiere/apps/form/FormFrame.java | 14 +++++++++++++- client/src/org/compiere/print/Viewer.java | 15 +++++++++++++-- 6 files changed, 60 insertions(+), 10 deletions(-) diff --git a/client/src/org/compiere/apps/AEnv.java b/client/src/org/compiere/apps/AEnv.java index c638588484..db3710b716 100644 --- a/client/src/org/compiere/apps/AEnv.java +++ b/client/src/org/compiere/apps/AEnv.java @@ -145,9 +145,10 @@ public final class AEnv public static void positionScreen (Window window, int position) { window.pack(); - Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize(); // take into account task bar and other adornments GraphicsConfiguration config = window.getGraphicsConfiguration(); + Rectangle bounds = config.getBounds(); + Dimension sSize = bounds.getSize(); Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(config); sSize.width -= (insets.left + insets.right); sSize.height -= (insets.top + insets.bottom); @@ -201,7 +202,7 @@ public final class AEnv y = (sSize.height - wSize.height); } // - window.setLocation(x + insets.left, y + insets.top); + window.setLocation(bounds.x + x + insets.left, bounds.y + y + insets.top); } // positionScreen /** diff --git a/client/src/org/compiere/apps/AMenuStartItem.java b/client/src/org/compiere/apps/AMenuStartItem.java index 778774f6fa..7909f3de42 100644 --- a/client/src/org/compiere/apps/AMenuStartItem.java +++ b/client/src/org/compiere/apps/AMenuStartItem.java @@ -241,7 +241,7 @@ public class AMenuStartItem extends Thread implements ActionListener } SwingUtilities.invokeLater(m_updatePB); // 1 - frame = new AWindow(); + frame = new AWindow(m_menu.getGraphicsConfiguration()); boolean OK = false; if (AD_Workbench_ID != 0) OK = frame.initWorkbench(AD_Workbench_ID); @@ -284,7 +284,7 @@ public class AMenuStartItem extends Thread implements ActionListener if (IsSOTrx != null && IsSOTrx.equals("Y")) isSO = true; m_timer.stop(); - ProcessDialog pd = new ProcessDialog (AD_Process_ID, isSO); + ProcessDialog pd = new ProcessDialog (m_menu.getGraphicsConfiguration(), AD_Process_ID, isSO); if (!pd.init()) return; m_timer.start(); @@ -333,7 +333,7 @@ public class AMenuStartItem extends Thread implements ActionListener return; } } - ff = new FormFrame(); + ff = new FormFrame(m_menu.getGraphicsConfiguration()); SwingUtilities.invokeLater(m_updatePB); // 1 boolean ok = ff.openForm(AD_Form_ID); if (!ok) { diff --git a/client/src/org/compiere/apps/AWindow.java b/client/src/org/compiere/apps/AWindow.java index 4f0efdf08a..2539eeaf81 100644 --- a/client/src/org/compiere/apps/AWindow.java +++ b/client/src/org/compiere/apps/AWindow.java @@ -17,6 +17,7 @@ package org.compiere.apps; import java.awt.BorderLayout; +import java.awt.GraphicsConfiguration; import java.awt.Image; import java.awt.event.WindowEvent; @@ -44,11 +45,21 @@ public class AWindow extends CFrame private static final long serialVersionUID = -1925388774073536474L; /** + * @deprecated * Standard Constructor - requires initWindow */ public AWindow () { - super(); + this(null); + } // AWindow + + /** + * Standard Constructor - requires initWindow + * @param gc + */ + public AWindow (GraphicsConfiguration gc) + { + super(gc); // Set UI Components this.setIconImage(Env.getImage("mWindow.gif")); this.getContentPane().add(m_APanel, BorderLayout.CENTER); diff --git a/client/src/org/compiere/apps/ProcessDialog.java b/client/src/org/compiere/apps/ProcessDialog.java index e9e10082d4..907dfcbd10 100644 --- a/client/src/org/compiere/apps/ProcessDialog.java +++ b/client/src/org/compiere/apps/ProcessDialog.java @@ -21,6 +21,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; +import java.awt.GraphicsConfiguration; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.PreparedStatement; @@ -74,6 +75,7 @@ public class ProcessDialog extends CFrame private static final long serialVersionUID = 790447068287846414L; /** + * @deprecated * Dialog to start Process * * @param AD_Process_ID process @@ -81,7 +83,20 @@ public class ProcessDialog extends CFrame */ public ProcessDialog (int AD_Process_ID, boolean isSOTrx) { - super(); + this(null, AD_Process_ID, isSOTrx); + + } // ProcessDialog + + /** + * Dialog to start Process + * + * @param gc + * @param AD_Process_ID process + * @param isSOTrx is sales trx + */ + public ProcessDialog (GraphicsConfiguration gc, int AD_Process_ID, boolean isSOTrx) + { + super(gc); log.info("Process=" + AD_Process_ID + "; SOTrx=" + isSOTrx); enableEvents(AWTEvent.WINDOW_EVENT_MASK); m_AD_Process_ID = AD_Process_ID; diff --git a/client/src/org/compiere/apps/form/FormFrame.java b/client/src/org/compiere/apps/form/FormFrame.java index fa741e19e0..9933058690 100644 --- a/client/src/org/compiere/apps/form/FormFrame.java +++ b/client/src/org/compiere/apps/form/FormFrame.java @@ -18,6 +18,7 @@ package org.compiere.apps.form; import java.awt.Cursor; import java.awt.Event; +import java.awt.GraphicsConfiguration; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; @@ -65,12 +66,23 @@ public class FormFrame extends CFrame private static final long serialVersionUID = 2559005548469735515L; /** + * @deprecated * Create Form. * Need to call openForm */ public FormFrame () { - super(); + this(null); + } // FormFrame + + /** + * Create Form. + * Need to call openForm + * @param gc + */ + public FormFrame (GraphicsConfiguration gc) + { + super(gc); addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(java.awt.event.WindowEvent evt) diff --git a/client/src/org/compiere/print/Viewer.java b/client/src/org/compiere/print/Viewer.java index 7828e77485..eb4a9a174b 100644 --- a/client/src/org/compiere/print/Viewer.java +++ b/client/src/org/compiere/print/Viewer.java @@ -23,6 +23,7 @@ import java.awt.Component; import java.awt.Cursor; import java.awt.Dimension; import java.awt.Event; +import java.awt.GraphicsConfiguration; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.ActionEvent; @@ -130,14 +131,24 @@ public class Viewer extends CFrame */ private static final long serialVersionUID = 7306392362119021781L; - /** + * @deprecated * Viewer Constructor * @param re report engine */ public Viewer (ReportEngine re) { - super(); + this(null, re); + } + + /** + * Viewer Constructor + * @param gc + * @param re report engine + */ + public Viewer (GraphicsConfiguration gc, ReportEngine re) + { + super(gc); log.info(""); m_WindowNo = Env.createWindowNo(this); m_reportEngine = re;