Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Eclipse Plug-in Developer Guide
Previous Page Home Next Page

The Hello World view

Now that we've created a project, package, and view class for our plug-in, we're ready to study some code.  Here is everything you need in your HelloWorldView.  Copy the contents below into the class you created, replacing the auto-generated content. 

   package com.example.helloworld.views;

   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("Hello World");
      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.

The view part creates the widgets that will represent it in the createPartControl method. In this example, we create an SWT label and set the "Hello World" text into it. This is about the simplest view that can be created.

  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire