blob: f565271bbdebc4789f26e6aba25184b0586278bb [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2013. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../../../book.css" charset="ISO-8859-1" type="text/css">
<title>SWT Standalone Examples Setup</title>
</head>
<body>
<h2>SWT standalone examples setup</h2>
<h3>Adding SWT to your workspace</h3>
<ol>
<li>Download SWT for standalone applications. A standalone version of SWT is available
on the same download page as the Eclipse SDK. Look for the section titled
<strong>SWT Binary and Source</strong>. Do not extract the archive file, just save it to disk.
<li>Select <strong>Import...</strong> from the <strong>File</strong> menu.</li>
<li>Select <strong>Existing Projects into Workspace</strong> and click on the <strong>Next</strong> button.</li>
<li>Select <strong>Select archive file:</strong> and use the <strong>Browse</strong> button to locate the SWT
standalone archive you have previously downloaded.</li>
<li>Click on the <strong>Finish</strong> button.</li>
</ol>
<h3>Importing example source</h3>
<ol>
<li>Download and install the Eclipse Example Plug-ins. The Eclipse Example Plug-ins are available on the same
download page as the Eclipse SDK. Look for the section titled <strong>Example Plug-ins</strong>.
You can unzip the examples in the same location as you installed Eclipse or you can choose
a different location. If you install the examples in the same location as Eclipse, the example views
and editors will show up in your Eclipse environment when you select <strong>Windows &gt; Show View ... &gt; Other ... &gt; SWT Examples</strong>.
(If the SWT example views do not appear right away in your menu, restart eclipse with the <strong>-clean</strong> argument).
<li>To import the example source, select <strong>New &gt; Project ...</strong> from the <strong>File</strong> menu.
<li>Select <strong>Java Project</strong> and click on the <strong>Next</strong> button.</li>
<li>Give the java project a name such as "SWT Examples".</li>
<li>Deselect <strong>Use default location</strong> and click on the <strong>Browse ...</strong>
button to locate the following directory:
&nbsp;&nbsp;&nbsp;&nbsp;<code>eclipse/plugins/org.eclipse.sdk.examples.source_3.1.0/src/org.eclipse.swt.examples_3.1.0</code>
<li>Click on the <strong>Next</strong> button.</li>
<li>Click on the <strong>Projects</strong> tab and click on the <strong>Add</strong> button.</li>
<li>Place a check beside <strong>org.eclipse.swt</strong> and click on the <strong>OK</strong> button.</li>
<li>Click on the <strong>Finish</strong> button.</li>
</ol>
<p>At this point your SWT examples should be compiled without any errors. Check the <strong>Problems</strong>
view for errors. If you get an error like "<code>java.lang.Object</code> not found" it means
you have not configured a JRE. Go to the <strong>Window</strong> &gt; <strong>Preferences ...</strong> dialog
and select the <strong>Java</strong> &gt; <strong>Installed JREs</strong> preference page. Ensure that a JRE is installed
and that the path to the JRE is correct.</p>
<h3><a NAME="Run"></a>Running the Example</h3>
<p>Now you can run the SWT standalone examples.
<ol>
<li>Open the Java perspective.
<li>In the Packages view, select the main class that you want to run.
For example, the main class for the Address Book example is
<code>org.eclipse.swt.examples.addressbook.AddressBook</code>.
<li>Select <strong>Run</strong> &gt; <strong>Run As...</strong> &gt; <strong>Java Application</strong> from the main menu.
</ol>
<h3><a name="ExamplesOverview">Examples Overview</a></h3>
<p>
Consult the documentation of each individual example for the name of
its main class and additional details.
The following examples are included in the <code>swtexamples.jar</code>:
</p>
<ul>
<li><a href="swt_addressbook_ex.html">Address Book</a>
<li><a href="swt_browser_ex.html">Browser Example</a>
<li><a href="swt_clipboard_ex.html">Clipboard</a>
<li><a href="swt_controls_ex.html">Controls</a>
<li><a href="swt_customcontrols_ex.html">Custom Controls</a>
<li><a href="swt_dnd_ex.html">Drag and Drop Example</a>
<li><a href="swt_fileviewer_ex.html">File Viewer</a>
<li><a href="swt_helloworld_ex.html">Hello World [1-5]</a>
<li><a href="swt_hoverhelp_ex.html">Hover Help</a>
<li><a href="swt_imageanalyzer_ex.html">Image Analyzer</a>
<li><a href="swt_javaviewer_ex.html">Java Syntax Viewer</a>
<li><a href="swt_layout_ex.html">Layouts</a>
<li><a href="swt_paint_ex.html">Paint Example</a>
<li><a href="swt_texteditor_ex.html">Text Editor</a>
</ul>
</body>
</html>