本文整理匯總了Java中org.eclipse.swt.widgets.Shell.setLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java Shell.setLocation方法的具體用法?Java Shell.setLocation怎麽用?Java Shell.setLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.Shell
的用法示例。
在下文中一共展示了Shell.setLocation方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: StartupSplashShell
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
/**
* create the startup splash shell and display it
* @param display
*/
public StartupSplashShell(Display display){
shell = new Shell(display, SWT.NO_TRIM);
setupShell(); // place components in the main avoCADo shell
shell.setText("avoCADo");
shell.setBackgroundImage(ImageUtils.getIcon("./avoCADo-Splash.jpg", 360, 298));
shell.setSize(360, 298); //TODO: set intial size to last known size
Rectangle b = display.getBounds();
int xPos = Math.max(0, (b.width-360)/2);
int yPos = Math.max(0, (b.height-298)/2);
shell.setLocation(xPos, yPos);
shell.setImage(ImageUtils.getIcon("./avoCADo.png", 32, 32));
shell.open();
// handle events while the shell is not disposed
//while (!shell.isDisposed()) {
// if (!display.readAndDispatch())
// display.sleep();
//}
}
示例2: AboutAvoCADoGPLShell
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
/**
* create the startup splash shell and display it
* @param display
*/
public AboutAvoCADoGPLShell(Display display){
shell = new Shell(display, SWT.PRIMARY_MODAL);
setupShell(); // place components in the avoCADo license shell
shell.setText("avoCADo GPLv2");
shell.setSize(583, 350); //TODO: set initial size to last known size
Rectangle b = display.getBounds();
int xPos = Math.max(0, (b.width-583)/2);
int yPos = Math.max(0, (b.height-350)/2);
shell.setLocation(xPos, yPos);
shell.open();
// handle events while the shell is not disposed
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
示例3: MainAvoCADoShell
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
/**
* create the main avoCADo shell and display it
* @param display
*/
public MainAvoCADoShell(Display display){
shell = new Shell(display);
setupShell(); // place components in the main avoCADo shell
shell.setText("avoCADo");
shell.setSize(800, 600); //TODO: set intial size to last known size
shell.setMinimumSize(640, 480);
Rectangle b = display.getBounds();
int xPos = Math.max(0, (b.width-800)/2);
int yPos = Math.max(0, (b.height-600)/2);
shell.setLocation(xPos, yPos);
shell.setImage(ImageUtils.getIcon("./avoCADo.png", 32, 32));
shell.open();
AvoGlobal.intializeNewAvoCADoProject(); // initialize app to starting model/view.
StartupSplashShell.closeSplash();
// handle events while the shell is not disposed
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
示例4: setCenterinParent
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public static void setCenterinParent(Shell parentshell, Shell shell) {
int screenH = Toolkit.getDefaultToolkit().getScreenSize().height;
int screenW = Toolkit.getDefaultToolkit().getScreenSize().width;
int shellH = shell.getBounds().height;
int shellW = shell.getBounds().width;
// 如果窗口大小超過屏幕大小,調整為屏幕大小
if (shellH > screenH) {
shellH = screenH;
}
if (shellW > screenW) {
shellW = screenW;
}
int targetx = parentshell.getLocation().x + parentshell.getBounds().width / 2 - shell.getBounds().width / 2;
int targety = parentshell.getLocation().y + parentshell.getBounds().height / 2 - shell.getBounds().height / 2;
if (targetx + shellW > screenW) {
targetx = screenW - shellW;
}
if (targety + shellH > screenH) {
targety = screenH - shellH;
}
shell.setLocation(targetx, targety);
}
示例5: setLocation
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
/**
*
*/
protected void setLocation(final XCalendar popup) {
//
final Shell shell = popup.getShell();
final Display display = popup.getDisplay();
final Rectangle r1 = display.map(prevParent, null, prevBounds);
final Rectangle r2 = popup.getMonitor().getClientArea(); // Client area
//
final int margin = 2;
final Point size = shell.getSize();
int x = r1.x, y = r1.y + r1.height + margin;
if(y + size.y > r2.y + r2.height) y = r1.y - size.y - margin;
if(x < r2.x) x = r2.x; else if(x + size.x > r2.x + r2.width) x = r2.x + r2.width - size.x;
shell.setLocation(x, y);
}
示例6: center
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
/**
* Center the child shell within the parent shell window.
*/
public static void center(Shell parent, Shell child) {
int x = parent.getLocation().x +
(parent.getSize().x - child.getSize().x) / 2;
int y = parent.getLocation().y +
(parent.getSize().y - child.getSize().y) / 2;
if (x < 0) x = 0;
if (y < 0) y = 0;
child.setLocation(x,y);
}
示例7: setCenter
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public static void setCenter(Shell shell) {
int screenH = Toolkit.getDefaultToolkit().getScreenSize().height;
int screenW = Toolkit.getDefaultToolkit().getScreenSize().width;
int shellH = shell.getBounds().height;
int shellW = shell.getBounds().width;
if (shellH > screenH) {
shellH = screenH;
}
if (shellW > screenW) {
shellW = screenW;
}
shell.setLocation(((screenW - shellW) / 2), ((screenH - shellH) / 2));
}
示例8: center
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
private void center(Shell shell) {
Shell parent = (Shell) shell.getParent();
Rectangle bounds = parent.getBounds();
Point size = shell.getSize();
int x = bounds.x + bounds.width / 2 - size.x / 2;
int y = bounds.y + bounds.height / 2 - size.y / 2;
// System.err.println("ChoiceDialog: center: x=" + x + " y=" + y);
shell.setLocation(x, (y < 0) ? 0 : y);
}
示例9: main
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public static void main(String[] args) {
Shell shell = new Shell(new Display());
shell.setSize(1200, 500);
shell.setLayout(new GridLayout());
shell.setLocation(100, 150);
Figure root = new Figure();
root.setFont(shell.getFont());
// XYLayout layout = new XYLayout();
// root.setLayoutManager(layout);
org.eclipse.draw2d.GridLayout layout = new org.eclipse.draw2d.GridLayout(2,false);
layout.horizontalSpacing = 100;
root.setLayoutManager(layout);
Canvas canvas = new Canvas(shell, SWT.DOUBLE_BUFFERED);
canvas.setBackground(ColorConstants.white);
canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
createDiagram(root);
LightweightSystem lws = new LightweightSystem(canvas);
lws.setContents(root);
Display display = shell.getDisplay();
shell.open();
while (!shell.isDisposed()) {
while (!display.readAndDispatch()) {
display.sleep();
}
}
}
示例10: main
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public static void main(String[] args) {
Shell shell = new Shell(new Display());
shell.setSize(1200, 500);
shell.setLayout(new GridLayout());
shell.setLocation(100, 150);
Figure root = new Figure();
root.setFont(shell.getFont());
// XYLayout layout = new XYLayout();
// root.setLayoutManager(layout);
org.eclipse.draw2d.GridLayout layout = new org.eclipse.draw2d.GridLayout(2,false);
layout.horizontalSpacing = 100;
root.setLayoutManager(layout);
Canvas canvas = new Canvas(shell, SWT.DOUBLE_BUFFERED);
canvas.setBackground(ColorConstants.white);
canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
MatrixWidget widget = new MatrixWidget();
MockArray array = new MockArray("int[]", new int[]{1,2,3}, new int[]{4,5,6}, new int[]{7,8,9}, new int[]{10,11,12});
root.add(widget.createFigure(array));
LightweightSystem lws = new LightweightSystem(canvas);
lws.setContents(root);
Display display = shell.getDisplay();
shell.open();
while (!shell.isDisposed()) {
while (!display.readAndDispatch()) {
display.sleep();
}
}
}
示例11: launchXMLTextContainerWindow
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
/**
* Launches the component property editor window for Unknown components. It is used to display XML content of Unknown
* components on property window.
*
* @return XML content of component.
*/
public String launchXMLTextContainerWindow() {
try{
String xmlText = this.xmlText;
Shell shell = new Shell(Display.getDefault().getActiveShell(), SWT.WRAP | SWT.MAX | SWT.APPLICATION_MODAL);
shell.setLayout(new GridLayout(1, false));
shell.setText("XML Content");
shell.setSize(439, 432);
text = new Text(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
text.setEditable(false);
text.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 250, 250, 250));
if (this.xmlText != null) {
xmlText = xmlText.substring(xmlText.indexOf('\n') + 1);
xmlText = xmlText.substring(xmlText.indexOf('\n') + 1, xmlText.lastIndexOf('\n') - 13);
text.setText(xmlText);
} else
text.setText(Messages.EMPTY_XML_CONTENT);
GridData gd_text = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
gd_text.widthHint = 360;
gd_text.heightHint = 360;
text.setLayoutData(gd_text);
Monitor primary = shell.getDisplay().getPrimaryMonitor();
Rectangle bounds = primary.getBounds();
Rectangle rect = shell.getBounds();
int x = bounds.x + (bounds.width - rect.width) / 2;
int y = bounds.y + (bounds.height - rect.height) / 2;
shell.setLocation(x, y);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!shell.getDisplay().readAndDispatch()) {
shell.getDisplay().sleep();
}
}
}catch(Exception e)
{
LOGGER.error("Error occurred while creating XML text container widget", e);
}
return getXmlText();
}
示例12: center
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
/**
* Shell
*/
public static void center(final Shell shell) {
final Rectangle r1 = shell.getMonitor().getBounds(), r2 = shell.getBounds();
shell.setLocation(r1.x + (r1.width - r2.width) / 2, r1.y + (r1.height - r2.height) / 2);
}