Java Code Examples for org.eclipse.swt.widgets.Shell#setBackgroundMode()

The following examples show how to use org.eclipse.swt.widgets.Shell#setBackgroundMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Notifier.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates a notification window
 *
 * @param image image. If <code>null</code>, a default image is used
 * @param title title, the title of the window
 * @param text text of the window
 * @param colors color set
 * @return the notification window as a shell object
 */
protected static Shell createNotificationWindow(final Image image, final String title, final String text, final NotifierColors colors) {
	final Shell shell = new Shell(Display.getDefault().getActiveShell(), SWT.NO_TRIM | SWT.NO_FOCUS | SWT.ON_TOP);
	shell.setLayout(new GridLayout(2, false));
	shell.setBackgroundMode(SWT.INHERIT_FORCE);

	createTitle(shell, title, colors);
	createImage(shell, image);
	createText(shell, text, colors);
	createBackground(shell, colors);
	createCloseAction(shell);

	shell.addListener(SWT.Dispose, event -> {
		colors.dispose();
	});

	shell.pack();
	shell.setMinimumSize(320, 100);
	return shell;
}
 
Example 2
Source File: SimpleMessageDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * Overridden to make the shell background white.
 *
 * @param shell
 */
@Override
protected void configureShell( Shell shell ) {
  super.configureShell( shell );
  shell.setBackground( shell.getDisplay().getSystemColor( SWT.COLOR_WHITE ) );
  shell.setBackgroundMode( SWT.INHERIT_FORCE );
}
 
Example 3
Source File: LibrarySuggestionView.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void configureShell(Shell newShell) {
	super.configureShell(newShell);
	newShell.setToolTipText("");
	newShell.setImage(ResourceManager.getPluginImage("org.eclipse.scava.plugin",
			"icons/features/crossminer_library_search_16x16.png"));
	newShell.setText("Library search");

	newShell.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
	newShell.setBackgroundMode(SWT.INHERIT_FORCE);
}
 
Example 4
Source File: SearchView.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void configureShell(Shell newShell) {
	super.configureShell(newShell);
	newShell.setToolTipText("");
	newShell.setImage(ResourceManager.getPluginImage("org.eclipse.scava.plugin",
			"icons/features/crossminer_project_search_16x16.png"));
	newShell.setText("Project search");

	newShell.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
	newShell.setBackgroundMode(SWT.INHERIT_FORCE);
}
 
Example 5
Source File: InstallView.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void configureShell(Shell newShell) {
	super.configureShell(newShell);
	newShell.setImage(ResourceManager.getPluginImage("org.eclipse.scava.plugin", "icons/features/crossminer_project_search_16x16.png"));
	newShell.setToolTipText("");
	newShell.setText("Project search");

	newShell.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
	newShell.setBackgroundMode(SWT.INHERIT_FORCE);
}
 
Example 6
Source File: SimpleMessageDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Overridden to make the shell background white.
 *
 * @param shell
 */
@Override
protected void configureShell( Shell shell ) {
  super.configureShell( shell );
  shell.setBackground( shell.getDisplay().getSystemColor( SWT.COLOR_WHITE ) );
  shell.setBackgroundMode( SWT.INHERIT_FORCE );
}
 
Example 7
Source File: PGroupSnippet2.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main (String [] args) {
    Display display = new Display ();
    Shell shell = new Shell (display);
    shell.setLayout(new GridLayout());

    //Set the shell background to something different
    shell.setBackground(display.getSystemColor(SWT.COLOR_RED));
    
    //Tell the shell to give its children the same background color or image
    shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
    
    //Optionally trying creating a patterned image for the shell background
//    final Image backImage = new Image(display,10,10);
//    GC gc = new GC(backImage);
//    gc.drawLine(0,0,9,9);
//    gc.dispose();
//    shell.addDisposeListener(new DisposeListener() {
//		public void widgetDisposed(DisposeEvent e) {
//			backImage.dispose();
//		}	
//	});
//    shell.setBackgroundImage(backImage);
    
    PGroup group = new PGroup(shell, SWT.SMOOTH);
    group.setText("Example");
    group.setLayout(new FillLayout());    
    group.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
    
    Composite groupClient = new Composite(group,SWT.NONE);
    groupClient.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
    
    groupClient.setLayout(new GridLayout());
    
    Label label = new Label(groupClient,SWT.NONE);
    label.setText("Contents");
    Button button = new Button(groupClient,SWT.PUSH);
    button.setText("Contents");
    Scale scale = new Scale(groupClient,SWT.HORIZONTAL);
    
    
    shell.setSize(200,200);
    shell.open ();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch ()) display.sleep ();
    }
    display.dispose ();
}
 
