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: javaprogrammingforums.com/whats-wrong-my-code/27637-widget-disposed-lmde.html
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: youtube.com/watch?v=nHviFWnrVVI

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");
                shell.setSize(255,150);
                shell.setMinimumSize(255,150);
                shell.open();
                final Button checkme = new Button(shell,SWT.PUSH);
                checkme.setText("Check string");
                checkme.setBounds(55,50,140,60);
                final Text checkit = new Text(shell,SWT.SHADOW_IN);
                checkit.setBounds(10,10,230,30);
                
 
                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);
	                    result.setBounds(10,10,230,30);
	                    final Button ok = new Button(dialog,SWT.PUSH);
	                    ok.setBounds(105,35,35,30);
	                    ok.setText("OK");
	     
	                    Listener dialoglistener = new Listener() {
	                        public void handleEvent(Event event) {
	                            dialog.close();
	                        }
	                    };
	                    ok.addListener(SWT.Selection,dialoglistener);
		                dialog.open();
		                result.setText((answer) ? "The string is a palindrome indeed!" : "The string is not a palindrome!");
	                }
                };
                checkme.addListener(SWT.Selection,checkmelistener);
 
 
                while (!shell.isDisposed()) {
                        if (!display.readAndDispatch()) display.sleep();
                }
                display.dispose();
	}
}


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


Current Time: Thu Mar 28 10:12:08 GMT 2024

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

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

Back to the top