Results 1 to 8 of 8
  1. #1
    thendral m is offline Member
    Join Date
    Jul 2009
    Posts
    1
    Rep Power
    0

    Default getting problem in disposing the widgets

    Hi,

    my application is java based thick client application.
    From my application, i am generating report file using crystal report tool.
    the report file is exported as pdf format and stored in my local macine. from this path, am displaying the report in a SWT browser.
    till now its working fine. when i close the browser, i am getting java.lang.null.pointer exception.
    i dont understand from this exception, printed in console.
    please help me.

    java.lang.NullPointerException
    at org.eclipse.swt.ole.win32.OleClientSite.onPaint(Ol eClientSite.java:921)
    at org.eclipse.swt.ole.win32.OleClientSite.access$2(O leClientSite.java:906)
    at org.eclipse.swt.ole.win32.OleClientSite$1.handleEv ent(OleClientSite.java:131)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Event Table.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1003)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1027)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1012)
    at org.eclipse.swt.widgets.Composite.WM_PAINT(Composi te.java:1424)
    at org.eclipse.swt.widgets.Control.windowProc(Control .java:3842)
    at org.eclipse.swt.widgets.Display.windowProc(Display .java:4541)
    at org.eclipse.swt.internal.ole.win32.COM.CoFreeUnuse dLibraries(Native Method)
    at org.eclipse.swt.ole.win32.OleClientSite.releaseObj ectInterfaces(OleClientSite.java:1084)
    at org.eclipse.swt.ole.win32.OleControlSite.releaseOb jectInterfaces(OleControlSite.java:683)
    at org.eclipse.swt.ole.win32.OleClientSite.onDispose( OleClientSite.java:852)
    at org.eclipse.swt.ole.win32.OleClientSite.access$1(O leClientSite.java:847)
    at org.eclipse.swt.ole.win32.OleClientSite$1.handleEv ent(OleClientSite.java:128)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Event Table.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1003)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1027)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1008)
    at org.eclipse.swt.widgets.Widget.release(Widget.java :804)
    at org.eclipse.swt.widgets.Composite.releaseChildren( Composite.java:755)
    at org.eclipse.swt.widgets.Widget.release(Widget.java :807)
    at org.eclipse.swt.widgets.Composite.releaseChildren( Composite.java:755)
    at org.eclipse.swt.widgets.Widget.release(Widget.java :807)
    at org.eclipse.swt.widgets.Widget.dispose(Widget.java :441)
    at com.siemens.med.cad.hqm.reports.ReportViewer$1.wid getDisposed(ReportViewer.java:273)
    at org.eclipse.swt.widgets.TypedListener.handleEvent( TypedListener.java:117)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Event Table.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1003)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1027)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1008)
    at org.eclipse.swt.widgets.Widget.release(Widget.java :804)
    at org.eclipse.swt.widgets.Widget.dispose(Widget.java :441)
    at org.eclipse.swt.widgets.Decorations.dispose(Decora tions.java:446)
    at org.eclipse.swt.widgets.Shell.dispose(Shell.java:6 74)
    at org.eclipse.swt.widgets.Decorations.closeWidget(De corations.java:308)
    at org.eclipse.swt.widgets.Decorations.WM_CLOSE(Decor ations.java:1643)
    at org.eclipse.swt.widgets.Control.windowProc(Control .java:3789)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.j ava:337)
    at org.eclipse.swt.widgets.Decorations.windowProc(Dec orations.java:1576)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.jav a:1937)
    at org.eclipse.swt.widgets.Display.windowProc(Display .java:4528)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(N ative Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS .java:2366)
    at org.eclipse.swt.widgets.Shell.callWindowProc(Shell .java:477)
    at org.eclipse.swt.widgets.Control.windowProc(Control .java:3877)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.j ava:337)
    at org.eclipse.swt.widgets.Decorations.windowProc(Dec orations.java:1576)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.jav a:1937)
    at org.eclipse.swt.widgets.Display.windowProc(Display .java:4528)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(N ative Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS .java:2366)
    at org.eclipse.swt.widgets.Shell.callWindowProc(Shell .java:477)
    at org.eclipse.swt.widgets.Control.windowProc(Control .java:3877)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.j ava:337)
    at org.eclipse.swt.widgets.Decorations.windowProc(Dec orations.java:1576)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.jav a:1937)
    at org.eclipse.swt.widgets.Display.windowProc(Display .java:4528)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW (Native Method)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage( OS.java:2371)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Di splay.java:3420)
    at org.eclipse.swt.widgets.TypedListener.handleEvent( TypedListener.java:228)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Event Table.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1003)
    at org.eclipse.swt.widgets.Display.runDeferredEvents( Display.java:3823)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Di splay.java:3422)


    this is the code i have written for display the report file in a browser:

    Display display = Display.getDefault() ;
    Shell shell = new Shell(display, SWT.RESIZE | SWT.CLOSE | SWT.MIN | SWT.MAX | SWT.APPLICATION_MODAL);


    shell.setText(reportTitle);
    shell.setLayout(new FillLayout());
    shell.setMaximized(false);
    shell.setSize(800, 600);

    Composite comp = new Composite(shell, SWT.NONE);
    comp.setLayout(new FillLayout());


    final Browser browser = new Browser(comp, SWT.FLAT);

    try {
    File file = new File(exportFile);
    URL url = file.toURL();
    browser.setUrl("file:" + url.getPath());

    } catch (MalformedURLException malURLEx) {
    // malURLEx.printStackTrace();
    throw new ProgrammingExceptionAdapter(malURLEx);
    }

    shell.addDisposeListener(new DisposeListener() {
    public void widgetDisposed(DisposeEvent arg0) {
    File file = new File(exportFile);
    if (file != null && file.exists()) {
    file.delete();
    }
    browser.dispose();
    }
    });

    shell.open();
    shell.setFocus()

  2. #2
    tititruc is offline Member
    Join Date
    Jan 2010
    Posts
    4
    Rep Power
    0

    Default

    I have the same problem.
    Do you have to find the origin of the error?
    thank

  3. #3
    AndreB's Avatar
    AndreB is offline Senior Member
    Join Date
    Dec 2009
    Location
    Stuttgart, Germany
    Posts
    114
    Rep Power
    0

    Default

    1. you forgot to run the ui thread

    Java Code:
    		while (!shell.isDisposed ()) {
    			if (!display.readAndDispatch ()) display.sleep ();
    		}
    		display.dispose ();
    2. This code runs for me; its basically the same code you provided
    Java Code:
    		Display display = Display.getDefault() ;
    		Shell shell = new Shell(display, SWT.RESIZE | SWT.CLOSE | SWT.MIN | SWT.MAX | SWT.APPLICATION_MODAL);
    
    
    		shell.setText("Title");
    		shell.setLayout(new FillLayout());
    		shell.setMaximized(false);
    		shell.setSize(800, 600);
    
    		Composite comp = new Composite(shell, SWT.NONE);
    		comp.setLayout(new FillLayout());
    
    
    		final Browser browser = new Browser(comp, SWT.FLAT);
    			browser.setUrl("http://www.java-forums.org/swt-jface/19718-getting-problem-disposing-widgets.html");
    
    
    		shell.addDisposeListener(new DisposeListener() {
    			public void widgetDisposed(DisposeEvent arg0) {
    				browser.dispose();
    			}
    		});
    
    		shell.open();
    		shell.setFocus();
    
    		while (!shell.isDisposed ()) {
    			if (!display.readAndDispatch ()) display.sleep ();
    		}
    		display.dispose ();
    "There is no foolproof thing; fools are too smart."
    "Why can't you solve my Problem ?"

  4. #4
    tititruc is offline Member
    Join Date
    Jan 2010
    Posts
    4
    Rep Power
    0

    Default

    Thank you for your answer.
    I used this code with Acrobat 8.1.3 . I have no error.
    But by using Acrobat 9.2.0, when I close the browser with the cross, I have the following error.
    What is the difference?

    Exception in thread "main" java.lang.NullPointerException
    at org.eclipse.swt.ole.win32.OleClientSite.onPaint(Ol eClientSite.java:921)
    at org.eclipse.swt.ole.win32.OleClientSite.access$2(O leClientSite.java:906)
    at org.eclipse.swt.ole.win32.OleClientSite$1.handleEv ent(OleClientSite.java:131)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Event Table.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1003)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1027)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1012)
    at org.eclipse.swt.widgets.Composite.WM_PAINT(Composi te.java:1424)
    at org.eclipse.swt.widgets.Control.windowProc(Control .java:3842)
    at org.eclipse.swt.widgets.Display.windowProc(Display .java:4541)
    at org.eclipse.swt.internal.ole.win32.COM.CoFreeUnuse dLibraries(Native Method)
    at org.eclipse.swt.ole.win32.OleClientSite.releaseObj ectInterfaces(OleClientSite.java:1084)
    at org.eclipse.swt.ole.win32.OleControlSite.releaseOb jectInterfaces(OleControlSite.java:683)
    at org.eclipse.swt.ole.win32.OleClientSite.onDispose( OleClientSite.java:852)
    at org.eclipse.swt.ole.win32.OleClientSite.access$1(O leClientSite.java:847)
    at org.eclipse.swt.ole.win32.OleClientSite$1.handleEv ent(OleClientSite.java:128)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Event Table.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1003)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1027)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1008)
    at org.eclipse.swt.widgets.Widget.release(Widget.java :804)
    at org.eclipse.swt.widgets.Composite.releaseChildren( Composite.java:755)
    at org.eclipse.swt.widgets.Widget.release(Widget.java :807)
    at org.eclipse.swt.widgets.Composite.releaseChildren( Composite.java:755)
    at org.eclipse.swt.widgets.Widget.release(Widget.java :807)
    at org.eclipse.swt.widgets.Widget.dispose(Widget.java :441)
    at com.client.app.module.main.testBrowser$1.widgetDis posed(testBrowser.java:60)
    at org.eclipse.swt.widgets.TypedListener.handleEvent( TypedListener.java:117)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Event Table.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1003)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1027)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1008)
    at org.eclipse.swt.widgets.Widget.release(Widget.java :804)
    at org.eclipse.swt.widgets.Widget.dispose(Widget.java :441)
    at org.eclipse.swt.widgets.Decorations.dispose(Decora tions.java:446)
    at org.eclipse.swt.widgets.Shell.dispose(Shell.java:6 74)
    at org.eclipse.swt.widgets.Decorations.closeWidget(De corations.java:308)
    at org.eclipse.swt.widgets.Decorations.WM_CLOSE(Decor ations.java:1632)
    at org.eclipse.swt.widgets.Control.windowProc(Control .java:3789)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.j ava:337)
    at org.eclipse.swt.widgets.Decorations.windowProc(Dec orations.java:1565)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.jav a:1937)
    at org.eclipse.swt.widgets.Display.windowProc(Display .java:4528)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(N ative Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS .java:2365)
    at org.eclipse.swt.widgets.Shell.callWindowProc(Shell .java:477)
    at org.eclipse.swt.widgets.Control.windowProc(Control .java:3877)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.j ava:337)
    at org.eclipse.swt.widgets.Decorations.windowProc(Dec orations.java:1565)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.jav a:1937)
    at org.eclipse.swt.widgets.Display.windowProc(Display .java:4528)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(N ative Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS .java:2365)
    at org.eclipse.swt.widgets.Shell.callWindowProc(Shell .java:477)
    at org.eclipse.swt.widgets.Control.windowProc(Control .java:3877)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.j ava:337)
    at org.eclipse.swt.widgets.Decorations.windowProc(Dec orations.java:1565)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.jav a:1937)
    at org.eclipse.swt.widgets.Display.windowProc(Display .java:4528)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW (Native Method)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage( OS.java:2370)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Di splay.java:3420)
    at com.client.app.module.main.testBrowser.main(testBr owser.java:71)

  5. #5
    AndreB's Avatar
    AndreB is offline Senior Member
    Join Date
    Dec 2009
    Location
    Stuttgart, Germany
    Posts
    114
    Rep Power
    0

    Default

    check that line
    at com.client.app.module.main.testBrowser$1.widgetDis posed(testBrowser.java:60)
    "There is no foolproof thing; fools are too smart."
    "Why can't you solve my Problem ?"

  6. #6
    tititruc is offline Member
    Join Date
    Jan 2010
    Posts
    4
    Rep Power
    0

    Default

    I realized this test: I execute snippet148 from SWT snippets.
    http://dev.eclipse.org/viewcvs/index...8.java?view=co
    I just replace //browser.setUrl("http://www.eclipse.org");
    by browser.setUrl("C:\\MyApplication\\temp\\FR1234.pd f");

    With acrobat 8, there is no error.
    With acrobat 9, when I close the browser with the cross, I have the following error.
    Have you an idea?

    Exception in thread "main" java.lang.NullPointerException
    at org.eclipse.swt.ole.win32.OleClientSite.onPaint(Ol eClientSite.java:921)
    at org.eclipse.swt.ole.win32.OleClientSite.access$2(O leClientSite.java:906)
    at org.eclipse.swt.ole.win32.OleClientSite$1.handleEv ent(OleClientSite.java:131)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Event Table.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1003)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1027)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1012)
    at org.eclipse.swt.widgets.Composite.WM_PAINT(Composi te.java:1424)
    at org.eclipse.swt.widgets.Control.windowProc(Control .java:3842)
    at org.eclipse.swt.widgets.Display.windowProc(Display .java:4541)
    at org.eclipse.swt.internal.ole.win32.COM.CoFreeUnuse dLibraries(Native Method)
    at org.eclipse.swt.ole.win32.OleClientSite.releaseObj ectInterfaces(OleClientSite.java:1084)
    at org.eclipse.swt.ole.win32.OleControlSite.releaseOb jectInterfaces(OleControlSite.java:683)
    at org.eclipse.swt.ole.win32.OleClientSite.onDispose( OleClientSite.java:852)
    at org.eclipse.swt.ole.win32.OleClientSite.access$1(O leClientSite.java:847)
    at org.eclipse.swt.ole.win32.OleClientSite$1.handleEv ent(OleClientSite.java:128)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Event Table.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1003)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1027)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:1008)
    at org.eclipse.swt.widgets.Widget.release(Widget.java :804)
    at org.eclipse.swt.widgets.Composite.releaseChildren( Composite.java:755)
    at org.eclipse.swt.widgets.Widget.release(Widget.java :807)
    at org.eclipse.swt.widgets.Composite.releaseChildren( Composite.java:755)
    at org.eclipse.swt.widgets.Widget.release(Widget.java :807)
    at org.eclipse.swt.widgets.Composite.releaseChildren( Composite.java:755)
    at org.eclipse.swt.widgets.Canvas.releaseChildren(Can vas.java:174)
    at org.eclipse.swt.widgets.Decorations.releaseChildre n(Decorations.java:771)
    at org.eclipse.swt.widgets.Shell.releaseChildren(Shel l.java:1211)
    at org.eclipse.swt.widgets.Widget.release(Widget.java :807)
    at org.eclipse.swt.widgets.Widget.dispose(Widget.java :441)
    at org.eclipse.swt.widgets.Decorations.dispose(Decora tions.java:446)
    at org.eclipse.swt.widgets.Shell.dispose(Shell.java:6 74)
    at org.eclipse.swt.widgets.Decorations.closeWidget(De corations.java:308)
    at org.eclipse.swt.widgets.Decorations.WM_CLOSE(Decor ations.java:1632)
    at org.eclipse.swt.widgets.Control.windowProc(Control .java:3789)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.j ava:337)
    at org.eclipse.swt.widgets.Decorations.windowProc(Dec orations.java:1565)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.jav a:1937)
    at org.eclipse.swt.widgets.Display.windowProc(Display .java:4528)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(N ative Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS .java:2365)
    at org.eclipse.swt.widgets.Shell.callWindowProc(Shell .java:477)
    at org.eclipse.swt.widgets.Control.windowProc(Control .java:3877)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.j ava:337)
    at org.eclipse.swt.widgets.Decorations.windowProc(Dec orations.java:1565)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.jav a:1937)
    at org.eclipse.swt.widgets.Display.windowProc(Display .java:4528)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(N ative Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS .java:2365)
    at org.eclipse.swt.widgets.Shell.callWindowProc(Shell .java:477)
    at org.eclipse.swt.widgets.Control.windowProc(Control .java:3877)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.j ava:337)
    at org.eclipse.swt.widgets.Decorations.windowProc(Dec orations.java:1565)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.jav a:1937)
    at org.eclipse.swt.widgets.Display.windowProc(Display .java:4528)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW (Native Method)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage( OS.java:2370)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Di splay.java:3420)
    at com.client.test.module.main.Snippet148.main(Snippe t148.java:53)
    Last edited by tititruc; 01-11-2010 at 03:42 PM.

  7. #7
    AndreB's Avatar
    AndreB is offline Senior Member
    Join Date
    Dec 2009
    Location
    Stuttgart, Germany
    Posts
    114
    Rep Power
    0

    Default

    sorry, i cant test it for different acrobat readers ... but it seems an swt error. post it on the swt bugtracker
    "There is no foolproof thing; fools are too smart."
    "Why can't you solve my Problem ?"

  8. #8
    tititruc is offline Member
    Join Date
    Jan 2010
    Posts
    4
    Rep Power
    0

Similar Threads

  1. How to create widgets on some event
    By sarbuland in forum Advanced Java
    Replies: 0
    Last Post: 02-06-2008, 09:08 PM
  2. How to create widgets dynamically
    By sarbuland in forum Advanced Java
    Replies: 0
    Last Post: 02-06-2008, 09:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •