blob: 07037e471464197846c8b838124a7ecfc08d0dbd [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html lang="en">
<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">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="../book.css" CHARSET="ISO-8859-1" TYPE="text/css">
<TITLE>
The Hello World view
</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<H2>
The Hello World view</H2>
<P >Now that we've created a project, package, and view class for our plug-in, we're ready to study some code.&nbsp; Here is everything you need in
your <b>HelloWorldView</b>.&nbsp; Copy the contents below into the
class you created, replacing the auto-generated content.&nbsp;</P>
<pre>
package com.example.helloworld;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.ui.part.ViewPart;
public class HelloWorldView extends ViewPart {
Label label;
public HelloWorldView() {
}
public void createPartControl(Composite parent) {
label = new Label(parent, SWT.WRAP);
label.setText(&quot;Hello World&quot;);
}
public void setFocus() {
// set focus to my widget. For a label, this doesn't
// make much sense, but for more complex sets of widgets
// you would decide which one gets the focus.
}
}
</pre>
<P >
The view part creates the widgets that will represent it in the <b> createPartControl</b> method. In this example, we create an SWT label and set the &quot;Hello World&quot; text into it. This
is about the simplest view that can be created.</P>
</BODY>
</HTML>