diff --git a/b6Middleware/b6middleware.install4j b/b6Middleware/b6middleware.install4j index 61c8dd5..0baa3ba 100644 --- a/b6Middleware/b6middleware.install4j +++ b/b6Middleware/b6middleware.install4j @@ -1,7 +1,7 @@ - + - + diff --git a/b6Middleware/c4jMiddleware.jar b/b6Middleware/c4jMiddleware.jar index 60f89e5..e475721 100644 Binary files a/b6Middleware/c4jMiddleware.jar and b/b6Middleware/c4jMiddleware.jar differ diff --git a/b6Middleware/src/com/commander4j/mw/StartGUI.java b/b6Middleware/src/com/commander4j/mw/StartGUI.java index 213320d..94eddb0 100644 --- a/b6Middleware/src/com/commander4j/mw/StartGUI.java +++ b/b6Middleware/src/com/commander4j/mw/StartGUI.java @@ -4,8 +4,9 @@ import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Font; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; import java.awt.Rectangle; -import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; @@ -21,6 +22,7 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ListModel; +import javax.swing.ListSelectionModel; import javax.swing.SwingConstants; import javax.swing.border.BevelBorder; import javax.swing.border.EmptyBorder; @@ -29,7 +31,6 @@ import com.commander4j.gui.JList4j; import com.commander4j.sys.Common; import com.commander4j.util.Utility; -import javax.swing.ListSelectionModel; public class StartGUI extends JFrame { @@ -106,8 +107,17 @@ public void run() { try { - StartGUI.frame = new StartGUI(); - StartGUI.frame.setVisible(true); + frame = new StartGUI(); + + GraphicsDevice gd = Utility.getGraphicsDevice(); + + GraphicsConfiguration gc = gd.getDefaultConfiguration(); + + Rectangle screenBounds = gc.getBounds(); + + frame.setBounds(screenBounds.x + ((screenBounds.width - frame.getWidth()) / 2), screenBounds.y + ((screenBounds.height - frame.getHeight()) / 2), frame.getWidth(), frame.getHeight()); + + frame.setVisible(true); } catch (Exception e) { @@ -126,16 +136,15 @@ public StartGUI() setTitle("Commander4j Middleware" + " " + StartMain.version); util.initLogging(""); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - setBounds(100, 100, 1319, 765); + + setSize(1319, 765); + contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); addWindowListener(new WindowListener()); - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - Rectangle window = getBounds(); - setLocation((screen.width - window.width) / 2, (screen.height - window.height) / 2); JButton btnClose = new JButton(Common.icon_close); btnClose.setFont(new Font("Dialog", Font.PLAIN, 12)); diff --git a/b6Middleware/src/com/commander4j/mw/StartMain.java b/b6Middleware/src/com/commander4j/mw/StartMain.java index 87d5c06..ea7ecff 100644 --- a/b6Middleware/src/com/commander4j/mw/StartMain.java +++ b/b6Middleware/src/com/commander4j/mw/StartMain.java @@ -16,7 +16,7 @@ public class StartMain Logger logger = org.apache.logging.log4j.LogManager.getLogger((StartMain.class)); public MiddlewareConfig cfg; - public static String version = "5.24"; + public static String version = "5.25"; Boolean running = false; LogArchiveThread archiveLog; StatusThread statusthread; diff --git a/b6Middleware/src/com/commander4j/util/Utility.java b/b6Middleware/src/com/commander4j/util/Utility.java index baadcca..19887a9 100644 --- a/b6Middleware/src/com/commander4j/util/Utility.java +++ b/b6Middleware/src/com/commander4j/util/Utility.java @@ -1,5 +1,11 @@ package com.commander4j.util; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.HeadlessException; +import java.awt.MouseInfo; +import java.awt.Point; +import java.awt.Rectangle; import java.io.File; import java.io.StringWriter; import java.net.InetAddress; @@ -23,6 +29,58 @@ public class Utility { + public static GraphicsDevice getGraphicsDevice() + { + GraphicsDevice result; + + Point mouseLocation = MouseInfo.getPointerInfo().getLocation(); + + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + + GraphicsDevice[] devices; + + try + { + devices = ge.getScreenDevices(); + + GraphicsDevice currentDevice = null; + + for (GraphicsDevice device : devices) + { + Rectangle bounds = device.getDefaultConfiguration().getBounds(); + if (bounds.contains(mouseLocation)) + { + currentDevice = device; + break; + } + } + + GraphicsDevice[] gs = ge.getScreenDevices(); + + String defaultID = currentDevice.getIDstring(); + + int monitorIndex = 0; + + for (int x = 0; x < gs.length; x++) + { + if (gs[x].getIDstring().equals(defaultID)) + { + monitorIndex = x; + break; + } + } + + result = gs[monitorIndex]; + } + catch (HeadlessException ex) + { + result = null; + } + + return result; + } + + public Timestamp getTimeStampFromISOString(String isoString) { Timestamp result;