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

The following examples show how to use org.eclipse.swt.widgets.Shell#setSize() . 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: SWTPieChartDemo1.java    From ccu-historian with GNU General Public License v3.0 7 votes vote down vote up
/**
 * Starting point for the demonstration application.
 *
 * @param args  ignored.
 */
public static void main(String[] args) 
{
    JFreeChart chart = createChart(createDataset());
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setSize(600, 400);
    shell.setLayout(new FillLayout());
    shell.setText("Test for jfreechart running with SWT");
    final ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true);
    //frame.setDisplayToolTips(false);
    frame.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}
 
Example 2
Source File: SWTPieChartDemo1.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Starting point for the demonstration application.
 *
 * @param args  ignored.
 */
public static void main(String[] args) 
{
    JFreeChart chart = createChart(createDataset());
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setSize(600, 400);
    shell.setLayout(new FillLayout());
    shell.setText("Test for jfreechart running with SWT");
    final ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true);
    //frame.setDisplayToolTips(false);
    frame.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}
 
Example 3
Source File: AutoDataBindingViewer.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * main() method for constructing the layout.
 * 
 * @param args
 */
public static void main( String[] args )
{
	Display display = Display.getDefault( );
	Shell shell = new Shell( display );
	shell.setSize( 600, 400 );
	shell.setLayout( new GridLayout( ) );

	Canvas cCenter = new Canvas( shell, SWT.NONE );
	AutoDataBindingViewer adbv = new AutoDataBindingViewer(  );
	cCenter.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	cCenter.addPaintListener( adbv );

	shell.open( );
	while ( !shell.isDisposed( ) )
	{
		if ( !display.readAndDispatch( ) )
			display.sleep( );
	}
	display.dispose( );
}
 
Example 4
Source File: FloatingTextSnippet.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @param args
 */
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setLayout(new GridLayout(1, true));

	createText(new Group(shell, SWT.NONE));

	Point p = shell.getSize();
	p.y = (int) (shell.getMonitor().getBounds().height * 75) / 100;
	p.x = (int) (shell.getMonitor().getBounds().width * 50) / 100;
	shell.setSize(p);
	shell.open();

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

}
 
Example 5
Source File: RichTextEditorExample.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public static void main(String[] args) {
	Display display = new Display();

	final Shell shell = new Shell(display);
	shell.setText("SWT Rich Text Editor example");
	shell.setSize(800, 600);

	shell.setLayout(new GridLayout(1, true));

	RichTextEditorExample example = new RichTextEditorExample();
	example.createControls(shell);

	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
Example 6
Source File: ActionPipelineDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
public IAction open() {
    Shell parent = getParent();
    display = parent.getDisplay();

    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.RESIZE);
    props.setLook(shell);
    WorkflowDialog.setShellImage(shell, action);

    backupChanged = action.hasChanged();

    createElements();

    // Detect [X] or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {
        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });

    getData();
    setActive();

    BaseTransformDialog.setSize(shell);

    int width = 750;
    int height = Const.isWindows() ? 730 : 720;

    shell.setSize(width, height);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return action;
}
 
Example 7
Source File: SinAdvanced.java    From Flashtool with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create contents of the dialog.
 */
private void createContents() {
	shlSinEditor = new Shell(getParent(), getStyle());
	shlSinEditor.setSize(299, 314);
	shlSinEditor.setText("Advanced Sin Editor");
	shlSinEditor.setLayout(new FormLayout());
}
 
Example 8
Source File: ShowProcessOutputDialog.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void constrainShellSize() {
    Shell shell = getShell();
    shell.setSize(640, 480);

    // Move the dialog to the center of the top level shell.
    Rectangle shellBounds = getParentShell().getBounds();
    shell.setLocation(shellBounds.x + (shellBounds.width - 640) / 2,
            shellBounds.y + (shellBounds.height - 480) / 2);
    super.constrainShellSize();
}
 
Example 9
Source File: DayEditorSnippet0.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void createShell() {
	sShell = new Shell();
	sShell.setText("DayEditorSnippet0 -- Display calendar events in DayEditor");
	sShell.setLayout(new GridLayout());
	createNavBar();
	createDayEditor();
	sShell.setSize(new org.eclipse.swt.graphics.Point(800, 592));
}
 
