本文整理了Java中org.eclipse.swt.widgets.Shell.getBounds()
方法的一些代码示例,展示了Shell.getBounds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Shell.getBounds()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Shell
类名称:Shell
方法名:getBounds
暂无
代码示例来源:origin: pentaho/pentaho-kettle
public WindowProperty( Shell shell ) {
name = shell.getText();
maximized = shell.getMaximized();
rectangle = shell.getBounds();
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Overridden to auto-size the shell according to the selected width.
*/
@Override
protected void constrainShellSize() {
super.constrainShellSize();
try {
// the shell property within the Windows class is private - need to access it via reflection
final Field shellField = Window.class.getDeclaredField( "shell" );
shellField.setAccessible( true );
final Shell thisShell = (Shell) shellField.get( this );
thisShell.pack();
final int height = thisShell.computeSize( width, SWT.DEFAULT ).y;
thisShell.setBounds( thisShell.getBounds().x, thisShell.getBounds().y, width + 4, height + 2 );
} catch ( final Exception e ) {
// nothing to do
}
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Sets the minimal shell height.
*
* @param shell the shell
* @param controls the controls to measure
* @param margin the margin between the components
* @param extra the extra padding
*/
public static void setMinimalShellHeight( Shell shell, Control[] controls, int margin, int extra ) {
int height = 0;
for ( int i = 0; i < controls.length; i++ ) {
Rectangle bounds = controls[ i ].getBounds();
height += bounds.height + margin;
}
height += extra;
shell.setSize( shell.getBounds().width, height );
}
代码示例来源:origin: pentaho/pentaho-kettle
protected void setPosition() {
Rectangle shellBounds = getParent().getBounds();
Point dialogSize = dialog.getSize();
dialog.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2, shellBounds.y
+ ( shellBounds.height - dialogSize.y ) / 2 );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
private void setPosition() {
Rectangle shellBounds = getParent().getBounds();
Point dialogSize = dialog.getSize();
dialog.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2,
shellBounds.y + ( shellBounds.height - dialogSize.y ) / 2 );
}
}
代码示例来源:origin: caoxinyu/RedisClient
protected void setMiddle() {
Rectangle screenSize = shell.getParent().getBounds();
Rectangle shellSize = shell.getBounds();
shell.setLocation(screenSize.x + screenSize.width / 2 - shellSize.width / 2,
screenSize.y + screenSize.height / 2 - shellSize.height / 2);
}
代码示例来源:origin: pentaho/pentaho-kettle
public void widgetSelected( SelectionEvent event ) {
if ( list.getSelectionCount() <= 0 ) {
return;
}
String name = list.getSelection()[0];
String value = variables.getVariable( name );
Rectangle shellBounds = shell.getBounds();
String message = BaseMessages.getString( PKG, "TextVar.VariableValue.Message", name, value );
if ( name.startsWith( Const.INTERNAL_VARIABLE_PREFIX ) ) {
message += BaseMessages.getString( PKG, "TextVar.InternalVariable.Message" );
}
toolTip.setText( message );
toolTip.hide();
toolTip.show( new Point( shellBounds.width, 0 ) );
}
} );
代码示例来源:origin: pentaho/pentaho-kettle
protected void openDialog() {
shell.pack();
// Set the focus on the OK button
wOK.setFocus();
Rectangle shellBounds = getParent().getBounds();
Point dialogSize = shell.getSize();
shell.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2, shellBounds.y
+ ( shellBounds.height - dialogSize.y ) / 2 );
shell.open();
while ( !shell.isDisposed() ) {
if ( !display.readAndDispatch() ) {
display.sleep();
}
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public void dispose() {
props.setScreen( new WindowProperty( shell ) );
bounds = shell.getBounds();
hscroll = wFields.getHorizontalBar().getSelection();
vscroll = wFields.getVerticalBar().getSelection();
shell.dispose();
}
代码示例来源:origin: pentaho/pentaho-kettle
public void dispose() {
props.setScreen( new WindowProperty( shell ) );
bounds = shell.getBounds();
hscroll = wFields.getHorizontalBar().getSelection();
vscroll = wFields.getVerticalBar().getSelection();
shell.dispose();
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
*
* @param shell
* the shell.
*/
public OlapInputAboutDialog( final Shell shell ) {
this.dialog = new Shell( shell, SWT.BORDER | SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.SHEET );
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
this.dialog.setLayout( gridLayout );
this.dialog.setText( BaseMessages.getString( PKG, "OlapInputDialog.About.Shell.Title" ) );
this.dialog.setImage( shell.getImage() );
this.buildIconCell();
this.buildPluginInfoCell();
this.buildOkButton();
this.dialog.pack();
Rectangle shellBounds = shell.getBounds();
Point dialogSize = this.dialog.getSize();
this.dialog.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2, shellBounds.y
+ ( shellBounds.height - dialogSize.y ) / 2 );
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
*
* @param shell
* the shell.
*/
public SapInputAboutDialog( final Shell shell ) {
this.dialog = new Shell( shell, SWT.BORDER | SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.SHEET );
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
this.dialog.setLayout( gridLayout );
this.dialog.setText( BaseMessages.getString( PKG, "SapInputDialog.About.Shell.Title" ) );
this.dialog.setImage( shell.getImage() );
this.buildIconCell();
this.buildPluginInfoCell();
this.buildOkButton();
this.dialog.pack();
Rectangle shellBounds = shell.getBounds();
Point dialogSize = this.dialog.getSize();
this.dialog.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2, shellBounds.y
+ ( shellBounds.height - dialogSize.y ) / 2 );
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
*
* @param shell
* the shell.
*/
public TeraFastAboutDialog( final Shell shell ) {
this.dialog = new Shell( shell, SWT.BORDER | SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.SHEET );
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
this.dialog.setLayout( gridLayout );
this.dialog.setText( BaseMessages.getString( PKG, "TeraFastDialog.About.Shell.Title" ) );
this.dialog.setImage( shell.getImage() );
this.buildIconCell();
this.buildPluginInfoCell();
this.buildOkButton();
this.dialog.pack();
Rectangle shellBounds = shell.getBounds();
Point dialogSize = this.dialog.getSize();
this.dialog.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2, shellBounds.y
+ ( shellBounds.height - dialogSize.y ) / 2 );
}
代码示例来源:origin: pentaho/pentaho-kettle
shell.setLocation( ( screenSize.width - shell.getBounds().width ) / 2, ( screenSize.height - shell.getBounds().height ) / 2 );
closeButton.setFocus();
shell.open();
代码示例来源:origin: pentaho/pentaho-kettle
Rectangle bounds = shell.getBounds();
if ( bounds.width < minWidth ) {
bounds.width = minWidth;
Rectangle shellSize = shell.getBounds();
if ( shellSize.width < computedSize.x ) {
shellSize.width = computedSize.x;
代码示例来源:origin: pentaho/pentaho-kettle
shell.open();
Rectangle shellBounds = getParent().getBounds();
Point dialogSize = shell.getSize();
代码示例来源:origin: pentaho/pentaho-kettle
public static void setSize( Shell shell, int minWidth, int minHeight, boolean packIt ) {
PropsUI props = PropsUI.getInstance();
WindowProperty winprop = props.getScreen( shell.getText() );
if ( winprop != null ) {
winprop.setShell( shell, minWidth, minHeight );
} else {
if ( packIt ) {
shell.pack();
} else {
shell.layout();
}
// OK, sometimes this produces dialogs that are waay too big.
// Try to limit this a bit, m'kay?
// Use the same algorithm by cheating :-)
//
winprop = new WindowProperty( shell );
winprop.setShell( shell, minWidth, minHeight );
// Now, as this is the first time it gets opened, try to put it in the middle of the screen...
Rectangle shellBounds = shell.getBounds();
Monitor monitor = shell.getDisplay().getPrimaryMonitor();
if ( shell.getParent() != null ) {
monitor = shell.getParent().getMonitor();
}
Rectangle monitorClientArea = monitor.getClientArea();
int middleX = monitorClientArea.x + ( monitorClientArea.width - shellBounds.width ) / 2;
int middleY = monitorClientArea.y + ( monitorClientArea.height - shellBounds.height ) / 2;
shell.setLocation( middleX, middleY );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static void setSize( Shell shell, int prefWidth, int prefHeight ) {
PropsUI props = PropsUI.getInstance();
WindowProperty winprop = props.getScreen( shell.getText() );
if ( winprop != null ) {
winprop.setShell( shell, prefWidth, prefHeight );
} else {
shell.layout();
winprop = new WindowProperty( shell.getText(), false, new Rectangle( 0, 0, prefWidth, prefHeight ) );
winprop.setShell( shell );
// Now, as this is the first time it gets opened, try to put it in the middle of the screen...
Rectangle shellBounds = shell.getBounds();
Monitor monitor = shell.getDisplay().getPrimaryMonitor();
if ( shell.getParent() != null ) {
monitor = shell.getParent().getMonitor();
}
Rectangle monitorClientArea = monitor.getClientArea();
int middleX = monitorClientArea.x + ( monitorClientArea.width - shellBounds.width ) / 2;
int middleY = monitorClientArea.y + ( monitorClientArea.height - shellBounds.height ) / 2;
shell.setLocation( middleX, middleY );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
Rectangle shellBounds = shell.getBounds();
Monitor monitor = shell.getDisplay().getPrimaryMonitor();
if ( shell.getParent() != null ) {
代码示例来源:origin: BiglySoftware/BiglyBT
ShellMetricsResizeListener(Shell shell, String sConfigPrefix) {
this.sConfigPrefix = sConfigPrefix;
state = calcState(shell);
if (state == SWT.NONE)
bounds = shell.getBounds();
shell.addListener(SWT.Resize, this);
shell.addListener(SWT.Move, this);
shell.addListener(SWT.Dispose, this);
}
内容来源于网络,如有侵权,请联系作者删除!