Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Pb with SWT_AWT
Pb with SWT_AWT [message #432636] Wed, 24 March 2004 15:20 Go to next message
Philippe Riand is currently offline Philippe RiandFriend
Messages: 2
Registered: July 2009
Junior Member
I'm currently experiencing the new SWT_AWT while porting our development
studio to Eclipse. I'm using M7 & JDK 1.4.2.
I found the following problems:

1/ I need a listener on the SWT Composite to resize the underlying Swing
component. Else, the swing component is not resized!
Here is the code I use to add the component. I added an intermadiate panel,
as I saw on other threads that swing components may not receive mouse events
when directly added to the Frame.
javax.swing.JComponent component = <get my swing control method>;
final java.awt.Frame statusFrame = SWT_AWT.new_Frame(parent);
final java.awt.Panel pnl = new java.awt.Panel();

statusFrame.setLayout(new java.awt.BorderLayout());
statusFrame.add(pnl,java.awt.BorderLayout.CENTER);

pnl.setLayout(new java.awt.BorderLayout());
pnl.add(component,java.awt.BorderLayout.CENTER);

statusFrame.add(component,java.awt.BorderLayout.CENTER);
parent.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event e) {
Rectangle rect = parent.getClientArea();
statusFrame.setSize(rect.width, rect.height);
statusFrame.validate();
}
});

2/ I'm systematically gettting a NullPointerException when a swing based
editor is closed.
In fact, it seems that the awt component is still receiving events while the
editor is already closed (the Composite is disposed). Here is the exception
I get:
Thread [AWT-EventQueue-0] (Suspended (exception NullPointerException))
Win32BlitLoops.Blit(SurfaceData, SurfaceData, Composite, Region, int, int,
int, int, int, int) line: not available [native method]
DrawImage.blitSurfaceData(SunGraphics2D, SurfaceData, SurfaceData,
SurfaceType, SurfaceType, int, int, int, int, int, int, Color) line: 640
DrawImage.renderSurfaceData(SunGraphics2D, SurfaceData, Color, int, int,
int, int, int, int) line: 346
DrawImage.copyImage(SunGraphics2D, Image, int, int, int, int, int, int,
Color) line: 66
DrawImage.copyImage(SunGraphics2D, Image, int, int, Color) line: 50
DrawImage.copyImage(SunGraphics2D, Image, int, int, Color, ImageObserver)
line: 736
ValidatePipe.copyImage(SunGraphics2D, Image, int, int, Color,
ImageObserver) line: 147
SunGraphics2D.drawImage(Image, int, int, Color, ImageObserver) line: 2755
SunGraphics2D.drawImage(Image, int, int, ImageObserver) line: 2745
PageEditorPanel(JComponent).paintWithOffscreenBuffer(JCompon ent, Graphics,
int, int, int, int, Image) line: 4805
PageEditorPanel(JComponent).paintDoubleBuffered(JComponent, Component,
Graphics, int, int, int, int) line: 4748
PageEditorPanel(JComponent)._paintImmediately(int, int, int, int) line:
4692
PageEditorPanel(JComponent).paintImmediately(int, int, int, int) line: 4495
RepaintManager.paintDirtyRegions() line: 410
SystemEventQueueUtilities$ComponentWorkRequest.run() line: 117
InvocationEvent.dispatch() line: 178
EventQueue.dispatchEvent(AWTEvent) line: 454
EventDispatchThread.pumpOneEventForHierarchy(int, Component) line: 201
EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component)
line: 151
EventDispatchThread.pumpEvents(int, Conditional) line: 145
EventDispatchThread.pumpEvents(Conditional) line: 137
EventDispatchThread.run() line: 100


3/ The Swing cursor is incorrect
In fact, it seems that the component positions are incorrectly computed, as
the cursor displayed is *not* the cursor assigned to the underlying
component. Moreover, it seems that it compute the position from absolute
screen (0,0). In other words, when your using a SplitPane, the vertical
divider cursor does not appear when the mouse is over the divider, but when
the mouse is left to the divider. And it seems that the distance between
this position and the divider correspond to the left corner of the embedded
frame, relative to absolute (0,0)


4/ The editor is flashing
It seems that the Frame (or some other SWT component?) is painting its
background before the Swing component paints. As a result, it flashes with a
gray background.
I don't know how to overcome this.


Does anybody have an idea about these issues?

Thanks,

