Code Monkey home page Code Monkey logo

eclipse.platform.swt's Introduction

SWT Matrix Build SWT Matrix Tests

About

SWT is a cross-platform GUI library for JVM based desktop applications. The best known SWT-based application is Eclipse.

Getting Started

SWT comes with platform-specific jar files. Download them from https://download.eclipse.org/eclipse/downloads/index.html and add the jar file to your classpath.

Example

Example

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class HelloWorld {

	public static void main(String[] args) {
		final Display display = new Display();

		final Shell shell = new Shell(display);
		shell.setText("Hello World");
		shell.setLayout(new GridLayout(2, false));

		final Label label = new Label(shell, SWT.LEFT);
		label.setText("Your &Name:");
		label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

		final Text text = new Text(shell, SWT.BORDER | SWT.SINGLE);
		final GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
		data.minimumWidth = 120;
		text.setLayoutData(data);

		final Button button = new Button(shell, SWT.PUSH);
		button.setText("Say Hello");
		shell.setDefaultButton(button);
		button.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false, 2, 1));

		final Label output = new Label(shell, SWT.CENTER);
		output.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

		button.addListener(SWT.Selection, event -> {
			String name = text.getText().trim();
			if (name.length() == 0) {
				name = "world";
			}
			output.setText("Hello " + name + "!");
		});

		shell.setSize(shell.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}

		display.dispose();
	}
}

First, a Display is created which is something like the central place of all GUI-related code. Then a Shell is created which in our example is a top-level window. Then all child controls and listeners are created, including their layout information. Finally, we set the window's size determines by its child controls and open the window. The while-loop processes all GUI related events until the shell is disposed which happens when closing. Before exiting, any claimed GUI resources needs to be freed.

Contributing to SWT

Thanks for your interest in this project.

See https://github.com/eclipse-platform/.github/blob/main/CONTRIBUTING.md for contributing to Eclipse Platform in general.

Developer resources:

See the following description for how to contribute a feature or a bug fix to SWT.

Information regarding source code management, builds, coding standards, and more and be found under the following link.

Contributor License Agreement:

Before your contribution can be accepted by the project, you need to create and electronically sign the Eclipse Foundation Contributor License Agreement (CLA).

Contact:

Contact the project developers via the project's "dev" list.

Search for bugs:

SWT used to track ongoing development and issues in Bugzilla .

Create a new bug:

You can register bugs and feature requests in the Github Issue Tracker. Remember that contributions are always welcome!

Please bear in mind that this project is almost entirely developed by volunteers. If you do not provide the implementation yourself (or pay someone to do it for you), the bug might never get fixed. If it is a serious bug, other people than you might care enough to provide a fix.

eclipse.platform.swt's People

Contributors

arunkumart avatar akurtakov avatar eclipse-releng-bot avatar squarti avatar ericwill avatar lshanmug avatar niraj-modi avatar syntevoalex avatar grant-g avatar mkeller avatar pauldpong avatar sravanlakkimsetti avatar vogella avatar carmacleod avatar nnemkin avatar iloveeclipse avatar bogg avatar dependabot[bot] avatar hanneswell avatar joel-majano avatar trancexpress avatar ecljpseb0t avatar mickaelistria avatar laeubi avatar heikoklare avatar carstenartur avatar rolftheunissen avatar jonahgraham avatar conradgroth avatar snjeza avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.