Java Code Examples for org.eclipse.swt.widgets.Button#setBounds()

The following examples show how to use org.eclipse.swt.widgets.Button#setBounds() . 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: SimpleMessageDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * Overridden to give the button the desired width.
 */
@Override
public void create() {
  super.create();
  final Button button = getButton( 0 );
  final int newX = button.getBounds().x + button.getBounds().width - buttonWidth;
  button.setBounds( newX, button.getBounds().y, buttonWidth, button.getBounds().height );
}
 
Example 2
Source File: VButtonImageBak.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void createImage(VButton button) {
	String key = getKey(button);
	if(requests.containsKey(key)) {
		requests.get(key).add(button);
	} else {
		requests.put(key, new ArrayList<VButton>());
		requests.get(key).add(button);

		int style = button.getStyle() & (SWT.CHECK | SWT.RADIO);
		if(style == 0) {
			style = SWT.TOGGLE; // defaults to, and converts PUSH buttons to, TOGGLE
		}

		Button b = new Button(button.composite, style);
		b.setBackground(button.getBackground());
		b.setBounds(button.getBounds());
		if(button.hasState(VControl.STATE_SELECTED)) {
			b.setSelection(true);
		}
		if(button == VTracker.getFocusControl()) {
			 b.setFocus();
		}
		b.addListener(SWT.Paint, new ImageListener(key, b));

		b.redraw();
		b.update();
	}
}
 
Example 3
Source File: ManualLayout.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);

	for (int i = 0; i <= 10; i++) {
		Button button = new Button(shell, SWT.PUSH);
		button.setText("Button " + 1);
		button.setBounds(i*10, i*10, 200, 200);
		button.moveAbove(null);
		button.addSelectionListener(new SelectionAdapter() {
			
			@Override
			public void widgetSelected(SelectionEvent e) {
				Control control = (Control) e.widget;
				control.moveAbove(null);
			}
			
		});
	}
	shell.pack();
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
Example 4
Source File: SimpleMessageDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Overridden to give the button the desired width.
 */
@Override
public void create() {
  super.create();
  final Button button = getButton( 0 );
  final int newX = button.getBounds().x + button.getBounds().width - buttonWidth;
  button.setBounds( newX, button.getBounds().y, buttonWidth, button.getBounds().height );
}
 
Example 5
Source File: SeriesPagePie.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
public SeriesPagePie(Composite parent, int style) {
	super(parent, style);
	setLayout(new GridLayout(1, false));
	
	compositeFirst = new Composite(this, SWT.NONE);
	compositeFirst.setLayout(new GridLayout(2, false));
	compositeFirst.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	
	btnNewButton = new Button(compositeFirst, SWT.NONE);
	btnNewButton.setText("Select Term");
	
	lblSelectedTermIs = new Label(compositeFirst, SWT.CENTER);
	GridData gd_lblSelectedTermIs = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_lblSelectedTermIs.widthHint = 367;
	lblSelectedTermIs.setLayoutData(gd_lblSelectedTermIs);
	lblSelectedTermIs.setText("No Term Selected");
	btnNewButton.addSelectionListener(this);
	
	
	
	Composite compositeCentre = new Composite(this, SWT.NONE);
	compositeCentre.setLayout(new GridLayout(1, false));
	compositeCentre.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, true, 1, 1));
	
	list = new List(compositeCentre, SWT.BORDER | SWT.V_SCROLL);
	GridData gd_list = new GridData(SWT.LEFT, SWT.FILL, true, true, 1, 1);
	gd_list.widthHint = 400;
	list.setLayoutData(gd_list);
	list.setBounds(0, 0, 71, 68);
	list.addSelectionListener(this);
	
	Composite compositeNorth = new Composite(this, SWT.NONE);
	compositeNorth.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	FillLayout fl_compositeNorth = new FillLayout(SWT.HORIZONTAL);
	fl_compositeNorth.marginWidth = 5;
	fl_compositeNorth.spacing = 5;
	compositeNorth.setLayout(fl_compositeNorth);
	
	lblColor = new Label(compositeNorth, SWT.NONE);
	lblColor.setText("Color:");
	
	btnRadioButtonGrey = new Button(compositeNorth, SWT.RADIO);
	btnRadioButtonGrey.setText("Grey");
	btnRadioButtonGrey.addSelectionListener(this);
	
	btnRadioButtonCustom = new Button(compositeNorth, SWT.RADIO);
	btnRadioButtonCustom.setText("Custom");
	btnRadioButtonCustom.addSelectionListener(this);
	
	btnRadioButtonRandom = new Button(compositeNorth, SWT.RADIO);
	btnRadioButtonRandom.setSelection(true);
	btnRadioButtonRandom.setText("Random");
	
	btnOneColor = new Button(compositeNorth, SWT.RADIO);
	btnOneColor.setText("One Color");
	btnOneColor.addSelectionListener(this);
	
	btnRadioButtonRandom.addSelectionListener(this);
	
	Composite compositeSouth = new Composite(this, SWT.NONE);
	compositeSouth.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	compositeSouth.setLayout(new GridLayout(5, false));
	
	btnCheckButton = new Button(compositeSouth, SWT.CHECK);
	btnCheckButton.setBounds(0, 0, 111, 20);
	btnCheckButton.setText("Show in Chart");
	btnCheckButton.addSelectionListener(this);
	
	labelShowColor = new Label(compositeSouth, SWT.BORDER);
	GridData gd_labelShowColor = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_labelShowColor.widthHint = 100;
	labelShowColor.setLayoutData(gd_labelShowColor);
	labelShowColor.setBounds(0, 0, 70, 20);
	labelShowColor.setText(" ");
	labelShowColor.addMouseListener(this);
	new Label(compositeSouth, SWT.NONE);
	new Label(compositeSouth, SWT.NONE);
	new Label(compositeSouth, SWT.NONE);
	
	loadSettings();

}
 
