/******************************************************************************* | |
* Copyright (c) 2020 RBEI and others. | |
* | |
* This program and the accompanying materials | |
* are made available under the terms of the Eclipse Public License v. 2.0 | |
* which accompanies this distribution, and is available at | |
* https://www.eclipse.org/legal/epl-2.0/ | |
* | |
* SPDX-License-Identifier: EPL-2.0 | |
* | |
* Contributors: | |
* Adhith Gopal - Initial contribution and API | |
*******************************************************************************/ | |
package org.eclipse.blockchain.ui.util; | |
import org.eclipse.swt.graphics.Rectangle; | |
import org.eclipse.swt.widgets.Display; | |
import org.eclipse.swt.widgets.Shell; | |
/** | |
* A general UI helper class | |
*/ | |
public class UIUtilities { | |
private UIUtilities() { | |
} | |
/** | |
* @param display | |
* - | |
* @param parent | |
* - | |
*/ | |
public static void moveShellToCenterOfScreen(final Display display, | |
final Shell parent) { | |
Rectangle monitorBound = display.getPrimaryMonitor().getBounds(); | |
Rectangle shellBounds = parent.getBounds(); | |
int x = monitorBound.x + ((monitorBound.width - shellBounds.width) / 2); | |
int y = monitorBound.y | |
+ ((monitorBound.height - shellBounds.height) / 2); | |
parent.setLocation(x, y); | |
} | |
} |