Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Support for opening on active monitor when multiple monitors attached.
  • Loading branch information
C4J committed Jun 8, 2024
1 parent 1720348 commit 91df907
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 84 deletions.
Binary file modified b6/commander4j.jar
Binary file not shown.
19 changes: 14 additions & 5 deletions b6/src/com/commander4j/cfg/JFrameHostAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
*/

import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
Expand Down Expand Up @@ -997,7 +998,7 @@ public void actionPerformed(ActionEvent evt)
public void actionPerformed(ActionEvent evt)
{
logger.debug("JFrameHostAdmin closed");
dispose();
System.exit(0);
}
});
}
Expand Down Expand Up @@ -2472,8 +2473,16 @@ public void actionPerformed(ActionEvent e) {

setHostsFilename(System.getProperty("user.dir") + File.separator + "xml" + File.separator + "hosts" + File.separator + "hosts.xml");
setIconImage(Common.imageIconloader.getImageIcon16x16(Common.image_osx_setup4j).getImage());
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screenSize.width - getSize().width) / 2, (screenSize.height - getSize().height) / 2);

GraphicsDevice gd = JUtility.getGraphicsDevice();

GraphicsConfiguration gc = gd.getDefaultConfiguration();

Rectangle screenBounds = gc.getBounds();

setBounds(screenBounds.x + ((screenBounds.width - JFrameHostAdmin.this.getWidth()) / 2), screenBounds.y + ((screenBounds.height - JFrameHostAdmin.this.getHeight()) / 2), JFrameHostAdmin.this.getWidth(), JFrameHostAdmin.this.getHeight());

setVisible(true);

}
catch (Exception e)
Expand Down
19 changes: 14 additions & 5 deletions b6/src/com/commander4j/clone/JFrameCloneDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
*/

import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;
Expand Down Expand Up @@ -149,8 +150,16 @@ public JFrameCloneDB()
initGUI();

setIconImage(Common.imageIconloader.getImageIcon16x16(Common.image_osx_clone4j).getImage());
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screenSize.width - getSize().width) / 2, (screenSize.height - getSize().height) / 2);

GraphicsDevice gd = JUtility.getGraphicsDevice();

GraphicsConfiguration gc = gd.getDefaultConfiguration();

Rectangle screenBounds = gc.getBounds();

setBounds(screenBounds.x + ((screenBounds.width - JFrameCloneDB.this.getWidth()) / 2), screenBounds.y + ((screenBounds.height - JFrameCloneDB.this.getHeight()) / 2), JFrameCloneDB.this.getWidth(), JFrameCloneDB.this.getHeight());

setVisible(true);

getHosts();

Expand Down Expand Up @@ -570,7 +579,7 @@ public void actionPerformed(ActionEvent evt)
public void actionPerformed(ActionEvent evt)
{
logger.debug("JFrameCloneDB closed");
dispose();
System.exit(0);;
}
});

Expand Down
45 changes: 12 additions & 33 deletions b6/src/com/commander4j/sys/JDialogChangePassword.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,9 @@
package com.commander4j.sys;

/**
* @author David Garratt
*
* Project Name : Commander4j
*
* Filename : JDialogChangePassword.java
*
* Package Name : com.commander4j.sys
*
* License : GNU General Public License
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* http://www.commander4j.com/website/license.html.
*
*/


import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
Expand Down Expand Up @@ -138,10 +111,16 @@ public JDialogChangePassword(Frame parent, String DefaultUserName, String Defaul

getRootPane().setDefaultButton(btn_change);

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

this.setSize(304, 224);
setLocation((screenSize.width - screenWidth) / 2, (screenSize.height - screenHeight) / 2);

GraphicsDevice gd = JUtility.getGraphicsDevice();

GraphicsConfiguration gc = gd.getDefaultConfiguration();

Rectangle screenBounds = gc.getBounds();

setBounds(screenBounds.x + ((screenBounds.width - JDialogChangePassword.this.getWidth()) / 2), screenBounds.y + ((screenBounds.height - JDialogChangePassword.this.getHeight()) / 2), JDialogChangePassword.this.getWidth(), JDialogChangePassword.this.getHeight());

setResizable(false);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
getContentPane().setLayout(null);
Expand Down
21 changes: 12 additions & 9 deletions b6/src/com/commander4j/sys/JDialogHosts.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Dimension;
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.MouseAdapter;
Expand All @@ -47,12 +47,13 @@
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;

import com.commander4j.app.JVersion;
import com.commander4j.gui.JButton4j;
import com.commander4j.gui.JList4j;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import com.commander4j.util.JUtility;

public class JDialogHosts extends JDialog
{
Expand All @@ -77,10 +78,13 @@ public JDialogHosts(JFrame frame)

populateList("");

Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle window = getBounds();
setLocation((screen.width - window.width) / 2, (screen.height - window.height) / 2);
GraphicsDevice gd = JUtility.getGraphicsDevice();

GraphicsConfiguration gc = gd.getDefaultConfiguration();

Rectangle screenBounds = gc.getBounds();

setBounds(screenBounds.x + ((screenBounds.width - JDialogHosts.this.getWidth()) / 2), screenBounds.y + ((screenBounds.height - JDialogHosts.this.getHeight()) / 2), JDialogHosts.this.getWidth(), JDialogHosts.this.getHeight());
Common.selectedHostID = "Cancel";
setResizable(false);
setModal(true);
Expand All @@ -94,7 +98,6 @@ public void run() {
}
});


}

