2011-10-12 10 views

Respuesta

28

Puede especificar los bits de estilo Shell mediante el constructor de dos arg . Los bits de estilo por defecto son SWT.SHELL_TRIM:

public static final int SHELL_TRIM = CLOSE | TITLE | MIN | MAX | RESIZE; 

que realmente desea excluir el bit RESIZE. Si va a crear su propio Shell:

final Shell shell = new Shell(parentShell, SWT.SHELL_TRIM & (~SWT.RESIZE)); 

Si está extendiendo Dialog, puede influir en los bits de estilo concha por overridding getShellStyle:

@Override 
protected int getShellStyle() 
{ 
    return super.getShellStyle() & (~SWT.RESIZE); 
} 
4

Puede controlar los muebles cuando declara el shell. Creo que este ejemplo hace lo que quieres;

import org.eclipse.swt.SWT; 
import org.eclipse.swt.graphics.Rectangle; 
import org.eclipse.swt.widgets.Display; 
import org.eclipse.swt.widgets.Event; 
import org.eclipse.swt.widgets.Listener; 
import org.eclipse.swt.widgets.Shell; 
import org.eclipse.swt.widgets.Text; 

public class FixedWindow { 
    public static void main(String[] args) { 
     Display display = new Display(); 

     //final Shell shell = new Shell(display); //defaults 
     //final Shell shell = new Shell(display, SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX); //can be maximised 
     final Shell shell = new Shell(display, SWT.CLOSE | SWT.TITLE | SWT.MIN); // fixed but can be minimised 
     //final Shell shell = new Shell(display, SWT.TITLE); // fixed, uncloseable, unminimisable can only be removed by OS killing JVM. 

     Rectangle boundRect = new Rectangle(0, 0, 1024, 768); 
     shell.setBounds(boundRect); 
     Rectangle boundInternal = shell.getClientArea(); 

     shell.setText("Fixed size SWT Window."); 

     shell.open(); 

     final Text text = new Text(shell, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); 

     text.setEditable(true); 
     text.setEnabled(true); 
     text.setText("Oh help!"); 
     text.setBounds(boundInternal); 


     while (!shell.isDisposed()) { 

      if (!display.readAndDispatch()) 
       display.sleep(); 
     } 
     display.dispose(); 
    } 
} 
+0

gracias, en realidad lo resolví mientras tanto al agregar: "nuevo Shell (pantalla, SWT.CLOSE | SWT.TITLE)" , y su respuesta hace lo mismo pero tiene adicionalmente MIN – alhcr

-1

No estoy seguro de ello, pero creo que se puede simplemente dejar evento SWT.Resize así:

shell.addListener (SWT.Resize, new Listener() { 
    public void handleEvent (Event e) 
    { 
     return; 
    } 
}); 
+2

Esto no funciona en la práctica - el cambio de tamaño El oyente se activa después de que la ventana se ha redimensionado, no antes, por lo que establecer 'e.doit' en falso no tiene ningún efecto. En algunas plataformas, puede intentar establecer el tamaño de la carcasa ** de nuevo como lo que era, pero esto se ve raro en algunas plataformas (especialmente con el cambio de tamaño de malla, o plataformas que permiten una buena cantidad de cambio de tamaño antes de disparar ese evento.) En otras plataformas, en realidad obtienes un bucle infinito de eventos cuando cambias el tamaño de un intérprete dentro de un oyente de cambio de tamaño (a menos que configures un indicador de que estás cambiando el tamaño). –

Cuestiones relacionadas