Example 10
Source File: Translator2.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void open() {
  shell = new Shell( display );
  shell.setLayout( new FillLayout() );
  shell.setText( APP_NAME );
  shell.setImage( GUIResource.getInstance().getImageLogoSmall() );

  try {
    readFiles();
  } catch ( Exception e ) {
    new ErrorDialog(
      shell, "Error reading translations", "There was an unexpected error reading the translations", e );
  }

  // Put something on the screen
  sashform = new SashForm( shell, SWT.HORIZONTAL );
  sashform.setLayout( new FormLayout() );

  addLists();
  addGrid();
  addListeners();

  sashform.setWeights( new int[] { 40, 60 } );
  sashform.setVisible( true );

  shell.pack();

  refresh();

  shell.setSize( 1024, 768 );

  shell.open();
}
 
Example 11
Source File: GraphDemo.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public static void main(final String[] args) {

		// if testName is Default, the original Axis implementation will be
		// used. If Diamond, the new DAxis implementation will be used to
		// generate the tick marks.
		String testName = "Default";
		String[] testNames = new String[] { "Default", "Diamond" };

		final Shell shell = new Shell();
		shell.setSize(800, 500);
		shell.open();

		final LightweightSystem lws = new LightweightSystem(shell);

		XYGraphTest2 testFigure = null;
		if (testName.equals(testNames[0])) {
			testFigure = new XYGraphTest2(
					new XYGraph(new DefaultAxesFactory()),
					new Axis("X-2", false), new Axis("Log Scale", true));
		} else {
			testFigure = new XYGraphTest2(
					new XYGraph(new DAxesFactory()),
					new DAxis("X-2", false), new DAxis("Log Scale", true));
		}
		lws.setContents(testFigure);

		shell.setText("XY Graph Test");
		final Display display = Display.getDefault();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		// System.out.println(Calendar.getInstance().getTime());
	}
 
Example 12
Source File: MeterExample.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	final Shell shell = new Shell();
	shell.setSize(300, 150);
    shell.open();
    
    //use LightweightSystem to create the bridge between SWT and draw2D
	final LightweightSystem lws = new LightweightSystem(shell);		
	
	//Create Gauge
	final MeterFigure meterFigure = new MeterFigure();
	
	//Init gauge
	meterFigure.setBackgroundColor(
			XYGraphMediaFactory.getInstance().getColor(255, 255, 255));
	
	meterFigure.setBorder(new SchemeBorder(SchemeBorder.SCHEMES.ETCHED));
	
	meterFigure.setRange(-100, 100);
	meterFigure.setLoLevel(-50);
	meterFigure.setLoloLevel(-80);
	meterFigure.setHiLevel(60);
	meterFigure.setHihiLevel(80);
	meterFigure.setMajorTickMarkStepHint(50);
	
	lws.setContents(meterFigure);		
	
	//Update the gauge in another thread.
	ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
	ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(new Runnable() {
		
		@Override
		public void run() {
			Display.getDefault().asyncExec(new Runnable() {					
				@Override
				public void run() {
					meterFigure.setValue(Math.sin(counter++/10.0)*100);						
				}
			});
		}
	}, 100, 100, TimeUnit.MILLISECONDS);		
	
    Display display = Display.getDefault();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    future.cancel(true);
    scheduler.shutdown();
   
}
 
Example 13
Source File: WarningDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void open() {
  Shell parent = getParent();
  Display display = parent.getDisplay();

  shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.SHEET | SWT.RESIZE );
  shell.setImage( GUIResource.getInstance().getImageSpoon() );
  shell.setLayout( new FormLayout() );
  shell.setText( title );
  props.setLook( shell );

  Label wlImage = new Label( shell, SWT.NONE );
  wlImage.setImage( GUIResource.getInstance().getImageWarning32() );
  FormData fdWarnImage = new FormData();
  fdWarnImage.left = new FormAttachment( 0, 15 );
  fdWarnImage.top = new FormAttachment( 0, 15 );
  fdWarnImage.height = 32;
  fdWarnImage.width = 32;
  wlImage.setLayoutData( fdWarnImage );
  props.setLook( wlImage );

  Label wlMessage = new Label( shell, SWT.FLAT  | SWT.WRAP );
  wlMessage.setText( message );
  FormData fdMessage = new FormData();
  fdMessage.left = new FormAttachment( wlImage, 15, SWT.RIGHT );
  fdMessage.right = new FormAttachment( 100, -15 );
  fdMessage.top = new FormAttachment( wlImage, 0, SWT.TOP );
  wlMessage.setLayoutData( fdMessage );
  props.setLook( wlMessage );


  Button spacer = new Button( shell, SWT.NONE );
  FormData fdSpacer = new FormData();
  fdSpacer.right = new FormAttachment( 100, 0 );
  fdSpacer.bottom = new FormAttachment( 100, -15 );
  fdSpacer.left = new FormAttachment( 100, -11 );
  fdSpacer.top = new FormAttachment( wlMessage, 15, SWT.BOTTOM );
  spacer.setLayoutData( fdSpacer );
  spacer.setVisible( false );
  props.setLook( spacer );

  Control attachTo = spacer;
  for ( String label : listenerMap.keySet() ) {
    Button wButton = new Button( shell, SWT.PUSH );
    wButton.setText( label );
    FormData fdButton = new FormData();
    fdButton.right = new FormAttachment( attachTo, -Const.MARGIN, SWT.LEFT );
    fdButton.bottom = new FormAttachment( attachTo, 0, SWT.BOTTOM );
    wButton.setLayoutData( fdButton );
    wButton.addListener( SWT.Selection, listenAndDispose( listenerMap.get( label ) ) );
    props.setLook( wButton );
    attachTo = wButton;
  }
  Point point = shell.computeSize( 436, SWT.DEFAULT );
  shell.setSize( point );
  shell.open();
  while ( !shell.isDisposed() ) {
    if ( !display.readAndDispatch() ) {
      display.sleep();
    }
  }
}
 