Example 6
Source File: SeriesPageBubble.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
public SeriesPageBubble(Composite parent, int style) {
	super(parent, style);
	setLayout(new GridLayout(1, false));
	
	compositeFirst = new Composite(this, SWT.NONE);
	compositeFirst.setLayout(new GridLayout(4, true));
	compositeFirst.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	
	btnGetYTerm = new Button(compositeFirst, SWT.NONE);
	btnGetYTerm.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	btnGetYTerm.setText("Select Y Term");
	btnGetYTerm.addSelectionListener(this);
	
	lblySelectedTermIs = new Label(compositeFirst, SWT.NONE);
	lblySelectedTermIs.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	lblySelectedTermIs.setText("No Term Selected");
	
	btnGetXTerm = new Button(compositeFirst, SWT.NONE);
	btnGetXTerm.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	btnGetXTerm.setText("Select X Term");
	btnGetXTerm.addSelectionListener(this);
	
	lblxNewLabel = new Label(compositeFirst, SWT.NONE);
	lblxNewLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	lblxNewLabel.setText("No Term Selected");
	
	
	Composite compositeCentre = new Composite(this, SWT.NONE);
	compositeCentre.setLayout(new FillLayout(SWT.HORIZONTAL));
	GridData gd_compositeCentre = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
	gd_compositeCentre.widthHint = 218;
	compositeCentre.setLayoutData(gd_compositeCentre);
	
	list_y = new List(compositeCentre, SWT.BORDER | SWT.V_SCROLL);
	list_y.setBounds(0, 0, 71, 68);
	list_y.addSelectionListener(this);
	
	list_x = new List(compositeCentre, SWT.BORDER | SWT.V_SCROLL);
	list_x.addSelectionListener(this);
	
	Composite compositeNorth = new Composite(this, SWT.NONE);
	compositeNorth.setLayout(new GridLayout(2, false));
	compositeNorth.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	
	btnShowInChartY = new Button(compositeNorth, SWT.CHECK);
	btnShowInChartY.setBounds(0, 0, 111, 20);
	btnShowInChartY.setText("Show in Chart");
	btnShowInChartY.addSelectionListener(this);
	
	btnShowInChartX = new Button(compositeNorth, SWT.CHECK);
	btnShowInChartX.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
	btnShowInChartX.setText("Show in Chart");
	btnShowInChartX.addSelectionListener(this);
	
	Composite compositeSouth = new Composite(this, SWT.NONE);
	compositeSouth.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	compositeSouth.setLayout(new GridLayout(6, false));
	
	lblColorYSeries = new Label(compositeSouth, SWT.NONE);
	GridData gd_lblColorYSeries = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_lblColorYSeries.widthHint = 100;
	lblColorYSeries.setLayoutData(gd_lblColorYSeries);
	lblColorYSeries.setText("Color Y Series:");
	
	labelShowColor = new Label(compositeSouth, SWT.BORDER);
	GridData gd_labelShowColor = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_labelShowColor.widthHint = 100;
	labelShowColor.setLayoutData(gd_labelShowColor);
	labelShowColor.setBounds(0, 0, 70, 20);
	labelShowColor.setText(" ");
	
	btnRadioButtonGrey = new Button(compositeSouth, SWT.RADIO);
	btnRadioButtonGrey.setText("Grey");
	
	btnRadioButtonCustom = new Button(compositeSouth, SWT.RADIO);
	btnRadioButtonCustom.setText("Custom");
	
	btnRadioButtonRandom = new Button(compositeSouth, SWT.RADIO);
	btnRadioButtonRandom.setSelection(true);
	btnRadioButtonRandom.setText("Random");
	
	btnOneColor = new Button(compositeSouth, SWT.RADIO);
	btnOneColor.setText("One color");
	btnOneColor.addSelectionListener(this);
	btnRadioButtonRandom.addSelectionListener(this);
	btnRadioButtonCustom.addSelectionListener(this);
	btnRadioButtonGrey.addSelectionListener(this);
	labelShowColor.addMouseListener(this);
	
	loadSettings();

}
 
