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
16
votes
5 answers

swt browser No more handles Error

I wrote a simple program. just a CTabFolder and a WelcomTab inherent from CTabItem. I want to fill my WelcomeTab by a browser which render my htmls. at the init() method of WelcomeTab I Create a Browser but when program want to construct it I get…
Isa Hekmat
  • 758
  • 1
  • 7
  • 19
16
votes
6 answers

How do I add an icon as a classpath resource to an SWT window created with WindowBuilder?

I'm trying to add an external icon from an *.ico file to a window that I'm creating using the WindowBuilder design window. I can select the shell, which brings up an "image" properties field. That brings up the image chooser dialog box: How do I…
Zoot
  • 2,217
  • 4
  • 29
  • 47
16
votes
2 answers

Updating SWT objects from another thread

In my Java application, when the main module is invoked, i start my SWT GUI in a separate thread. I need to perform some long opertations in the main thread and update the GUI thread. When I try to update the GUI thread from the main thread i.e.…
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
16
votes
7 answers

How do I resize the dropdown of a combobox?

Background: I am doing some UI work in an eclipse environment where I fill a combo control with some values. The string values have an different length and often a length greater than the combo width and the width of the parent…
Dirk
  • 161
  • 1
  • 3
16
votes
4 answers

swt.jar where is it?

Anyone know where I can download swt.jar?
Xander
  • 9,069
  • 14
  • 70
  • 129
16
votes
6 answers

How do you force a java swt program to "move itself to the foreground"?

Currently with swt, I sometimes want a program to arbitrarily come to the foreground (like an alarm clock might). Typically the following works (jruby): @shell.setMinimized(false) @shell.forceActive This brings the shell to the front if it was…
rogerdpack
  • 62,887
  • 36
  • 269
  • 388
16
votes
2 answers

Undo and Redo in WYSYWYG contentEditable in SWT doesn't work

I'm doing a WYSYWYG HTML5 editor With SWT by setting the contentEditable attribute of the body tag to true. When I'm executing some commands like document.execCommand('bold'), it works perfectly. But when I try to undo an operation with…
Jbprod
  • 209
  • 2
  • 8
16
votes
3 answers

Is there an equivalent in Java for fieldset (HTML)?

Is there an element in Java (i.e. Swing/AWT or SWT) that is equivalent to the HTML element fieldset?
RedhopIT
  • 609
  • 2
  • 7
  • 20
15
votes
2 answers

How to hide/delete column in SWT table

Which approach to use to have ability to hide/delete columns in the table in SWT (in Eclipse plugin in particular)? A cannot transfer this functionality to rows, since I need insert and hide(or delete) of both rows and columns. I tried to delete…
Ivan Sopov
  • 2,300
  • 4
  • 21
  • 39
15
votes
1 answer

What does JFace add to SWT?

What is the difference betweem the following: TreeViewer & Tree TableViewer & Table TreeViewerColumn & TreeColumn TableViewerColumn & TableColumn When to use viewer & regular widget? PS: It would a great help if you can help me find a good…
Reddy
  • 1,620
  • 6
  • 26
  • 33
15
votes
2 answers

Java SWT Browser. Different output on screens with Ultra HD (4K) or higher resolutions

We use SWT browser in our java app to render HTML content. The problems arise when the environment has a very high resolution (4K). When the content has a such html:
benchpresser
  • 2,171
  • 2
  • 23
  • 41
15
votes
4 answers

Java swt - Get actual x,y coordinates from Image after scaling and zooming

I have an image that has been scaled to fit. From the scaled image a user is selecting a rectangle. I then re-draw based on this selection: gc.drawImage(imageDisplayed, minX, minY, width, height, imageDisplayed.getBounds().x, …
Robben_Ford_Fan_boy
  • 8,494
  • 11
  • 64
  • 85
15
votes
2 answers

Best Practices - SWT Table, TableViewer, EditingSupport

I am adding a table to my main GUI. It does show up and has the data it is suppose to show. But I feel like I have a big mess of code and it is not structured correctly. I am looking for someone that uses SWT a lot to help me put the right pieces of…
jkteater
  • 1,381
  • 3
  • 36
  • 69
15
votes
1 answer

Can I detect change in text fields in SWT?

I have a couple of SWT widgets. I am trying to create an action if there is any modification in any of the fields present. Example: If I change the name from the Text I should be able to identify it. I tried searching online for a solution but…
noMAD
  • 7,744
  • 19
  • 56
  • 94
15
votes
8 answers

A more advanced table/spreadsheet SWT implementation

I'm developing an application based on Eclipse's Rich Client Platform that relies heavily on the use of tables for showing and editing data. I'm currently using the SWT implementations of Table and TableViewer. My users are forever complaining that…
Tirno
  • 1,568
  • 2
  • 16
  • 21