Example 14
Source File: Regression_117511_svg.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void widgetSelected( SelectionEvent e )
{
	if ( e.widget == btn )
	{
		int i = cbType.getSelectionIndex( );
		switch ( i )
		{
			case 0 :
				cm = BarChart( );
				break;
		}

		try
		{

			RunTimeContext rtc = new RunTimeContext( );
			rtc.setULocale( ULocale.getDefault( ) );

			idr = PluginSettings.instance( ).getDevice( "dv.SVG" ); //$NON-NLS-1$
			Generator gr = Generator.instance( );
			GeneratedChartState gcs = null;
			Bounds bo = BoundsImpl.create( 0, 0, 450, 300 );
			gcs = gr.build(
					idr.getDisplayServer( ),
					cm,
					bo,
					null,
					rtc,
					null );

			idr
					.setProperty(
							IDeviceRenderer.FILE_IDENTIFIER,
							"c:/test.svg" ); //$NON-NLS-1$
			idr.setProperty(
					IDeviceRenderer.UPDATE_NOTIFIER,
					new EmptyUpdateNotifier( cm, gcs.getChartModel( ) ) );

			gr.render( idr, gcs );
		}
		catch ( ChartException ce )
		{
			ce.printStackTrace( );
		}

		Shell shell = new Shell( display );
		shell.setSize( 620, 450 );
		shell.setLayout( new GridLayout( ) );

		Browser br = new Browser( shell, SWT.NONE );
		br.setLayoutData( new GridData( GridData.FILL_BOTH ) );
		br.setUrl( "c:/test.svg" );//$NON-NLS-1$		
		br.setVisible( true );

		shell.open( );
	}
}
 
Example 15
Source File: FontAwesomeSnippet2.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(final String[] args) throws IllegalArgumentException, IllegalAccessException {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setText("FontAwesome Snippet");
	shell.setSize(600, 600);
	shell.setLayout(new GridLayout(1, false));

	// Label
	new Label(shell, SWT.NONE).setText("In Label");
	Label text = new Label(shell, SWT.NONE);
	text.setFont(FontAwesome.getFont(22));
	text.setText(FontAwesome.code);

	// Button
	new Label(shell, SWT.NONE).setText("In Button");
	Composite comp1 = new Composite(shell, SWT.NONE);
	comp1.setLayout(new RowLayout());
	Button button1 = new Button(comp1, SWT.NONE);
	button1.setFont(FontAwesome.getFont(10));
	button1.setText(FontAwesome.plus + " plus");
	Button button2 = new Button(comp1, SWT.NONE);
	button2.setFont(FontAwesome.getFont(10));
	button2.setText(FontAwesome.minus + " minus");

	// Toolbar
	new Label(shell, SWT.NONE).setText("In ToolBar");
	ToolBar toolbar = new ToolBar(shell, SWT.NONE);
	toolbar.setFont(FontAwesome.getFont(15));
	ToolItem item1 = new ToolItem(toolbar, SWT.NONE);
	item1.setText(FontAwesome.align_left);
	ToolItem item2 = new ToolItem(toolbar, SWT.NONE);
	item2.setText(FontAwesome.align_center);
	ToolItem item3 = new ToolItem(toolbar, SWT.NONE);
	item3.setText(FontAwesome.align_right);
	new ToolItem(toolbar, SWT.SEPARATOR);
	ToolItem item4 = new ToolItem(toolbar, SWT.NONE);
	item4.setText(FontAwesome.quote_left);
	new ToolItem(toolbar, SWT.SEPARATOR);
	ToolItem item5 = new ToolItem(toolbar, SWT.NONE);
	item5.setText(FontAwesome.question);

	shell.pack();
	shell.open();

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

}
 
