Questions tagged [swt]

SWT: The Standard Widget Toolkit is a user interface library for Java maintained by the Eclipse Foundation. SWT uses native widgets wherever possible to provide a look and feel consistent with the host platform. SWT is a third-party library (not included in the JVM) and applications that rely on it must distribute the appropriate library for each target operating system. Use this tag for questions about developing SWT based applications.

SWT: The Standard Widget Toolkit

SWT example

SWT is a user interface library for Java maintained by the Eclipse Foundation. SWT uses native widgets wherever possible to provide a look and feel consistent with the host platform.

SWT is a third-party library (not included in the JVM) and applications that rely on it must distribute the appropriate library for each target operating system.

Hello World

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;

public class HelloSWT {
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    Label label = new Label(shell, SWT.NONE);
    label.setText("Hello, World!");
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    display.dispose();
  }
}

Reference Documentation

6100 questions
2
votes
1 answer

Show local HTML file with JavaScript in SWT Browser widget in RAP

For my RAP-project I need to show some charts. Because I haven't found any widget for this purpose, my plan was to use the browser widget, so I can use JavaScript-Plugins like Highcharts or Chartsjs. But I can't get it working. If I set an HTML-File…
2
votes
2 answers

Java swt KeyListener "solution" barcode reading

I found some good Q/A here on my problem but couldn't find the right one. I have a barcode reader that reads barcode and sends scanned code as keyboard input. It is alright I can catch input easily browser.addKeyListener(new KeyAdapter() { …
Kyslik
  • 8,217
  • 5
  • 54
  • 87
2
votes
0 answers

SWT Timeout on OSX, Application hangs

since i installed the OSX Java Update (2013-004, updates JRE to 1.6.0_51) my rcp will not start anymore. Started from console, i get a msg like this: [Java CocoaComponent compatibility mode]: Enabled [Java CocoaComponent compatibility mode]: Setting…
hage
  • 95
  • 11
2
votes
2 answers

How to get absolute paths from FileDialog from different folders

One way to open multiple files in SWT is to use a FileDialog: FileDialog dialog = new FileDialog(shell, SWT.MULTI); dialog.open(); System.out.println(dialog.getFilterPath()); System.out.println(Arrays.toString(dialog.getFileNames())); and each…
fgb
  • 18,439
  • 2
  • 38
  • 52
2
votes
2 answers

Attaching an Eclipse detached view programmatically

I have programmatically detached a view from eclipse. now I want to attach it back. What is the best efficient way to do that.
Abhishek Choudhary
  • 8,255
  • 19
  • 69
  • 128
2
votes
1 answer

JFace MasterDetailsPart - details Page is not shown

I've got some trouble using JFace MasterDetailsPart for the first time. The details page is not shown - and when I select a new Item, the event is not fired. I couldn't find any good example or tutorial for this, even the JavaDoc could not help…
Mirco
  • 2,940
  • 5
  • 34
  • 57
2
votes
0 answers

SWT anti-aliasing control shapes

I have a NO_TRIM shell with rounded corners, created by applying a Region. The problem is, I'd like the edges of the shell to be anti-aliased, which I don't know how to do with applying a Region or any other way. Right now I have…
Eugene Marin
  • 1,706
  • 3
  • 23
  • 35
2
votes
3 answers

White, read-only Text field in SWT

I'm trying to make a large white box in an SWT window to display information. I want this to look different from a label but I also want it to be non-editable. So far I've only been able to create a noon-editable text box with a grey back (top). I'm…
CodyBugstein
  • 21,984
  • 61
  • 207
  • 363
2
votes
0 answers

Hang on Mac with zoomed desktop when starting an app. with both Swing & SWT

I am on a Mac ( tested it with 10.6.4, 10.7.5 & 10.8.2 ) with my desktop zoomed. When lunching my Java application that use both Swing and SWT the window is freezing right at the opening. The issue can also be reproduced with the snippet 337…
2
votes
1 answer

Layouting a large number of draw2d widgets in a Canvas

We are facing a problem, in handling a large number of Draw2d Figures, in a single Canvas. We are building a Tree of the nodes, with Connections between a parent, and a child node. The number of figures, in the canvas are of the order of 10000 (just…
Saurabh
  • 63
  • 8
2
votes
3 answers

Asynchronously control the BusyIndicator

Apparently all Eclipse/SWT has in the way of managing the busy mouse indicator is BusyIndicator.showWhile(Runnable synchronousStuffToDo) However, I have a fundamentally event-oriented project where "stuff to do" doesn't happen within a sequential…
Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436
2
votes
1 answer

SWT Bullet Change Entire Background

I'm trying to highlight the bullet background of the currently active line but if I just set the background color of the bullet it only highlights the number portion. I would like all the space occupied by the bullet to highlighted. I would like…
Alchitry
  • 1,369
  • 1
  • 16
  • 29
2
votes
2 answers

JAVA How to get SWT or JFace internal images

Does anybody know where are and how can I obtain internal images which are used by SWT/JFace, like WARNING, ERROR or INFORMATION icons and others...? Where are they situated and how to get them into my code ?
To Kra
  • 3,344
  • 3
  • 38
  • 45
2
votes
2 answers

how to automate Open Office with JAVA and SWT OleAutomation?

I have successfully programmed automation of Microsoft Word with Java and SWT. Now I need to do the same for Open Office / Libre Office writter. In case of MS Word I used Word.Application, something like that: ... wordSite = new OleClientSite(frame,…
norbi771
  • 814
  • 2
  • 12
  • 29
2
votes
1 answer

What's the difference between the 'show' and the 'paint' events in SWT?

The list of SWT constants in the SWT API supplies two very similar event types (for use with various event listeners): Show Paint What's the difference? Wouldn't all 'Show' events require a 'Paint' event and all 'Paint' events require a 'Show'…
ChaimKut
  • 2,759
  • 3
  • 38
  • 64