Phil.
Re: Pb with SWT_AWT [message #432718 is a reply to message #432636] Wed, 24 March 2004 20:03 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Please enter a problem report with each one of these issues and a snippet
that shows the problem. The flashing I have seen before but determined
(possibly incorrectly) that the problem was in Swing.

"Philippe Riand" <phil@triloggroup.com> wrote in message
news:c3s8nn$qr$1@eclipse.org...
> I'm currently experiencing the new SWT_AWT while porting our development
> studio to Eclipse. I'm using M7 & JDK 1.4.2.
> I found the following problems:
>
> 1/ I need a listener on the SWT Composite to resize the underlying Swing
> component. Else, the swing component is not resized!
> Here is the code I use to add the component. I added an intermadiate
panel,
> as I saw on other threads that swing components may not receive mouse
events
> when directly added to the Frame.
> javax.swing.JComponent component = <get my swing control method>;
> final java.awt.Frame statusFrame = SWT_AWT.new_Frame(parent);
> final java.awt.Panel pnl = new java.awt.Panel();
>
> statusFrame.setLayout(new java.awt.BorderLayout());
> statusFrame.add(pnl,java.awt.BorderLayout.CENTER);
>
> pnl.setLayout(new java.awt.BorderLayout());
> pnl.add(component,java.awt.BorderLayout.CENTER);
>
> statusFrame.add(component,java.awt.BorderLayout.CENTER);
> parent.addListener(SWT.Resize, new Listener() {
> public void handleEvent(Event e) {
> Rectangle rect = parent.getClientArea();
> statusFrame.setSize(rect.width, rect.height);
> statusFrame.validate();
> }
> });
>
> 2/ I'm systematically gettting a NullPointerException when a swing based
> editor is closed.
> In fact, it seems that the awt component is still receiving events while
the
> editor is already closed (the Composite is disposed). Here is the
exception
> I get:
> Thread [AWT-EventQueue-0] (Suspended (exception NullPointerException))
> Win32BlitLoops.Blit(SurfaceData, SurfaceData, Composite, Region, int,
int,
> int, int, int, int) line: not available [native method]
> DrawImage.blitSurfaceData(SunGraphics2D, SurfaceData, SurfaceData,
> SurfaceType, SurfaceType, int, int, int, int, int, int, Color) line: 640
> DrawImage.renderSurfaceData(SunGraphics2D, SurfaceData, Color, int, int,
> int, int, int, int) line: 346
> DrawImage.copyImage(SunGraphics2D, Image, int, int, int, int, int, int,
> Color) line: 66
> DrawImage.copyImage(SunGraphics2D, Image, int, int, Color) line: 50
> DrawImage.copyImage(SunGraphics2D, Image, int, int, Color, ImageObserver)
> line: 736
> ValidatePipe.copyImage(SunGraphics2D, Image, int, int, Color,
> ImageObserver) line: 147
> SunGraphics2D.drawImage(Image, int, int, Color, ImageObserver) line: 2755
> SunGraphics2D.drawImage(Image, int, int, ImageObserver) line: 2745
> PageEditorPanel(JComponent).paintWithOffscreenBuffer(JCompon ent,
Graphics,
> int, int, int, int, Image) line: 4805
> PageEditorPanel(JComponent).paintDoubleBuffered(JComponent, Component,
> Graphics, int, int, int, int) line: 4748
> PageEditorPanel(JComponent)._paintImmediately(int, int, int, int) line:
> 4692
> PageEditorPanel(JComponent).paintImmediately(int, int, int, int) line:
4495
> RepaintManager.paintDirtyRegions() line: 410
> SystemEventQueueUtilities$ComponentWorkRequest.run() line: 117
> InvocationEvent.dispatch() line: 178
> EventQueue.dispatchEvent(AWTEvent) line: 454
> EventDispatchThread.pumpOneEventForHierarchy(int, Component) line: 201
> EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component)
> line: 151
> EventDispatchThread.pumpEvents(int, Conditional) line: 145
> EventDispatchThread.pumpEvents(Conditional) line: 137
> EventDispatchThread.run() line: 100
>
>
> 3/ The Swing cursor is incorrect
> In fact, it seems that the component positions are incorrectly computed,
as
> the cursor displayed is *not* the cursor assigned to the underlying
> component. Moreover, it seems that it compute the position from absolute
> screen (0,0). In other words, when your using a SplitPane, the vertical
> divider cursor does not appear when the mouse is over the divider, but
when
> the mouse is left to the divider. And it seems that the distance between
> this position and the divider correspond to the left corner of the
embedded
> frame, relative to absolute (0,0)
>
>
> 4/ The editor is flashing
> It seems that the Frame (or some other SWT component?) is painting its
> background before the Swing component paints. As a result, it flashes with
a
> gray background.
> I don't know how to overcome this.
>
>
> Does anybody have an idea about these issues?
>
> Thanks,
>
> Phil.
>
>
Previous Topic:Newbie in SWT - should i start new project with SWT3?
Next Topic:Setting the background color of a ToolItem
Goto Forum:
  


Current Time: Fri Apr 26 11:22:42 GMT 2024

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

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

Back to the top