Example 16
Source File: InputParameterDialog.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected void configureShell( Shell newShell )
{
	super.configureShell( newShell );
	newShell.setText( "Input parameters" ); //$NON-NLS-1$
	newShell.setSize( 400, 400 );
}
 
Example 17
Source File: ThermometerExample.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	final Shell shell = new Shell();
	shell.setSize(300, 250);
    shell.open();
    
    //use LightweightSystem to create the bridge between SWT and draw2D
	final LightweightSystem lws = new LightweightSystem(shell);		
	
	//Create widget
	final ThermometerFigure thermo = new ThermometerFigure();
	
	//Init widget
	thermo.setBackgroundColor(
			XYGraphMediaFactory.getInstance().getColor(255, 255, 255));
	
	thermo.setBorder(new SchemeBorder(SchemeBorder.SCHEMES.ETCHED));
	
	thermo.setRange(-100, 100);
	thermo.setLoLevel(-50);
	thermo.setLoloLevel(-80);
	thermo.setHiLevel(60);
	thermo.setHihiLevel(80);
	thermo.setShowHi(false);
	thermo.setMajorTickMarkStepHint(50);
	
	lws.setContents(thermo);		
	
	//Update the widget in another thread.
	ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
	ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(new Runnable() {
		
		public void run() {
			Display.getDefault().asyncExec(new Runnable() {					
				public void run() {
					thermo.setValue(Math.sin(counter++/10.0)*100);						
				}
			});
		}
	}, 100, 100, TimeUnit.MILLISECONDS);		
	
    Display display = Display.getDefault();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    future.cancel(true);
    scheduler.shutdown();
   
}
 
Example 18
Source File: USBLogviewer.java    From Flashtool with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Create contents of the dialog.
 */
private void createContents() {
	shlUSBLogviewer = new Shell(getParent(), getStyle());
	shlUSBLogviewer.setSize(710, 475);
	shlUSBLogviewer.setText("USB Log Viewer");
	shlUSBLogviewer.setLayout(new FormLayout());
	
	btnClose = new Button(shlUSBLogviewer, SWT.NONE);
	FormData fd_btnClose = new FormData();
	fd_btnClose.bottom = new FormAttachment(100, -10);
	fd_btnClose.right = new FormAttachment(100, -10);
	btnClose.setLayoutData(fd_btnClose);
	btnClose.setText("Close");
	
	compositeTable = new Composite(shlUSBLogviewer, SWT.NONE);
	compositeTable.setLayout(new FillLayout(SWT.HORIZONTAL));
	FormData fd_compositeTable = new FormData();
	
	fd_compositeTable.right = new FormAttachment(100, -10);
	fd_compositeTable.left = new FormAttachment(0, 10);
	fd_compositeTable.bottom = new FormAttachment(btnClose, -6);
	compositeTable.setLayoutData(fd_compositeTable);
	
	tableViewer = new TableViewer(compositeTable,SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.SINGLE);
	tableViewer.setContentProvider(new VectorContentProvider());
	tableViewer.setLabelProvider(new VectorLabelProvider());

	table = tableViewer.getTable();
	TableColumn[] columns = new TableColumn[2];
	columns[0] = new TableColumn(table, SWT.NONE);
	columns[0].setText("Action");
	columns[1] = new TableColumn(table, SWT.NONE);
	columns[1].setText("Parameter");
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
	TableSorter sort = new TableSorter(tableViewer);
	Composite compositeSource = new Composite(shlUSBLogviewer, SWT.NONE);
	compositeSource.setLayout(new GridLayout(3, false));
	FormData fd_compositeSource = new FormData();
	fd_compositeSource.top = new FormAttachment(0, 10);
	fd_compositeSource.left = new FormAttachment(0, 10);
	fd_compositeSource.right = new FormAttachment(100, -10);
	compositeSource.setLayoutData(fd_compositeSource);
	
	fd_compositeTable.top = new FormAttachment(compositeSource, 6);
	
	lblLogfile = new Label(compositeSource, SWT.BORDER);
	lblLogfile.setText("USB Log file :");
	
	textLogFile = new Text(compositeSource, SWT.BORDER);
	textLogFile.setEditable(false);
	GridData gd_textLogFile = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
	gd_textLogFile.widthHint = 471;
	textLogFile.setLayoutData(gd_textLogFile);
	
	btnLogFile = new Button(compositeSource, SWT.NONE);
	btnLogFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	btnLogFile.setText("...");
	
	Label lblSinfolder = new Label(compositeSource, SWT.NONE);
	GridData gd_lblSinfolder = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
	gd_lblSinfolder.widthHint = 110;
	lblSinfolder.setLayoutData(gd_lblSinfolder);
	lblSinfolder.setText("Source folder :");
	
	textSinFolder = new Text(compositeSource, SWT.BORDER);
	textSinFolder.setEditable(false);
	GridData gd_textSinFolder = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
	gd_textSinFolder.widthHint = 509;
	textSinFolder.setLayoutData(gd_textSinFolder);
	
	btnSourceFolder = new Button(compositeSource, SWT.NONE);
	GridData gd_btnSourceFolder = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
	gd_btnSourceFolder.widthHint = 46;
	btnSourceFolder.setLayoutData(gd_btnSourceFolder);
	btnSourceFolder.setText("...");
	btnParse = new Button(shlUSBLogviewer, SWT.NONE);
	FormData fd_btnParse = new FormData();
	fd_btnParse.bottom = new FormAttachment(100,-10);
	fd_btnParse.right = new FormAttachment(btnClose, -6);
	btnParse.setLayoutData(fd_btnParse);
	btnParse.setText("Parse");

}
 
