SWT – How to capture keyboard event

In SWT, keyboard event is represent by KeyEvent class. We can use KeyListener to receive and process a KeyEvent. The KeyEvent class has three member fields to provide information about the key that generated by event. 1) character – Display a char value of the pressed key. 2) stateMask – Check whether any other keys …

Read more

Where to download SWT Source Code?

The Standard Widget Toolkit (SWT) is an open source project. However Eclipse SWT plugin does not bundle with SWT source code. We have to manually download it ~ Here is the steps to download the SWT Source Code 1) Visit the Standard Widget Toolkit (SWT) Official Website http://www.eclipse.org/swt/ 2) Under Stable, select your operating system …

Read more

SWT – MouseListener & MouseAdapter Example

MouseListener Mouse event processing is easy to implement, we need to implement MouseListener interface and declare all the interface methods. We can attached the MouseListener to a widget with addMouseListener() method. "widget control".addMouseListener(new MouseListener() { public void mouseDown(MouseEvent e) { System.out.println("Mouse Down."); } public void mouseUp(MouseEvent e) { System.out.println("Mouse Up."); } public void mouseDoubleClick(MouseEvent e) …

Read more

SWT – TabFolder Example

What is TabFolder? In SWT, TabFolder is a subclass of a Composite class. The TabFolder can include composite object into a single container through a tabbed index. How to create a TabFolder? Here i create a TabFolder composite, add a sashForm composite into a tab 1 and Group composite into a tab 2. import org.eclipse.swt.SWT; …

Read more

SWT – SashForm Example

What is SashForm? In SWT, SashForm is similar with Group, however it added one more useful feature, it’s allow user to adjust the control size at runtime environment. The SashForm provide this feature by creating a movable line between child widget (button, label, text…). When user drag the “line” it will expand one widget size …

Read more

SWT – Group Example

What is Group In SWT, Group is a subclass of a Composite class. Group is used to improve application appearance and make whole application look more organized. It will draw a rectangular border around all it’s child widgets. Group widget support five styles (actually it is nothing much different) 1) SWT.SHADOW_IN 2) SWT.SHADOW_OUT 3) SWT.SHADOW_NONE …

Read more

SWT – Button Example

In SWT, button widget consists of five buttons style. 1) Normal Button – SWT.PUSH 2) Arrow Button – SWT.ARROW 3) Toggle Button – SWT.TOGGLE 4) Check Box button – SWT.CHECK 5) Radio Button – SWT.RADIO Here i demonstrate how to create those buttons in SWT import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class …

Read more

SWT – Label Example

What is Label? The Label is the most common and frequent use widget, it’s display static information such as String or Image, and no user input involve. How to create a Label widget? This code snippet will create a label at position x=100, y=50, width = 300, height = 30, and display “I am Label” …

Read more

SWT Positioning – setBounds() or setLocation()

When we start learn about SWT GUI programming, we always want to figure out how do we positioning the Text field, Label, button and other widget. In SWT, we can use setLocation() or setLocation() method to specify the size and position of a widget or component. Here is the two methods that SWT use to …

Read more

SWT Hello World Example

SWT is stand for Standard Widget Toolkit. I do not want to explain what the benefits of it , please search Google for it. Please access SWT Official Website if you want to know more about it. Here is the simple SWT Hello World program import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class …

Read more

How to import SWT library into Eclipse Workspace?

In order to develop SWT application in Eclipse environment, we have to import SWT library into Eclipse Workspace manually. Here is the steps to import SWT library 1) Right click on Java Project – Click Properties 2) Click Java Build Path –> Libraries –> Add Variable –> Configure Variable 3) Click New –> Type a …

Read more