private void populateList(String defaultitem) {
Expand Down Expand Up @@ -186,7 +189,7 @@ public void actionPerformed(ActionEvent evt) {
jButtonClose.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Common.selectedHostID = "Cancel";
dispose();
System.exit(0);
}
});
}
Expand Down
18 changes: 11 additions & 7 deletions b6/src/com/commander4j/sys/JDialogHosts2.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
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.MouseAdapter;
Expand All @@ -48,12 +48,13 @@
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import javax.swing.border.EtchedBorder;

import com.commander4j.app.JVersion;
import com.commander4j.gui.JButton4j;
import com.commander4j.gui.JImagePanel4j;
import com.commander4j.gui.JList4j;
import javax.swing.border.EtchedBorder;
import com.commander4j.util.JUtility;

public class JDialogHosts2 extends JDialog
{
Expand All @@ -75,10 +76,13 @@ public JDialogHosts2(JFrame frame)

populateList("");

Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle window = getBounds();
setLocation((screen.width - window.width) / 2, (screen.height - window.height) / 2);
GraphicsDevice gd = JUtility.getGraphicsDevice();

GraphicsConfiguration gc = gd.getDefaultConfiguration();

Rectangle screenBounds = gc.getBounds();

setBounds(screenBounds.x + ((screenBounds.width - JDialogHosts2.this.getWidth()) / 2), screenBounds.y + ((screenBounds.height - JDialogHosts2.this.getHeight()) / 2), JDialogHosts2.this.getWidth(), JDialogHosts2.this.getHeight());
Common.selectedHostID = "Cancel";

setResizable(false);
Expand Down Expand Up @@ -207,7 +211,7 @@ public void actionPerformed(ActionEvent evt)
public void actionPerformed(ActionEvent evt)
{
Common.selectedHostID = "Cancel";
dispose();
System.exit(0);
}
});
}
Expand Down
19 changes: 14 additions & 5 deletions b6/src/com/commander4j/sys/JDialogLogin.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
*/

import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
Expand Down Expand Up @@ -143,10 +144,18 @@ public void run() {
}
});

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

this.setSize(277, 192);
setLocation((screenSize.width - screenWidth) / 2, (screenSize.height - screenHeight) / 2);
this.setSize(277, 192);

GraphicsDevice gd = JUtility.getGraphicsDevice();

GraphicsConfiguration gc = gd.getDefaultConfiguration();

Rectangle screenBounds = gc.getBounds();

setBounds(screenBounds.x + ((screenBounds.width - JDialogLogin.this.getWidth()) / 2), screenBounds.y + ((screenBounds.height - JDialogLogin.this.getHeight()) / 2), JDialogLogin.this.getWidth(), JDialogLogin.this.getHeight());


setResizable(false);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setVisible(true);
Expand Down
15 changes: 11 additions & 4 deletions b6/src/com/commander4j/sys/JFrameMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Frame;
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.ComponentEvent;
Expand Down Expand Up @@ -63,6 +64,7 @@
import com.commander4j.db.JDBModule;
import com.commander4j.gui.JDesktopPane4j;
import com.commander4j.util.JHelp;
import com.commander4j.util.JUtility;

/**
* JFrameMain is the main desktop for the Swing application as shown below.
Expand Down Expand Up @@ -177,10 +179,15 @@ public JFrameMain()
{

super(Common.appDisplayName+" " + JVersion.getProgramVersion() + " (" + Common.hostList.getHost(Common.selectedHostID).getSiteDescription() + ")");

GraphicsDevice gd = JUtility.getGraphicsDevice();

GraphicsConfiguration gc = gd.getDefaultConfiguration();

Rectangle screenBounds = gc.getBounds();

setBounds(screenBounds.x, screenBounds.y , screenBounds.width, screenBounds.height-50);

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setSize(screenSize.width, screenSize.height - 50);
setLocation(0, 0);
setResizable(true);

setExtendedState(Frame.MAXIMIZED_HORIZ);
Expand Down
13 changes: 5 additions & 8 deletions b6/src/com/commander4j/sys/JWindowProgress.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;

import javax.swing.JProgressBar;
import javax.swing.JWindow;


public class JWindowProgress extends JWindow
{
private static final long serialVersionUID = 1;
Expand All @@ -52,19 +50,19 @@ public class JWindowProgress extends JWindow
private JProgressBar progress = new JProgressBar();


public JWindowProgress(Dimension imageSize)
public JWindowProgress(Rectangle splashBounds)
{

imageWidth = imageSize.width;
int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;
int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;

rect = new Rectangle((screenWidth / 2 - (imageWidth/2)), ((screenHeight /2)+10), imageWidth, progressHeight);
rect = new Rectangle(splashBounds.x, splashBounds.y+splashBounds.height+10, splashBounds.width, progressHeight);


setBounds(rect);

getContentPane().setLayout(new BorderLayout(0, 0));

getContentPane().add(progress,BorderLayout.PAGE_END);

progress.setBorderPainted(true);
progress.setPreferredSize(new Dimension(imageWidth, progressHeight));
progress.setMinimumSize(new Dimension(imageWidth, progressHeight));
Expand All @@ -74,7 +72,6 @@ public JWindowProgress(Dimension imageSize)
progress.setBackground(Color.WHITE);
progress.setForeground(Color.BLUE);


setVisible(true);
}

Expand Down
Loading

0 comments on commit 91df907

Please sign in to comment.