Example 7
Source File: SeriesPageBar.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
public SeriesPageBar(Composite parent, int style) {
	super(parent, style);
	setLayout(new GridLayout(1, false));
	
	compositeFirst = new Composite(this, SWT.NONE);
	compositeFirst.setLayout(new GridLayout(2, false));
	compositeFirst.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	
	btnNewButton = new Button(compositeFirst, SWT.NONE);
	btnNewButton.setText("Select Term");
	
	lblSelectedTermIs = new Label(compositeFirst, SWT.CENTER);
	GridData gd_lblSelectedTermIs = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_lblSelectedTermIs.widthHint = 367;
	lblSelectedTermIs.setLayoutData(gd_lblSelectedTermIs);
	lblSelectedTermIs.setText("No Term Selected");
	btnNewButton.addSelectionListener(this);
	
	
	
	Composite compositeCentre = new Composite(this, SWT.NONE);
	compositeCentre.setLayout(new GridLayout(1, false));
	compositeCentre.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, true, 1, 1));
	
	list = new List(compositeCentre, SWT.BORDER | SWT.V_SCROLL);
	GridData gd_list = new GridData(SWT.LEFT, SWT.FILL, true, true, 1, 1);
	gd_list.widthHint = 400;
	list.setLayoutData(gd_list);
	list.setBounds(0, 0, 71, 68);
	list.addSelectionListener(this);
	
	Composite compositeNorth = new Composite(this, SWT.NONE);
	compositeNorth.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	FillLayout fl_compositeNorth = new FillLayout(SWT.HORIZONTAL);
	fl_compositeNorth.marginWidth = 5;
	fl_compositeNorth.spacing = 5;
	compositeNorth.setLayout(fl_compositeNorth);
	
	lblColor = new Label(compositeNorth, SWT.NONE);
	lblColor.setText("Color: ");
	
	btnRadioButtonGrey = new Button(compositeNorth, SWT.RADIO);
	btnRadioButtonGrey.setText("Grey");
	btnRadioButtonGrey.addSelectionListener(this);
	
	btnRadioButtonCustom = new Button(compositeNorth, SWT.RADIO);
	btnRadioButtonCustom.setText("Custom");
	btnRadioButtonCustom.addSelectionListener(this);
	
	btnRadioButtonRandom = new Button(compositeNorth, SWT.RADIO);
	btnRadioButtonRandom.setSelection(true);
	btnRadioButtonRandom.setText("Random");
	
	btnOneColor = new Button(compositeNorth, SWT.RADIO);
	btnOneColor.setText("One Color");
	btnOneColor.addSelectionListener(this);
	
	btnRadioButtonRandom.addSelectionListener(this);
	
	Composite compositeSouth = new Composite(this, SWT.NONE);
	compositeSouth.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	compositeSouth.setLayout(new GridLayout(5, false));
	
	btnCheckButton = new Button(compositeSouth, SWT.CHECK);
	btnCheckButton.setBounds(0, 0, 111, 20);
	btnCheckButton.setText("Show in Chart");
	btnCheckButton.addSelectionListener(this);
	
	labelShowColor = new Label(compositeSouth, SWT.BORDER);
	GridData gd_labelShowColor = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_labelShowColor.widthHint = 100;
	labelShowColor.setLayoutData(gd_labelShowColor);
	labelShowColor.setBounds(0, 0, 70, 20);
	labelShowColor.setText(" ");
	labelShowColor.addMouseListener(this);
	new Label(compositeSouth, SWT.NONE);
	new Label(compositeSouth, SWT.NONE);
	new Label(compositeSouth, SWT.NONE);
	
	loadSettings();

}
 