Example 8
Source File: Bug385585.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(String[] args) {

		// get display.
		Display display = new Display();

		// create a new visible shell.
		final Shell shell = new Shell(display);
		shell.setText("Test");
		shell.setSize(600, 400);
		GridLayoutFactory.swtDefaults().numColumns(2).applyTo(shell);

		Button button = new Button(shell, SWT.PUSH);
		button.setText("Click me");
		GridDataFactory.fillDefaults().grab(false, false).applyTo(button);

		final Label label = new Label(shell, SWT.NONE);
		label.setText("Combo will appear here");
		GridDataFactory.fillDefaults().grab(true, false).applyTo(label);

		// create a new "background" shell
		Shell limbo = new Shell(display, SWT.NONE);
		limbo.setLocation(0, 10000);
		limbo.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
		limbo.setBackgroundMode(SWT.INHERIT_FORCE);
		GridLayoutFactory.swtDefaults().numColumns(2).applyTo(limbo);

		final TableComboViewer comboViewer = new TableComboViewer(limbo);
		GridDataFactory.fillDefaults().grab(true, false).applyTo(comboViewer.getControl());
		comboViewer.getTableCombo().defineColumns(1);
		comboViewer.setContentProvider(ArrayContentProvider.getInstance());
		comboViewer.setLabelProvider(new LabelProvider() {
			@Override
			public String getText(Object element) {
				return (String) element;
			}
		});
		comboViewer.setInput(Arrays.asList("One", "Two", "Three"));

		// move combo
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				label.dispose();
				comboViewer.getTableCombo().setParent(shell);
				shell.layout(true);
			}
		});

		// open the shell.
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}

		// dispose display
		display.dispose();
	}
 
Example 9
Source File: SnippetCheckBoxGroup.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
	final FillLayout layout1 = new FillLayout(SWT.VERTICAL);
	layout1.marginWidth = layout1.marginHeight = 10;
	shell.setLayout(layout1);

	// Displays the group
	final CheckBoxGroup group = new CheckBoxGroup(shell, SWT.NONE);
	group.setLayout(new GridLayout(4, false));
	group.setText("Use proxy server");

	final Composite content = group.getContent();

	final Label lblServer = new Label(content, SWT.NONE);
	lblServer.setText("Server:");
	lblServer.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));

	final Text txtServer = new Text(content, SWT.NONE);
	txtServer.setText("proxy.host.com");
	txtServer.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

	final Label lblPort = new Label(content, SWT.NONE);
	lblPort.setText("Port:");
	lblPort.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));

	final Text txtPort = new Text(content, SWT.NONE);
	txtPort.setText("1234");
	txtPort.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

	final Label lblUser = new Label(content, SWT.NONE);
	lblUser.setText("User ID:");
	lblUser.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));

	final Text txtUser = new Text(content, SWT.NONE);
	txtUser.setText("MyName");
	txtUser.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

	final Label lblPassword = new Label(content, SWT.NONE);
	lblPassword.setText("Password:");
	lblPassword.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));

	final Text txtPassword = new Text(content, SWT.PASSWORD);
	txtPassword.setText("password");
	txtPassword.setEnabled(false);
	txtPassword.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

	// Open the shell
	shell.setSize(640, 360);
	SWTGraphicUtil.centerShell(shell);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();
}