Solved

How to quit a GUI application in SWT?

Posted on 2013-06-19
1
352 Views
Last Modified: 2013-06-21
Hi,
I am working on a GUI application and I use SWT.

I wonder how I can quit this application by clicking a button in the toolbar just like closing it by pressing the x sign on the corner of the window.

This is the code that creates the quit icon :

       
CustomToolbar custToolBar33333 = new CustomToolbar(compTB3, SWT.FLAT, "Next Actions");      
    
        item33333333 = new ToolItem(custToolBar33333.getToolBar(), SWT.PUSH);
        item33333333.setImage(image_exit); item33333333.setText("Quit"); item33333333.setToolTipText("Quit the tool");
        item3333333.addListener(SWT.Selection, toolBarListener);

Open in new window

0
Comment
Question by:Tolgar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
Valeri earned 500 total points
ID: 39264353
in listener class add this code for this item:

try {
  if (!shell.isDisposed()) {
    shell.close();
    shell.dispose();
  }
} finally {
  display.dispose();
}

also you have to change "setShell" method in this way:

public void setShell(Shell shell, Display display) {
  this.shell = shell; this.display = display;
}

and to add reference to Display as a member of this class.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question