SlideShare une entreprise Scribd logo
1  sur  28
Developing Java SWT Applications A Quick Start http://www.RCP-Vision.com Email: info@rcp-vision.com
SWT Applications in minutes In this short presentation we will learn how to develop and deploy  a simple SWT Application in  a matter of minutes.
Requirements The setup process however is not included in these minutes, because you will have to do some download and setting process. Anyway this is a one-time task!
Requirements Ensure you have a Java JDK installed (Java 1.5 or higher)
Download Eclipse RCP distro Go to the Eclipse download page: http://www.eclipse.org/downloads and download the RCP version of Eclipse
Extracting Eclipse RCP IDE Extract the downloaded file (e.g. “eclipse-rcp-ganymede-SR1-win32.zip”) somewhere on your local drive (e.g. on  C:) Note:  do not use the the Compressed Folder unzipper shipped with the operating system since it may not extract hidden files
Running Eclipse RCP IDE Run the Eclipse executable file  (e.g. C:clipseclipse.exe)
Running Eclipse RCP IDE Choose a workspace location
Running Eclipse RCP IDE and close the Welcome page
Create a Java Project File, New, Java Project
Create a Java Project Enter a name for the Project  (e.g. FirstSwtProject) and press the Next button
Create a Java Project Select the “Libraries” tab and press the “Add External JARs ...” button
Create a Java Project Browse and select the file <eclipse_dir>/plugins/ org.eclipse.swt.win32.win32.x86_3.4.1.v3449c.jar
Create a Java Project Select the “Order and Export” tab and check the jar file we just added (this will export this jar file in the deploy phase) and press the “Finish” button
Create a Java Class Expand the Project tree, select the “src” folder and right-click New, Class
Create a Java Class Enter a package name for the new class (e.g. “com.yourcompany.swt.test”)
Create a Java Class Enter a name for the new class (e.g. “MainForm”) and make it executable  (checking “public static void main(String[] args) then press the “Finish” button
Edit the Java Class Fill the MainForm class with the following code public   class  MainForm { private   static   int   n  = 0; public   static   void  main(String[] args) { Display display =  new  Display(); Shell shell =  new  Shell(display); shell.setText( &quot;Click counter&quot; ); shell.setBounds(100, 100, 200, 100); shell.setLayout( null ); final  Label label =  new  Label(shell, SWT. PUSH ); label.setBounds(120, 20, 30, 30); final  Button button =  new  Button(shell, SWT. PUSH ); button.setBounds(10, 10, 80, 30); button.setText( &quot;Click Me&quot; ); button.addSelectionListener( new  SelectionAdapter() { public   void  widgetSelected(SelectionEvent event) { n ++; label.setText( &quot;&quot; + n ); } }); shell.open(); while  (!shell.isDisposed()) { if  (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
Edit the Java Class In order to solve the errors that are showed: right-click on the editor area and perform a “ Source, Organize imports” operation
Edit the Java Class Choose to import the SWT Button and Label class (“org.eclipse.swt.widgets.Button” and “org.eclipse.swt.widgets.Label” )
Run the Java Class Save the class (File, Save) then Right-click on the editor area and perform a “ Run as, Java Application”
Run the Java Class You should see a form with a button  and a label showing the number  of times the button was clicked
Deploy the Application Now that we have developed our (tiny) application how do we deploy it to a client ? First of all there is a requisite: on the client there must be a Java Runtime Environment installed
Deploy the Application Right-click on the Project, Export
Deploy the Application Expand the Java node,  select “Runnable JAR file”,  then press the Next button
Deploy the Application Select the (only) runnable Class
Deploy the Application Browse and enter a name for the exported JAR (e.g. C:empyFirstSWTApp.jar), then press the Finish button
Deploy the Application Ok, we are finished! Now just double-click the exported JAR file: it is your executable Java SWT Application. It can copied and launched from any client with  a Java Runtime Environment installed!

Contenu connexe

Tendances

Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitWriting and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitAlex Chaffee
 
Testing iOS10 Apps with Appium and its new XCUITest backend
Testing iOS10 Apps with Appium and its new XCUITest backendTesting iOS10 Apps with Appium and its new XCUITest backend
Testing iOS10 Apps with Appium and its new XCUITest backendTestplus GmbH
 
Automated Xcode 7 UI Testing
Automated Xcode 7 UI TestingAutomated Xcode 7 UI Testing
Automated Xcode 7 UI TestingJouni Miettunen
 
React 101 by Anatoliy Sieryi
React 101 by Anatoliy Sieryi React 101 by Anatoliy Sieryi
React 101 by Anatoliy Sieryi Binary Studio
 
Servlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpServlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpodilodif
 
Installing JDK and first java program
Installing JDK and first java programInstalling JDK and first java program
Installing JDK and first java programsunmitraeducation
 
iOS UI Testing in Xcode
iOS UI Testing in XcodeiOS UI Testing in Xcode
iOS UI Testing in XcodeJz Chang
 
Getting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingGetting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingBitbar
 
Eclipse & android setup
Eclipse & android setupEclipse & android setup
Eclipse & android setupChina Bigs
 
SwtBot: Unit Testing Made Easy
SwtBot: Unit Testing Made EasySwtBot: Unit Testing Made Easy
SwtBot: Unit Testing Made EasyAnkit Goel
 

Tendances (16)

Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitWriting and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
 
Installing the java sdk
Installing the java sdkInstalling the java sdk
Installing the java sdk
 
Rcp by example
Rcp by exampleRcp by example
Rcp by example
 
 xctest
 xctest xctest
 xctest
 
Testing iOS10 Apps with Appium and its new XCUITest backend
Testing iOS10 Apps with Appium and its new XCUITest backendTesting iOS10 Apps with Appium and its new XCUITest backend
Testing iOS10 Apps with Appium and its new XCUITest backend
 
Automated Xcode 7 UI Testing
Automated Xcode 7 UI TestingAutomated Xcode 7 UI Testing
Automated Xcode 7 UI Testing
 
React 101 by Anatoliy Sieryi
React 101 by Anatoliy Sieryi React 101 by Anatoliy Sieryi
React 101 by Anatoliy Sieryi
 
Servlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpServlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtp
 
Installing JDK and first java program
Installing JDK and first java programInstalling JDK and first java program
Installing JDK and first java program
 
iOS UI Testing in Xcode
iOS UI Testing in XcodeiOS UI Testing in Xcode
iOS UI Testing in Xcode
 
Getting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingGetting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App Testing
 
Eclipse & android setup
Eclipse & android setupEclipse & android setup
Eclipse & android setup
 
SwtBot: Unit Testing Made Easy
SwtBot: Unit Testing Made EasySwtBot: Unit Testing Made Easy
SwtBot: Unit Testing Made Easy
 
Android programming-basics
Android programming-basicsAndroid programming-basics
Android programming-basics
 
Activity
ActivityActivity
Activity
 
Gwt portlet
Gwt portletGwt portlet
Gwt portlet
 

Similaire à Developing Java SWT Applications - A Starter

Java Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldJava Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldYakov Fain
 
Single Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code baseSingle Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code baseRalf Sternberg
 
03 eclipse basics & hello world
03   eclipse basics & hello world03   eclipse basics & hello world
03 eclipse basics & hello worldZeeshan-Shaikh
 
Unit2 java
Unit2 javaUnit2 java
Unit2 javamrecedu
 
How to write a simple java program in 10 steps
How to write a simple java program in 10 stepsHow to write a simple java program in 10 steps
How to write a simple java program in 10 stepsIshara Amarasekera
 
How to run java program without IDE
How to run java program without IDEHow to run java program without IDE
How to run java program without IDEShweta Oza
 
Easy java installation &amp; practice
Easy java installation &amp; practiceEasy java installation &amp; practice
Easy java installation &amp; practiceNooria Esmaelzade
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMmanish kumar
 
java:characteristics, classpath, compliation
java:characteristics, classpath, compliationjava:characteristics, classpath, compliation
java:characteristics, classpath, compliationShivam Singhal
 

Similaire à Developing Java SWT Applications - A Starter (20)

Java Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldJava Intro: Unit1. Hello World
Java Intro: Unit1. Hello World
 
Java part 1
Java part 1Java part 1
Java part 1
 
Single Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code baseSingle Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code base
 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
 
Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1
 
Java Lab
Java LabJava Lab
Java Lab
 
03 eclipse basics & hello world
03   eclipse basics & hello world03   eclipse basics & hello world
03 eclipse basics & hello world
 
Unit2 java
Unit2 javaUnit2 java
Unit2 java
 
Installation
InstallationInstallation
Installation
 
Dspace
DspaceDspace
Dspace
 
Jdkeclipsevs
JdkeclipsevsJdkeclipsevs
Jdkeclipsevs
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
How to write a simple java program in 10 steps
How to write a simple java program in 10 stepsHow to write a simple java program in 10 steps
How to write a simple java program in 10 steps
 
How to run java program without IDE
How to run java program without IDEHow to run java program without IDE
How to run java program without IDE
 
Any point on mac
Any point on macAny point on mac
Any point on mac
 
Mc sl54 051_ (1)
Mc sl54 051_ (1)Mc sl54 051_ (1)
Mc sl54 051_ (1)
 
Easy java installation &amp; practice
Easy java installation &amp; practiceEasy java installation &amp; practice
Easy java installation &amp; practice
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVM
 
Class 1 blog
Class 1 blogClass 1 blog
Class 1 blog
 
java:characteristics, classpath, compliation
java:characteristics, classpath, compliationjava:characteristics, classpath, compliation
java:characteristics, classpath, compliation
 

Dernier

Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 

Dernier (20)

Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Developing Java SWT Applications - A Starter

  • 1. Developing Java SWT Applications A Quick Start http://www.RCP-Vision.com Email: info@rcp-vision.com
  • 2. SWT Applications in minutes In this short presentation we will learn how to develop and deploy a simple SWT Application in a matter of minutes.
  • 3. Requirements The setup process however is not included in these minutes, because you will have to do some download and setting process. Anyway this is a one-time task!
  • 4. Requirements Ensure you have a Java JDK installed (Java 1.5 or higher)
  • 5. Download Eclipse RCP distro Go to the Eclipse download page: http://www.eclipse.org/downloads and download the RCP version of Eclipse
  • 6. Extracting Eclipse RCP IDE Extract the downloaded file (e.g. “eclipse-rcp-ganymede-SR1-win32.zip”) somewhere on your local drive (e.g. on C:) Note: do not use the the Compressed Folder unzipper shipped with the operating system since it may not extract hidden files
  • 7. Running Eclipse RCP IDE Run the Eclipse executable file (e.g. C:clipseclipse.exe)
  • 8. Running Eclipse RCP IDE Choose a workspace location
  • 9. Running Eclipse RCP IDE and close the Welcome page
  • 10. Create a Java Project File, New, Java Project
  • 11. Create a Java Project Enter a name for the Project (e.g. FirstSwtProject) and press the Next button
  • 12. Create a Java Project Select the “Libraries” tab and press the “Add External JARs ...” button
  • 13. Create a Java Project Browse and select the file <eclipse_dir>/plugins/ org.eclipse.swt.win32.win32.x86_3.4.1.v3449c.jar
  • 14. Create a Java Project Select the “Order and Export” tab and check the jar file we just added (this will export this jar file in the deploy phase) and press the “Finish” button
  • 15. Create a Java Class Expand the Project tree, select the “src” folder and right-click New, Class
  • 16. Create a Java Class Enter a package name for the new class (e.g. “com.yourcompany.swt.test”)
  • 17. Create a Java Class Enter a name for the new class (e.g. “MainForm”) and make it executable (checking “public static void main(String[] args) then press the “Finish” button
  • 18. Edit the Java Class Fill the MainForm class with the following code public class MainForm { private static int n = 0; public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText( &quot;Click counter&quot; ); shell.setBounds(100, 100, 200, 100); shell.setLayout( null ); final Label label = new Label(shell, SWT. PUSH ); label.setBounds(120, 20, 30, 30); final Button button = new Button(shell, SWT. PUSH ); button.setBounds(10, 10, 80, 30); button.setText( &quot;Click Me&quot; ); button.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { n ++; label.setText( &quot;&quot; + n ); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
  • 19. Edit the Java Class In order to solve the errors that are showed: right-click on the editor area and perform a “ Source, Organize imports” operation
  • 20. Edit the Java Class Choose to import the SWT Button and Label class (“org.eclipse.swt.widgets.Button” and “org.eclipse.swt.widgets.Label” )
  • 21. Run the Java Class Save the class (File, Save) then Right-click on the editor area and perform a “ Run as, Java Application”
  • 22. Run the Java Class You should see a form with a button and a label showing the number of times the button was clicked
  • 23. Deploy the Application Now that we have developed our (tiny) application how do we deploy it to a client ? First of all there is a requisite: on the client there must be a Java Runtime Environment installed
  • 24. Deploy the Application Right-click on the Project, Export
  • 25. Deploy the Application Expand the Java node, select “Runnable JAR file”, then press the Next button
  • 26. Deploy the Application Select the (only) runnable Class
  • 27. Deploy the Application Browse and enter a name for the exported JAR (e.g. C:empyFirstSWTApp.jar), then press the Finish button
  • 28. Deploy the Application Ok, we are finished! Now just double-click the exported JAR file: it is your executable Java SWT Application. It can copied and launched from any client with a Java Runtime Environment installed!