Create a Hello World SWT application (как создать приложение с использованием оконных форм на яве)

Пример для эклипс.

1) открываем окна = If you're not already in the Java perspective, in the main menu select (ВЫБЕРЕТЕ В ГЛАВНОМ МЕНЮ-)

Window > Open Perspective > Java

2) Open the Import wizard from the main menu via (МЕНЮ ИМПОРТА ЧЕРЕЗ ГЛАВНОЕ МЕНЮ)

File > Import...

, and select

Plug-in Development > Plug-ins and Fragments. 

Click Next.

On the Import Plug-ins and Fragments page, select
(НАСТРАИВАЕМ ИМПОРТ)

  1. Import from: The active target platform.
  2. Plug-ins and Fragments to import: Select from all plug-ins and fragments found at specified location.
  3. Import As: Projects with source folders.

Click Next.

ДАЛЕЕ ВЫБИРАЕМ ЧТО ИМЕННО МЫ ЖЕЛАЕМ ИМПОРТИРОВАТЬ - КАКУЮ БИБЛИОТЕКУ
On the Selection page, Add org.eclipse.swt.{platform}.{os}.{arch} (for example: НАМ НУЖНО ВЫБРАТЬ ФАЙЛ ДЛЯ WINDOWS который содержит определения графического интерфейса, выберете что-то вроде(зависит от вашей системы)

org.eclipse.swt.win32.win32.x86 for win32

to Plug-ins and Fragments to Import: list.
)
Click Finish.

This will create the org.eclipse.swt.{platform}.{os}.{arch} project which we will need to compile and run the application.

теперь мы добавили проект org.eclipse.swt.{platform}.{os}.{arch} - это позволит нам далее обращаться к функционалу библиотеки - кстати, заметьте, что теперь, все файлы этой библиотеки лежат в директории нашего рабочего пространства - то есть они там явно представлены.

3) Now we need a project to store our own source code. In the main toolbar, click on the New Java Project button. Enter HelloWorldSWT for the project name, then
click Finish.

Теперь нам необходимо создать "проект" для хранения нашего собственного исходного кода .
О том, что видимо подразумевает под словом "проект" читайте здесь
Чтобы создать новый проект в главном меню эклипса выберете =

file -> new  -> Java Project

в появившемся окне укажите имя проекта в поле project name и нажмите книпку Finish данного окна .

движемся далее =

Since our project requires SWT, we need to specify this in the project properties. Right-click on the project and select Properties.
In the Java Build Path page open the Projects tab, add the org.eclipse.swt.{platform}.{os}.{arch} project, then click OK

4) Так так наш проект зависит от классов SWT, то мы должны указать это в свойствах проекта. Кликните правой кнопкой мыши по проекту (пакету проекта ) в окне Package Explorer и выберете раздел Properties
Далее найдите раздел Java Build Path - кликните по названию. - и откройте вкладку Projects - добавьте добавленный напи ранее пакет org.eclipse.swt.{platform}.{os}.{arch}
и нажмите OK

5) Далее нам требуется создать класс, с исходным кодом. для этого =

The next step is to create a new class. In the main toolbar, click on the New Java Class button (or the link below). If not already specified, select HelloWorldSWT/src as the source folder. Enter HelloWorldSWT for the class name and select the checkbox to create the main() method, then click Finish.
The Java editor will automatically open showing your new class.

то есть следует опять же созать новый класс используя кнопку New Java Class - указать там имя класса и выбрать в разделе методов пункт , в котором предполагается автоматическое добавление в класс main()-метода -

public static void main(String[] args)

после чего нажать кнопка FINISH формы автоматического создания класса. эклипс по-идее сразу же после нажатия продемонстрирует вам то ,что получилось - я создал класс с именем Start - вот что получилось у меня =

public class Start {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}

6) далее -

In the Java editor, enter the following Java code in the main() method:
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Hello world!");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}

display.dispose();
You will get compile errors. Right click in the Java editor and select Source > Organize Imports, then save your changes.

внутри метода main прописываем этот вот код -

Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Hello world!");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}

после чего попросим эклипс автоматически подключить определения типов, которые мы использовали для этого в главном меню выберете =

Source -> Organize Imports

и сохраните изменения - после этого в нашем коде появятся две новые инструкции import

, так что в целом получается вот что -

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


public class Start {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
    

	Display display = new Display();
	Shell shell = new Shell(display);
	shell.setText("Hello world!");
	shell.open();
	while (!shell.isDisposed()) {
	if (!display.readAndDispatch()) display.sleep();
	}
	display.dispose();
	}

}

7)

To run your application, right-click on your class in the Package Explorer and select Run As > Java Application. A new empty window should appear with the title "Hello world!".
Congratulations! You have successfully created a Hello World SWT application!

Чтобы запустить код, написанный в нашем классе - кликните по значку класса в разделе Package Explorer
и выберете =

Run As -> Java Application

Появится пустое окно с заголоком "Hellow World!" = "привет, мир! )) " -

8) Поздравляем)) добро пожаловать в мир Java ))

_____________________________________________
Источники(читать подробнее)=
Ключевые слова и фразы(для поиска)=
формы в яве
winforms in java