Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Widget is disposed (newb edition)(doing my university task in Linux)
Widget is disposed (newb edition) [message #1040510] Sat, 13 April 2013 18:18 Go to next message
Andrew Ivans is currently offline Andrew IvansFriend
Messages: 1
Registered: April 2013
Junior Member
Hi all, I'm newb & I know it. I've stuck at some bug with my Eclipse in Linux (LMDE).
The trouble is described here:
Sorry for giving link (& for poor Eng too), I just didn't want to duplicate the same post, there it has good formatting already and so on.
But they say there they don't work with SWT Rolling Eyes
Here is an additional video about the trouble:

Thanks for potential help.
Re: Widget is disposed (newb edition) [message #1053700 is a reply to message #1040510] Tue, 07 May 2013 09:53 Go to previous message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
you have create the dialog again when you click on the checkme button.

the dialog is closed(disposed,hence all children also disposed) every time you click on ok.

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Label;
public class PalindromeCheck {
	 * @param args
	public static void main(String[] args) {
		// TODO Auto-generated method stub
                Display display = new Display();
                final Shell shell = new Shell(display);
                shell.setText("Palindrome check");
                final Button checkme = new Button(shell,SWT.PUSH);
                checkme.setText("Check string");
                final Text checkit = new Text(shell,SWT.SHADOW_IN);
                Listener checkmelistener = new Listener() {
	                public void handleEvent(Event event) {
	                	boolean answer=true;
	                	String check = checkit.getText();
	        	        for (int j=0; j <= ((check.length() - 1) - j); j++) {
		                	String a = Character.toString(check.charAt(j));
		                	String b = Character.toString(check.charAt((check.length() - 1) - j));
		                	if (a.compareToIgnoreCase(b) != 0) {
		                		answer=false; break;
	        	        final Shell dialog = new Shell(shell,SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
	                    dialog.setSize(250,100); dialog.setMinimumSize(250,100);
	                    final Label result = new Label(dialog,SWT.NONE);
	                    final Button ok = new Button(dialog,SWT.PUSH);
	                    Listener dialoglistener = new Listener() {
	                        public void handleEvent(Event event) {
		                result.setText((answer) ? "The string is a palindrome indeed!" : "The string is not a palindrome!");
                while (!shell.isDisposed()) {
                        if (!display.readAndDispatch()) display.sleep();

why, mr. Anderson, why, why do you persist?
Because I Choose To.
Previous Topic:Resizing an Image: Without AntiAliasing it doesnt look good
Next Topic:Sync Horizontal Scrolling across two tables
Goto Forum:

Current Time: Thu Jun 21 06:59:26 GMT 2018

Powered by FUDForum. Page generated in 0.02084 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top