Example 8
Source File: ExporterDialog.java    From Rel with Apache License 2.0 4 votes vote down vote up
/**
 * Create contents of the dialog.
 */
private void createContents() {
	shlExportToFile = new Shell(getParent(), getStyle());
	shlExportToFile.addDisposeListener(new DisposeListener() {
		public void widgetDisposed(DisposeEvent e) {
			lastPath = exportDialog.getFileName();
		}
	});
	shlExportToFile.setSize(600, 200);
	shlExportToFile.setText("Export to File");
	shlExportToFile.setLayout(new FormLayout());
	
	Group group = new Group(shlExportToFile, SWT.NONE);
	FormData fd_group = new FormData();
	fd_group.top = new FormAttachment(0, 10);
	fd_group.right = new FormAttachment(100, -10);
	group.setLayoutData(fd_group);
	
	btnRadioButtonCSV = new Button(group, SWT.RADIO);
	btnRadioButtonCSV.addListener(SWT.Selection, e -> setupExportToCSV());
	btnRadioButtonCSV.setBounds(10, 10, 484, 18);
	btnRadioButtonCSV.setText("CSV text file");
	btnRadioButtonCSV.setSelection(true);
	
	btnRadioButtonXLS = new Button(group, SWT.RADIO);
	btnRadioButtonXLS.addListener(SWT.Selection, e -> setupExportToXLS());
	btnRadioButtonXLS.setBounds(10, 34, 484, 18);
	btnRadioButtonXLS.setText("Excel spreadsheet file (.XLS)");
	
	btnRadioButtonXLSX = new Button(group, SWT.RADIO);
	btnRadioButtonXLSX.addListener(SWT.Selection, e -> setupExportToXLSX());
	btnRadioButtonXLSX.setBounds(10, 58, 484, 18);
	btnRadioButtonXLSX.setText("Excel spreadsheet file (.XLSX)");
	
	Label lblExportTo = new Label(shlExportToFile, SWT.NONE);
	fd_group.left = new FormAttachment(lblExportTo, 6);
	FormData fd_lblExportTo = new FormData();
	fd_lblExportTo.top = new FormAttachment(0, 10);
	fd_lblExportTo.left = new FormAttachment(0, 10);
	lblExportTo.setLayoutData(fd_lblExportTo);
	lblExportTo.setText("Export to:");
	
	Button btnExport = new Button(shlExportToFile, SWT.NONE);
	btnExport.addListener(SWT.Selection, e -> doExport());
	FormData fd_btnExport = new FormData();
	fd_btnExport.top = new FormAttachment(group, 6);
	fd_btnExport.right = new FormAttachment(100, -10);
	btnExport.setLayoutData(fd_btnExport);
	btnExport.setText("Export");
	
	Button btnCancel = new Button(shlExportToFile, SWT.NONE);
	btnCancel.addListener(SWT.Selection, e -> close());
	btnCancel.setSelection(true);
	FormData fd_btnNewButton = new FormData();
	fd_btnNewButton.top = new FormAttachment(group, 6);
	fd_btnNewButton.right = new FormAttachment(btnExport, -10);
	btnCancel.setLayoutData(fd_btnNewButton);
	btnCancel.setText("Cancel");
	
	shlExportToFile.pack();
}