List of usage examples for org.eclipse.swt.widgets Label setLayoutData
public void setLayoutData(Object layoutData)
From source file:org.eclipse.swt.examples.imageanalyzer.ImageAnalyzer.java
void createWidgets() { // Add the widgets to the shell in a grid layout. GridLayout layout = new GridLayout(); layout.marginHeight = 0;//from w w w.ja va2s .co m layout.numColumns = 2; shell.setLayout(layout); // Add a composite to contain some control widgets across the top. Composite controls = new Composite(shell, SWT.NONE); RowLayout rowLayout = new RowLayout(); rowLayout.marginTop = 5; rowLayout.marginBottom = 5; rowLayout.spacing = 8; controls.setLayout(rowLayout); GridData gridData = new GridData(); gridData.horizontalSpan = 2; controls.setLayoutData(gridData); // Combo to change the background. Group group = new Group(controls, SWT.NONE); group.setLayout(new RowLayout()); group.setText(bundle.getString("Background")); backgroundCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY); backgroundCombo.setItems(bundle.getString("None"), bundle.getString("White"), bundle.getString("Black"), bundle.getString("Red"), bundle.getString("Green"), bundle.getString("Blue")); backgroundCombo.select(backgroundCombo.indexOf(bundle.getString("White"))); backgroundCombo.addSelectionListener(widgetSelectedAdapter(event -> changeBackground())); // Combo to change the compression ratio. group = new Group(controls, SWT.NONE); group.setLayout(new GridLayout(3, true)); group.setText(bundle.getString("Save_group")); imageTypeCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY); String[] types = { "JPEG", "PNG", "GIF", "ICO", "TIFF", "BMP" }; for (String type : types) { imageTypeCombo.add(type); } imageTypeCombo.select(imageTypeCombo.indexOf("JPEG")); imageTypeCombo.addSelectionListener(widgetSelectedAdapter(event -> { int index = imageTypeCombo.getSelectionIndex(); switch (index) { case 0: compressionCombo.setEnabled(true); compressionRatioLabel.setEnabled(true); if (compressionCombo.getItemCount() == 100) break; compressionCombo.removeAll(); for (int i = 0; i < 100; i++) { compressionCombo.add(String.valueOf(i + 1)); } compressionCombo.select(compressionCombo.indexOf("75")); break; case 1: compressionCombo.setEnabled(true); compressionRatioLabel.setEnabled(true); if (compressionCombo.getItemCount() == 10) break; compressionCombo.removeAll(); for (int i = 0; i < 4; i++) { compressionCombo.add(String.valueOf(i)); } compressionCombo.select(0); break; case 2: case 3: case 4: case 5: compressionCombo.setEnabled(false); compressionRatioLabel.setEnabled(false); break; } })); imageTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); compressionRatioLabel = new Label(group, SWT.NONE); compressionRatioLabel.setText(bundle.getString("Compression")); compressionRatioLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); compressionCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY); for (int i = 0; i < 100; i++) { compressionCombo.add(String.valueOf(i + 1)); } compressionCombo.select(compressionCombo.indexOf("75")); compressionCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // Combo to change the x scale. String[] values = { "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2", "3", "4", "5", "6", "7", "8", "9", "10", }; group = new Group(controls, SWT.NONE); group.setLayout(new RowLayout()); group.setText(bundle.getString("X_scale")); scaleXCombo = new Combo(group, SWT.DROP_DOWN); for (String value : values) { scaleXCombo.add(value); } scaleXCombo.select(scaleXCombo.indexOf("1")); scaleXCombo.addSelectionListener(widgetSelectedAdapter(event -> scaleX())); // Combo to change the y scale. group = new Group(controls, SWT.NONE); group.setLayout(new RowLayout()); group.setText(bundle.getString("Y_scale")); scaleYCombo = new Combo(group, SWT.DROP_DOWN); for (String value : values) { scaleYCombo.add(value); } scaleYCombo.select(scaleYCombo.indexOf("1")); scaleYCombo.addSelectionListener(widgetSelectedAdapter(event -> scaleY())); // Combo to change the alpha value. group = new Group(controls, SWT.NONE); group.setLayout(new RowLayout()); group.setText(bundle.getString("Alpha_K")); alphaCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY); for (int i = 0; i <= 255; i += 5) { alphaCombo.add(String.valueOf(i)); } alphaCombo.select(alphaCombo.indexOf("255")); alphaCombo.addSelectionListener(widgetSelectedAdapter(event -> alpha())); // Check box to request incremental display. group = new Group(controls, SWT.NONE); group.setLayout(new RowLayout()); group.setText(bundle.getString("Display")); incrementalCheck = new Button(group, SWT.CHECK); incrementalCheck.setText(bundle.getString("Incremental")); incrementalCheck.setSelection(incremental); incrementalCheck.addSelectionListener( widgetSelectedAdapter(event -> incremental = ((Button) event.widget).getSelection())); // Check box to request transparent display. transparentCheck = new Button(group, SWT.CHECK); transparentCheck.setText(bundle.getString("Transparent")); transparentCheck.setSelection(transparent); transparentCheck.addSelectionListener(widgetSelectedAdapter(event -> { transparent = ((Button) event.widget).getSelection(); if (image != null) { imageCanvas.redraw(); } })); // Check box to request mask display. maskCheck = new Button(group, SWT.CHECK); maskCheck.setText(bundle.getString("Mask")); maskCheck.setSelection(showMask); maskCheck.addSelectionListener(widgetSelectedAdapter(event -> { showMask = ((Button) event.widget).getSelection(); if (image != null) { imageCanvas.redraw(); } })); // Check box to request background display. backgroundCheck = new Button(group, SWT.CHECK); backgroundCheck.setText(bundle.getString("Background")); backgroundCheck.setSelection(showBackground); backgroundCheck.addSelectionListener( widgetSelectedAdapter(event -> showBackground = ((Button) event.widget).getSelection())); // Group the animation buttons. group = new Group(controls, SWT.NONE); group.setLayout(new RowLayout()); group.setText(bundle.getString("Animation")); // Push button to display the previous image in a multi-image file. previousButton = new Button(group, SWT.PUSH); previousButton.setText(bundle.getString("Previous")); previousButton.setEnabled(false); previousButton.addSelectionListener(widgetSelectedAdapter(event -> previous())); // Push button to display the next image in a multi-image file. nextButton = new Button(group, SWT.PUSH); nextButton.setText(bundle.getString("Next")); nextButton.setEnabled(false); nextButton.addSelectionListener(widgetSelectedAdapter(event -> next())); // Push button to toggle animation of a multi-image file. animateButton = new Button(group, SWT.PUSH); animateButton.setText(bundle.getString("Animate")); animateButton.setEnabled(false); animateButton.addSelectionListener(widgetSelectedAdapter(event -> animate())); // Label to show the image file type. typeLabel = new Label(shell, SWT.NONE); typeLabel.setText(bundle.getString("Type_initial")); typeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Canvas to show the image. imageCanvas = new Canvas(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND); imageCanvas.setBackground(whiteColor); imageCanvas.setCursor(crossCursor); gridData = new GridData(); gridData.verticalSpan = 15; gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; imageCanvas.setLayoutData(gridData); imageCanvas.addPaintListener(event -> { if (image == null) { Rectangle bounds = imageCanvas.getBounds(); event.gc.fillRectangle(0, 0, bounds.width, bounds.height); } else { paintImage(event); } }); imageCanvas.addMouseMoveListener(event -> { if (image != null) { showColorAt(event.x, event.y); } }); // Set up the image canvas scroll bars. ScrollBar horizontal = imageCanvas.getHorizontalBar(); horizontal.setVisible(true); horizontal.setMinimum(0); horizontal.setEnabled(false); horizontal .addSelectionListener(widgetSelectedAdapter(event -> scrollHorizontally((ScrollBar) event.widget))); ScrollBar vertical = imageCanvas.getVerticalBar(); vertical.setVisible(true); vertical.setMinimum(0); vertical.setEnabled(false); vertical.addSelectionListener(widgetSelectedAdapter(event -> scrollVertically((ScrollBar) event.widget))); // Label to show the image size. sizeLabel = new Label(shell, SWT.NONE); sizeLabel.setText(bundle.getString("Size_initial")); sizeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the image depth. depthLabel = new Label(shell, SWT.NONE); depthLabel.setText(bundle.getString("Depth_initial")); depthLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the transparent pixel. transparentPixelLabel = new Label(shell, SWT.NONE); transparentPixelLabel.setText(bundle.getString("Transparent_pixel_initial")); transparentPixelLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the time to load. timeToLoadLabel = new Label(shell, SWT.NONE); timeToLoadLabel.setText(bundle.getString("Time_to_load_initial")); timeToLoadLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Separate the animation fields from the rest of the fields. Label separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the logical screen size for animation. screenSizeLabel = new Label(shell, SWT.NONE); screenSizeLabel.setText(bundle.getString("Animation_size_initial")); screenSizeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the background pixel. backgroundPixelLabel = new Label(shell, SWT.NONE); backgroundPixelLabel.setText(bundle.getString("Background_pixel_initial")); backgroundPixelLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the image location (x, y). locationLabel = new Label(shell, SWT.NONE); locationLabel.setText(bundle.getString("Image_location_initial")); locationLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the image disposal method. disposalMethodLabel = new Label(shell, SWT.NONE); disposalMethodLabel.setText(bundle.getString("Disposal_initial")); disposalMethodLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the image delay time. delayTimeLabel = new Label(shell, SWT.NONE); delayTimeLabel.setText(bundle.getString("Delay_initial")); delayTimeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the background pixel. repeatCountLabel = new Label(shell, SWT.NONE); repeatCountLabel.setText(bundle.getString("Repeats_initial")); repeatCountLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Separate the animation fields from the palette. separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show if the image has a direct or indexed palette. paletteLabel = new Label(shell, SWT.NONE); paletteLabel.setText(bundle.getString("Palette_initial")); paletteLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Canvas to show the image's palette. paletteCanvas = new Canvas(shell, SWT.BORDER | SWT.V_SCROLL | SWT.NO_REDRAW_RESIZE); paletteCanvas.setFont(fixedWidthFont); paletteCanvas.getVerticalBar().setVisible(true); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; GC gc = new GC(paletteLabel); paletteWidth = gc.stringExtent(bundle.getString("Max_length_string")).x; gc.dispose(); gridData.widthHint = paletteWidth; gridData.heightHint = 16 * 11; // show at least 16 colors paletteCanvas.setLayoutData(gridData); paletteCanvas.addPaintListener(event -> { if (image != null) paintPalette(event); }); // Set up the palette canvas scroll bar. vertical = paletteCanvas.getVerticalBar(); vertical.setVisible(true); vertical.setMinimum(0); vertical.setIncrement(10); vertical.setEnabled(false); vertical.addSelectionListener(widgetSelectedAdapter(event -> scrollPalette((ScrollBar) event.widget))); // Sash to see more of image or image data. sash = new Sash(shell, SWT.HORIZONTAL); gridData = new GridData(); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; sash.setLayoutData(gridData); sash.addSelectionListener(widgetSelectedAdapter(event -> { if (event.detail != SWT.DRAG) { ((GridData) paletteCanvas.getLayoutData()).heightHint = SWT.DEFAULT; Rectangle paletteCanvasBounds = paletteCanvas.getBounds(); int minY = paletteCanvasBounds.y + 20; Rectangle dataLabelBounds = dataLabel.getBounds(); int maxY = statusLabel.getBounds().y - dataLabelBounds.height - 20; if (event.y > minY && event.y < maxY) { Rectangle oldSash = sash.getBounds(); sash.setBounds(event.x, event.y, event.width, event.height); int diff = event.y - oldSash.y; Rectangle bounds = imageCanvas.getBounds(); imageCanvas.setBounds(bounds.x, bounds.y, bounds.width, bounds.height + diff); bounds = paletteCanvasBounds; paletteCanvas.setBounds(bounds.x, bounds.y, bounds.width, bounds.height + diff); bounds = dataLabelBounds; dataLabel.setBounds(bounds.x, bounds.y + diff, bounds.width, bounds.height); bounds = dataText.getBounds(); dataText.setBounds(bounds.x, bounds.y + diff, bounds.width, bounds.height - diff); //shell.layout(true); } } })); // Label to show data-specific fields. dataLabel = new Label(shell, SWT.NONE); dataLabel.setText(bundle.getString("Pixel_data_initial")); gridData = new GridData(); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; dataLabel.setLayoutData(gridData); // Text to show a dump of the data. dataText = new StyledText(shell, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL); dataText.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); dataText.setFont(fixedWidthFont); gridData = new GridData(); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.heightHint = 128; gridData.grabExcessVerticalSpace = true; dataText.setLayoutData(gridData); dataText.addMouseListener(MouseListener.mouseDownAdapter(event -> { if (image != null && event.button == 1) { showColorForData(); } })); dataText.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent event) { if (image != null) { showColorForData(); } } }); // Label to show status and cursor location in image. statusLabel = new Label(shell, SWT.NONE); statusLabel.setText(""); gridData = new GridData(); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; statusLabel.setLayoutData(gridData); }
From source file:ImageAnalyzer.java
void createWidgets() { // Add the widgets to the shell in a grid layout. GridLayout layout = new GridLayout(); layout.marginHeight = 0;/*from w ww. j a v a 2 s . c o m*/ layout.numColumns = 2; shell.setLayout(layout); // Separate the menu bar from the rest of the widgets. Label separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); GridData gridData = new GridData(); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; separator.setLayoutData(gridData); // Add a composite to contain some control widgets across the top. Composite controls = new Composite(shell, SWT.NULL); RowLayout rowLayout = new RowLayout(); rowLayout.marginTop = 0; rowLayout.marginBottom = 5; rowLayout.spacing = 8; controls.setLayout(rowLayout); gridData = new GridData(); gridData.horizontalSpan = 2; controls.setLayoutData(gridData); // Combo to change the background. Group group = new Group(controls, SWT.NULL); group.setLayout(new RowLayout()); group.setText("Background"); backgroundCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY); backgroundCombo.setItems(new String[] { "None", "White", "Black", "Red", "Green", "Blue" }); backgroundCombo.select(backgroundCombo.indexOf("White")); backgroundCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { changeBackground(); } }); // Combo to change the x scale. String[] values = { "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2", "3", "4", "5", "6", "7", "8", "9", "10", }; group = new Group(controls, SWT.NULL); group.setLayout(new RowLayout()); group.setText("X_scale"); scaleXCombo = new Combo(group, SWT.DROP_DOWN); for (int i = 0; i < values.length; i++) { scaleXCombo.add(values[i]); } scaleXCombo.select(scaleXCombo.indexOf("1")); scaleXCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { scaleX(); } }); // Combo to change the y scale. group = new Group(controls, SWT.NULL); group.setLayout(new RowLayout()); group.setText("Y_scale"); scaleYCombo = new Combo(group, SWT.DROP_DOWN); for (int i = 0; i < values.length; i++) { scaleYCombo.add(values[i]); } scaleYCombo.select(scaleYCombo.indexOf("1")); scaleYCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { scaleY(); } }); // Combo to change the alpha value. group = new Group(controls, SWT.NULL); group.setLayout(new RowLayout()); group.setText("Alpha_K"); alphaCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY); for (int i = 0; i <= 255; i += 5) { alphaCombo.add(String.valueOf(i)); } alphaCombo.select(alphaCombo.indexOf("255")); alphaCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { alpha(); } }); // Check box to request incremental display. group = new Group(controls, SWT.NULL); group.setLayout(new RowLayout()); group.setText("Display"); incrementalCheck = new Button(group, SWT.CHECK); incrementalCheck.setText("Incremental"); incrementalCheck.setSelection(incremental); incrementalCheck.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { incremental = ((Button) event.widget).getSelection(); } }); // Check box to request transparent display. transparentCheck = new Button(group, SWT.CHECK); transparentCheck.setText("Transparent"); transparentCheck.setSelection(transparent); transparentCheck.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { transparent = ((Button) event.widget).getSelection(); if (image != null) { imageCanvas.redraw(); } } }); // Check box to request mask display. maskCheck = new Button(group, SWT.CHECK); maskCheck.setText("Mask"); maskCheck.setSelection(showMask); maskCheck.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { showMask = ((Button) event.widget).getSelection(); if (image != null) { imageCanvas.redraw(); } } }); // Check box to request background display. backgroundCheck = new Button(group, SWT.CHECK); backgroundCheck.setText("Background"); backgroundCheck.setSelection(showBackground); backgroundCheck.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { showBackground = ((Button) event.widget).getSelection(); } }); // Group the animation buttons. group = new Group(controls, SWT.NULL); group.setLayout(new RowLayout()); group.setText("Animation"); // Push button to display the previous image in a multi-image file. previousButton = new Button(group, SWT.PUSH); previousButton.setText("Previous"); previousButton.setEnabled(false); previousButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { previous(); } }); // Push button to display the next image in a multi-image file. nextButton = new Button(group, SWT.PUSH); nextButton.setText("Next"); nextButton.setEnabled(false); nextButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { next(); } }); // Push button to toggle animation of a multi-image file. animateButton = new Button(group, SWT.PUSH); animateButton.setText("Animate"); animateButton.setEnabled(false); animateButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { animate(); } }); // Label to show the image file type. typeLabel = new Label(shell, SWT.NULL); typeLabel.setText("Type_initial"); typeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Canvas to show the image. imageCanvas = new Canvas(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.NO_REDRAW_RESIZE); imageCanvas.setBackground(whiteColor); imageCanvas.setCursor(crossCursor); gridData = new GridData(); gridData.verticalSpan = 15; gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; imageCanvas.setLayoutData(gridData); imageCanvas.addPaintListener(new PaintListener() { public void paintControl(PaintEvent event) { if (image != null) paintImage(event); } }); imageCanvas.addMouseMoveListener(new MouseMoveListener() { public void mouseMove(MouseEvent event) { if (image != null) { showColorAt(event.x, event.y); } } }); // Set up the image canvas scroll bars. ScrollBar horizontal = imageCanvas.getHorizontalBar(); horizontal.setVisible(true); horizontal.setMinimum(0); horizontal.setEnabled(false); horizontal.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { scrollHorizontally((ScrollBar) event.widget); } }); ScrollBar vertical = imageCanvas.getVerticalBar(); vertical.setVisible(true); vertical.setMinimum(0); vertical.setEnabled(false); vertical.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { scrollVertically((ScrollBar) event.widget); } }); // Label to show the image size. sizeLabel = new Label(shell, SWT.NULL); sizeLabel.setText("Size_initial"); sizeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the image depth. depthLabel = new Label(shell, SWT.NULL); depthLabel.setText("Depth_initial"); depthLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the transparent pixel. transparentPixelLabel = new Label(shell, SWT.NULL); transparentPixelLabel.setText("Transparent_pixel_initial"); transparentPixelLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the time to load. timeToLoadLabel = new Label(shell, SWT.NULL); timeToLoadLabel.setText("Time_to_load_initial"); timeToLoadLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Separate the animation fields from the rest of the fields. separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the logical screen size for animation. screenSizeLabel = new Label(shell, SWT.NULL); screenSizeLabel.setText("Animation_size_initial"); screenSizeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the background pixel. backgroundPixelLabel = new Label(shell, SWT.NULL); backgroundPixelLabel.setText("Background_pixel_initial"); backgroundPixelLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the image location (x, y). locationLabel = new Label(shell, SWT.NULL); locationLabel.setText("Image_location_initial"); locationLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the image disposal method. disposalMethodLabel = new Label(shell, SWT.NULL); disposalMethodLabel.setText("Disposal_initial"); disposalMethodLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the image delay time. delayTimeLabel = new Label(shell, SWT.NULL); delayTimeLabel.setText("Delay_initial"); delayTimeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the background pixel. repeatCountLabel = new Label(shell, SWT.NULL); repeatCountLabel.setText("Repeats_initial"); repeatCountLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Separate the animation fields from the palette. separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show if the image has a direct or indexed palette. paletteLabel = new Label(shell, SWT.NULL); paletteLabel.setText("Palette_initial"); paletteLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Canvas to show the image's palette. paletteCanvas = new Canvas(shell, SWT.BORDER | SWT.V_SCROLL | SWT.NO_REDRAW_RESIZE); paletteCanvas.setFont(fixedWidthFont); paletteCanvas.getVerticalBar().setVisible(true); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; GC gc = new GC(paletteLabel); paletteWidth = gc.stringExtent("Max_length_string").x; gc.dispose(); gridData.widthHint = paletteWidth; gridData.heightHint = 16 * 11; // show at least 16 colors paletteCanvas.setLayoutData(gridData); paletteCanvas.addPaintListener(new PaintListener() { public void paintControl(PaintEvent event) { if (image != null) paintPalette(event); } }); // Set up the palette canvas scroll bar. vertical = paletteCanvas.getVerticalBar(); vertical.setVisible(true); vertical.setMinimum(0); vertical.setIncrement(10); vertical.setEnabled(false); vertical.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { scrollPalette((ScrollBar) event.widget); } }); // Sash to see more of image or image data. sash = new Sash(shell, SWT.HORIZONTAL); gridData = new GridData(); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; sash.setLayoutData(gridData); sash.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { if (event.detail != SWT.DRAG) { ((GridData) paletteCanvas.getLayoutData()).heightHint = SWT.DEFAULT; Rectangle paletteCanvasBounds = paletteCanvas.getBounds(); int minY = paletteCanvasBounds.y + 20; Rectangle dataLabelBounds = dataLabel.getBounds(); int maxY = statusLabel.getBounds().y - dataLabelBounds.height - 20; if (event.y > minY && event.y < maxY) { Rectangle oldSash = sash.getBounds(); sash.setBounds(event.x, event.y, event.width, event.height); int diff = event.y - oldSash.y; Rectangle bounds = imageCanvas.getBounds(); imageCanvas.setBounds(bounds.x, bounds.y, bounds.width, bounds.height + diff); bounds = paletteCanvasBounds; paletteCanvas.setBounds(bounds.x, bounds.y, bounds.width, bounds.height + diff); bounds = dataLabelBounds; dataLabel.setBounds(bounds.x, bounds.y + diff, bounds.width, bounds.height); bounds = dataText.getBounds(); dataText.setBounds(bounds.x, bounds.y + diff, bounds.width, bounds.height - diff); // shell.layout(true); } } } }); // Label to show data-specific fields. dataLabel = new Label(shell, SWT.NULL); dataLabel.setText("Pixel_data_initial"); gridData = new GridData(); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; dataLabel.setLayoutData(gridData); // Text to show a dump of the data. dataText = new StyledText(shell, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL); dataText.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); dataText.setFont(fixedWidthFont); gridData = new GridData(); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.heightHint = 128; gridData.grabExcessVerticalSpace = true; dataText.setLayoutData(gridData); dataText.addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent event) { if (image != null && event.button == 1) { showColorForData(); } } }); dataText.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { if (image != null) { showColorForData(); } } }); // Label to show status and cursor location in image. statusLabel = new Label(shell, SWT.NULL); statusLabel.setText(""); gridData = new GridData(); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; statusLabel.setLayoutData(gridData); }
From source file:ImageAnalyzer.java
int showBMPDialog() { final int[] bmpType = new int[1]; bmpType[0] = SWT.IMAGE_BMP;// w ww. j a v a 2 s. c o m SelectionListener radioSelected = new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { Button radio = (Button) event.widget; if (radio.getSelection()) bmpType[0] = ((Integer) radio.getData()).intValue(); } }; // need to externalize strings final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM); dialog.setText("Save_as"); dialog.setLayout(new GridLayout()); Label label = new Label(dialog, SWT.NONE); label.setText("Save_as"); Button radio = new Button(dialog, SWT.RADIO); radio.setText("Save_as_type_no_compress"); radio.setSelection(true); radio.setData(new Integer(SWT.IMAGE_BMP)); radio.addSelectionListener(radioSelected); radio = new Button(dialog, SWT.RADIO); radio.setText("Save_as_type_rle_compress"); radio.setData(new Integer(SWT.IMAGE_BMP_RLE)); radio.addSelectionListener(radioSelected); radio = new Button(dialog, SWT.RADIO); radio.setText("Save_as_type_os2"); radio.setData(new Integer(SWT.IMAGE_OS2_BMP)); radio.addSelectionListener(radioSelected); label = new Label(dialog, SWT.SEPARATOR | SWT.HORIZONTAL); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Button ok = new Button(dialog, SWT.PUSH); ok.setText("OK"); GridData data = new GridData(); data.horizontalAlignment = SWT.CENTER; data.widthHint = 75; ok.setLayoutData(data); ok.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { dialog.close(); } }); dialog.pack(); dialog.open(); while (!dialog.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } return bmpType[0]; }
From source file:PaintExample.java
/** * Handles a mouseDown event./*from w w w . j a va 2 s . c om*/ * * @param event the mouse event detail information */ public void mouseDown(MouseEvent event) { if (event.button == 1) { // draw with left mouse button getPaintSurface().commitRubberbandSelection(); } else { // set text with right mouse button getPaintSurface().clearRubberbandSelection(); Shell shell = getPaintSurface().getShell(); final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setText(PaintExample.getResourceString("tool.Text.dialog.title")); dialog.setLayout(new GridLayout()); Label label = new Label(dialog, SWT.NONE); label.setText(PaintExample.getResourceString("tool.Text.dialog.message")); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); final Text field = new Text(dialog, SWT.SINGLE | SWT.BORDER); field.setText(drawText); field.selectAll(); field.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Composite buttons = new Composite(dialog, SWT.NONE); GridLayout layout = new GridLayout(2, true); layout.marginWidth = 0; buttons.setLayout(layout); buttons.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); Button ok = new Button(buttons, SWT.PUSH); ok.setText(PaintExample.getResourceString("OK")); ok.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); ok.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { drawText = field.getText(); dialog.dispose(); } }); Button cancel = new Button(buttons, SWT.PUSH); cancel.setText(PaintExample.getResourceString("Cancel")); cancel.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { dialog.dispose(); } }); dialog.setDefaultButton(ok); dialog.pack(); dialog.open(); Display display = dialog.getDisplay(); while (!shell.isDisposed() && !dialog.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } }
From source file:org.eclipse.swt.examples.imageanalyzer.ImageAnalyzer.java
int showBMPDialog() { final int[] bmpType = new int[1]; bmpType[0] = SWT.IMAGE_BMP;//ww w. ja v a 2s.co m SelectionListener radioSelected = widgetSelectedAdapter(event -> { Button radio = (Button) event.widget; if (radio.getSelection()) bmpType[0] = ((Integer) radio.getData()).intValue(); }); // need to externalize strings final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM); dialog.setText(bundle.getString("Save_as_type")); dialog.setLayout(new GridLayout()); Label label = new Label(dialog, SWT.NONE); label.setText(bundle.getString("Save_as_type_label")); Button radio = new Button(dialog, SWT.RADIO); radio.setText(bundle.getString("Save_as_type_no_compress")); radio.setSelection(true); radio.setData(Integer.valueOf(SWT.IMAGE_BMP)); radio.addSelectionListener(radioSelected); radio = new Button(dialog, SWT.RADIO); radio.setText(bundle.getString("Save_as_type_rle_compress")); radio.setData(Integer.valueOf(SWT.IMAGE_BMP_RLE)); radio.addSelectionListener(radioSelected); radio = new Button(dialog, SWT.RADIO); radio.setText(bundle.getString("Save_as_type_os2")); radio.setData(Integer.valueOf(SWT.IMAGE_OS2_BMP)); radio.addSelectionListener(radioSelected); label = new Label(dialog, SWT.SEPARATOR | SWT.HORIZONTAL); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Button ok = new Button(dialog, SWT.PUSH); ok.setText(bundle.getString("OK")); GridData data = new GridData(); data.horizontalAlignment = SWT.CENTER; data.widthHint = 75; ok.setLayoutData(data); ok.addSelectionListener(widgetSelectedAdapter(e -> dialog.close())); dialog.pack(); dialog.open(); while (!dialog.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } return bmpType[0]; }
From source file:org.eclipse.swt.examples.dnd.DNDExample.java
public void open(Display display) { Shell shell = new Shell(display); shell.setText("Drag and Drop Example"); shell.setLayout(new FillLayout()); itemImage = new Image(display, DNDExample.class.getResourceAsStream("openFolder.gif")); ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); Composite parent = new Composite(sc, SWT.NONE); sc.setContent(parent);/*from ww w .ja va 2 s . c o m*/ parent.setLayout(new FormLayout()); Label dragLabel = new Label(parent, SWT.LEFT); dragLabel.setText("Drag Source:"); Group dragWidgetGroup = new Group(parent, SWT.NONE); dragWidgetGroup.setText("Widget"); createDragWidget(dragWidgetGroup); Composite cLeft = new Composite(parent, SWT.NONE); cLeft.setLayout(new GridLayout(2, false)); Group dragOperationsGroup = new Group(cLeft, SWT.NONE); dragOperationsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1)); dragOperationsGroup.setText("Allowed Operation(s):"); createDragOperations(dragOperationsGroup); Group dragTypesGroup = new Group(cLeft, SWT.NONE); dragTypesGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); dragTypesGroup.setText("Transfer Type(s):"); createDragTypes(dragTypesGroup); dragConsole = new Text(cLeft, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI); dragConsole.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); Menu menu = new Menu(shell, SWT.POP_UP); MenuItem item = new MenuItem(menu, SWT.PUSH); item.setText("Clear"); item.addSelectionListener(widgetSelectedAdapter(e -> dragConsole.setText(""))); item = new MenuItem(menu, SWT.CHECK); item.setText("Show Event detail"); item.addSelectionListener(widgetSelectedAdapter(e -> { MenuItem eItem = (MenuItem) e.widget; dragEventDetail = eItem.getSelection(); })); dragConsole.setMenu(menu); Label dropLabel = new Label(parent, SWT.LEFT); dropLabel.setText("Drop Target:"); Group dropWidgetGroup = new Group(parent, SWT.NONE); dropWidgetGroup.setText("Widget"); createDropWidget(dropWidgetGroup); Composite cRight = new Composite(parent, SWT.NONE); cRight.setLayout(new GridLayout(2, false)); Group dropOperationsGroup = new Group(cRight, SWT.NONE); dropOperationsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 2)); dropOperationsGroup.setText("Allowed Operation(s):"); createDropOperations(dropOperationsGroup); Group dropTypesGroup = new Group(cRight, SWT.NONE); dropTypesGroup.setText("Transfer Type(s):"); createDropTypes(dropTypesGroup); Group feedbackTypesGroup = new Group(cRight, SWT.NONE); feedbackTypesGroup.setText("Feedback Type(s):"); createFeedbackTypes(feedbackTypesGroup); dropConsole = new Text(cRight, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI); dropConsole.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); menu = new Menu(shell, SWT.POP_UP); item = new MenuItem(menu, SWT.PUSH); item.setText("Clear"); item.addSelectionListener(widgetSelectedAdapter(e -> dropConsole.setText(""))); item = new MenuItem(menu, SWT.CHECK); item.setText("Show Event detail"); item.addSelectionListener(widgetSelectedAdapter(e -> { MenuItem eItem = (MenuItem) e.widget; dropEventDetail = eItem.getSelection(); })); dropConsole.setMenu(menu); if (dragEnabled) createDragSource(); if (dropEnabled) createDropTarget(); int height = 200; FormData data = new FormData(); data.top = new FormAttachment(0, 10); data.left = new FormAttachment(0, 10); dragLabel.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dragLabel, 10); data.left = new FormAttachment(0, 10); data.right = new FormAttachment(50, -10); data.height = height; dragWidgetGroup.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dragWidgetGroup, 10); data.left = new FormAttachment(0, 10); data.right = new FormAttachment(50, -10); data.bottom = new FormAttachment(100, -10); cLeft.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(0, 10); data.left = new FormAttachment(cLeft, 10); dropLabel.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dropLabel, 10); data.left = new FormAttachment(cLeft, 10); data.right = new FormAttachment(100, -10); data.height = height; dropWidgetGroup.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dropWidgetGroup, 10); data.left = new FormAttachment(cLeft, 10); data.right = new FormAttachment(100, -10); data.bottom = new FormAttachment(100, -10); cRight.setLayoutData(data); sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); sc.setExpandHorizontal(true); sc.setExpandVertical(true); Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); Rectangle monitorArea = shell.getMonitor().getClientArea(); shell.setSize(Math.min(size.x, monitorArea.width - 20), Math.min(size.y, monitorArea.height - 20)); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } itemImage.dispose(); }
From source file:DNDExample.java
public void open(Display display) { Shell shell = new Shell(display); shell.setText("Drag and Drop Example"); shell.setLayout(new FillLayout()); ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); Composite parent = new Composite(sc, SWT.NONE); sc.setContent(parent);// w w w . j a va2s .c o m parent.setLayout(new FormLayout()); Label dragLabel = new Label(parent, SWT.LEFT); dragLabel.setText("Drag Source:"); Group dragWidgetGroup = new Group(parent, SWT.NONE); dragWidgetGroup.setText("Widget"); createDragWidget(dragWidgetGroup); Composite cLeft = new Composite(parent, SWT.NONE); cLeft.setLayout(new GridLayout(2, false)); Group dragOperationsGroup = new Group(cLeft, SWT.NONE); dragOperationsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1)); dragOperationsGroup.setText("Allowed Operation(s):"); createDragOperations(dragOperationsGroup); Group dragTypesGroup = new Group(cLeft, SWT.NONE); dragTypesGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); dragTypesGroup.setText("Transfer Type(s):"); createDragTypes(dragTypesGroup); dragConsole = new Text(cLeft, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI); dragConsole.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); Menu menu = new Menu(shell, SWT.POP_UP); MenuItem item = new MenuItem(menu, SWT.PUSH); item.setText("Clear"); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { dragConsole.setText(""); } }); item = new MenuItem(menu, SWT.CHECK); item.setText("Show Event detail"); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { MenuItem item = (MenuItem) e.widget; dragEventDetail = item.getSelection(); } }); dragConsole.setMenu(menu); Label dropLabel = new Label(parent, SWT.LEFT); dropLabel.setText("Drop Target:"); Group dropWidgetGroup = new Group(parent, SWT.NONE); dropWidgetGroup.setText("Widget"); createDropWidget(dropWidgetGroup); Composite cRight = new Composite(parent, SWT.NONE); cRight.setLayout(new GridLayout(2, false)); Group dropOperationsGroup = new Group(cRight, SWT.NONE); dropOperationsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 2)); dropOperationsGroup.setText("Allowed Operation(s):"); createDropOperations(dropOperationsGroup); Group dropTypesGroup = new Group(cRight, SWT.NONE); dropTypesGroup.setText("Transfer Type(s):"); createDropTypes(dropTypesGroup); Group feedbackTypesGroup = new Group(cRight, SWT.NONE); feedbackTypesGroup.setText("Feedback Type(s):"); createFeedbackTypes(feedbackTypesGroup); dropConsole = new Text(cRight, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI); dropConsole.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); menu = new Menu(shell, SWT.POP_UP); item = new MenuItem(menu, SWT.PUSH); item.setText("Clear"); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { dropConsole.setText(""); } }); item = new MenuItem(menu, SWT.CHECK); item.setText("Show Event detail"); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { MenuItem item = (MenuItem) e.widget; dropEventDetail = item.getSelection(); } }); dropConsole.setMenu(menu); int height = 200; FormData data = new FormData(); data.top = new FormAttachment(0, 10); data.left = new FormAttachment(0, 10); dragLabel.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dragLabel, 10); data.left = new FormAttachment(0, 10); data.right = new FormAttachment(50, -10); data.height = height; dragWidgetGroup.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dragWidgetGroup, 10); data.left = new FormAttachment(0, 10); data.right = new FormAttachment(50, -10); data.bottom = new FormAttachment(100, -10); cLeft.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(0, 10); data.left = new FormAttachment(cLeft, 10); dropLabel.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dropLabel, 10); data.left = new FormAttachment(cLeft, 10); data.right = new FormAttachment(100, -10); data.height = height; dropWidgetGroup.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(dropWidgetGroup, 10); data.left = new FormAttachment(cLeft, 10); data.right = new FormAttachment(100, -10); data.bottom = new FormAttachment(100, -10); cRight.setLayoutData(data); sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); sc.setExpandHorizontal(true); sc.setExpandVertical(true); Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); Rectangle monitorArea = shell.getMonitor().getClientArea(); shell.setSize(Math.min(size.x, monitorArea.width - 20), Math.min(size.y, monitorArea.height - 20)); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
From source file:PrintKTableExample.java
/** * Sets the image displayed in the dialogs header. * /*from ww w.jav a 2s. co m*/ * @param image */ public void setDialogImage(Image image) { guiPictureArea.setBackground(guiDisplay.getSystemColor(SWT.COLOR_WHITE)); guiPictureGridData.heightHint = image.getBounds().height + 2; GridLayout layout = new GridLayout(1, true); guiPictureArea.setLayout(layout); layout.horizontalSpacing = 0; layout.verticalSpacing = 0; layout.marginHeight = 0; layout.marginWidth = 0; guiPictureLabel = new Label(guiPictureArea, SWT.NONE); guiPictureLabel.setImage(image); // guiPictureLabel.setBackground(guiDisplay.getSystemColor(SWT.COLOR_WHITE)); GridData gd = new GridData(); // gd.grabExcessHorizontalSpace = true; // gd.horizontalAlignment = GridData.FILL; guiPictureLabel.setLayoutData(gd); Label line = new Label(guiPictureArea, SWT.SEPARATOR | SWT.HORIZONTAL); gd = new GridData(); gd.grabExcessHorizontalSpace = true; gd.horizontalAlignment = GridData.FILL; line.setLayoutData(gd); }
From source file:PrintKTableExample.java
protected void createContents() { guiMainArea.setLayout(new FillLayout()); root = new Composite(guiMainArea, SWT.NONE); final GridLayout gridLayout = new GridLayout(); gridLayout.verticalSpacing = 10;// w w w . ja v a2 s . c o m gridLayout.numColumns = 2; root.setLayout(gridLayout); { final Label l = new Label(root, SWT.NONE); l.setText("Papierformat:"); final GridData gridData_2 = new GridData(); gridData_2.widthHint = 80; l.setLayoutData(gridData_2); } { combFormat = new Combo(root, SWT.BORDER | SWT.READ_ONLY); combFormat.setToolTipText( "Bestimmt die PapiergroBe. Diese muss mit der Druckereinstellung ubereinstimmen."); for (int i = 0; i < formatNames.length; i++) { combFormat.add(formatNames[i]); } combFormat.setText(format); final GridData gridData_1 = new GridData(GridData.FILL_HORIZONTAL); gridData_1.widthHint = 180; combFormat.setLayoutData(gridData_1); } { final Label label = new Label(root, SWT.NONE); label.setText("Seitenrander:"); label.setLayoutData(new GridData(GridData.FILL_BOTH)); } { cmbMargin = new Combo(root, SWT.READ_ONLY); cmbMargin.setToolTipText("Bestimmt die Breite der Rander."); cmbMargin.add("Schmale Rander"); cmbMargin.add("Normale Rander"); cmbMargin.add("Breite Rander"); cmbMargin.select(marginStyle); cmbMargin.setLayoutData(new GridData(GridData.FILL_BOTH)); } { final Label label = new Label(root, SWT.NONE); final GridData gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gridData.horizontalSpan = 1; label.setLayoutData(gridData); label.setText("Ausrichtung:"); } { butPortrait = new Button(root, SWT.RADIO); butPortrait.setToolTipText( "Bestimmt, ob das Papier hochkant oder Breit bedruckt werden soll. \nDiese Einstellung muss mit der des Druckers ubereinstimmen"); butPortrait.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); butPortrait.setText("Hochformat"); butPortrait.setSelection(portrait); } { final Label label = new Label(root, SWT.NONE); } { butLandscape = new Button(root, SWT.RADIO); butLandscape.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); butLandscape.setText("Breitformat"); butLandscape.setSelection(!portrait); butLandscape.setToolTipText( "Bestimmt, ob das Papier hochkant oder quer bedruckt werden soll. \nDiese Einstellung muss mit der des Druckers ubereinstimmen"); } { final Label label = new Label(root, SWT.NONE); label.setText("Skalierung:"); label.setLayoutData(new GridData(GridData.FILL_BOTH)); } { cmbScalierung = new Combo(root, SWT.READ_ONLY); cmbScalierung.setItems(scalings); cmbScalierung.select(10 - (scaling / 10)); cmbScalierung.setLayoutData(new GridData(GridData.FILL_BOTH)); cmbScalierung.setToolTipText( "Hiermit konnen Sie dir GroBe des Ausdrucks veringern, so daB mehr auf eine Seite passt."); } }
From source file:PrintKTableExample.java
protected void createButtonBar() { // AuBeres Composite guiButtonArea = new Composite(guiShell, SWT.NONE); GridData gd = new GridData(); gd.grabExcessHorizontalSpace = true; gd.horizontalAlignment = GridData.FILL; guiButtonArea.setLayoutData(gd);//from w w w.j av a 2 s . c o m FormLayout butLayout = new FormLayout(); guiButtonArea.setLayout(butLayout); // Trennlinie Label sep = new Label(guiButtonArea, SWT.SEPARATOR | SWT.HORIZONTAL); FormData fd = new FormData(); fd.bottom = new FormAttachment(100, -32); fd.left = new FormAttachment(0, 0); fd.right = new FormAttachment(100, 0); sep.setLayoutData(fd); }