Example 19
Source File: DialChartViewer.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * execute application
 * 
 * @param args
 */
public static void main( String[] args )
{

	Display display = Display.getDefault( );
	Shell shell = new Shell( display );
	shell.setSize( 600, 400 );
	shell.setLayout( new GridLayout( ) );

	DialChartViewer dcViewer = new DialChartViewer( shell,
			SWT.NO_BACKGROUND );
	dcViewer.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	dcViewer.addPaintListener( dcViewer );

	Composite cBottom = new Composite( shell, SWT.NONE );
	cBottom.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	cBottom.setLayout( new RowLayout( ) );

	Label la = new Label( cBottom, SWT.NONE );

	la.setText( "&Choose: " );//$NON-NLS-1$
	cbType = new Combo( cBottom, SWT.DROP_DOWN | SWT.READ_ONLY );
	cbType.add( "Single Dial, Multi Regions" );//$NON-NLS-1$
	cbType.add( "Multi Dials, Multi Regions" );//$NON-NLS-1$
	cbType.add( "Single Dial, Single Region" );//$NON-NLS-1$
	cbType.add( "Multi Dials, Single Region" );//$NON-NLS-1$
	cbType.select( 0 );

	btn = new Button( cBottom, SWT.NONE );
	btn.setText( "&Update" );//$NON-NLS-1$
	btn.addSelectionListener( dcViewer );
	btn.setToolTipText( "Update" );//$NON-NLS-1$

	shell.open( );
	while ( !shell.isDisposed( ) )
	{
		if ( !display.readAndDispatch( ) )
			display.sleep( );
	}
	display.dispose( );
}
 
Example 20
Source File: GridSnippet6.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 FillLayout());

    Grid grid = new Grid(shell,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    grid.setHeaderVisible(true);
    GridColumn column = new GridColumn(grid,SWT.NONE);
    column.setText("Column 1");
    column.setWidth(100);
    GridColumnGroup columnGroup = new GridColumnGroup(grid,SWT.TOGGLE);
    columnGroup.setText("Column Group");
    GridColumn column2 = new GridColumn(columnGroup,SWT.NONE);
    column2.setText("Column 2");
    column2.setWidth(60);
    column2.setSummary(false);
    GridColumn column3 = new GridColumn(columnGroup,SWT.NONE);
    column3.setText("Column 3");
    column3.setWidth(60);
    column3.setSummary(false);
    GridColumn summaryColumn = new GridColumn(columnGroup,SWT.NONE);
    summaryColumn.setText("Sum");
    summaryColumn.setWidth(93);
    summaryColumn.setDetail(false);
    summaryColumn.setSummary(true);
    GridItem item1 = new GridItem(grid,SWT.NONE);
    item1.setText("First Item");
    item1.setText(1,"100");
    item1.setText(2,"42");
    item1.setText(3,"142");
    GridItem item2 = new GridItem(grid,SWT.NONE);
    item2.setText("Second Item");
    item2.setText(1,"63");
    item2.setText(2,"92");
    item2.setText(3,"155");
    GridItem item3 = new GridItem(grid,SWT.NONE);
    item3.setText("Third Item");
    item3.setText(1,"7");
    item3.setText(2,"3");
    item3.setText(3,"10");
    
    shell.setSize(250,250);
    shell.open ();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch ()) display.sleep ();
    }
    display.dispose ();
}