Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Another SWT_AWT bridge problems
Another SWT_AWT bridge problems [message #455556] Tue, 17 May 2005 11:14 Go to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

I've found another SWT_AWT bridge problem. I've created an AWT frame using
the SWT_AWT bridge and added a JPanel to it.
On this I've changed the cursor type, but it seems to be some problems with
this. The cursor appears only after resizing and only in a limited area
instead on the entire window.
I've tested the same snippet without the SWT_AWT bridge and works fine.
The snippet was tested using the vm from JDK 1.4.2_08-b03 and SWT version
3.123 on Windows 2000.

Below is the snippet:

import java.awt.CardLayout;
import java.awt.Cursor;
import java.awt.Frame;

import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class SWTAWTTest {
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());

System.getProperties().list(System.out);

Composite container = new Composite(shell, SWT.EMBEDDED);
container.setLayout(new FillLayout());

Frame frame = SWT_AWT.new_Frame(container);

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClass Name());
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}

JPanel panel = new JPanel(true);

panel.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));

frame.add(panel);
frame.setLayout(new CardLayout());
frame.pack();


shell.pack();
shell.open();

while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}


Best regards,
Boby
Re: Another SWT_AWT bridge problems [message #455558 is a reply to message #455556] Tue, 17 May 2005 13:01 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
I entered the following bug report and added you to the CC:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=95540

In the future, if you find a bug, it is best to track the resolution with a
bug report rather than a newsgroup posting.

"Robert Bacs" <boby@zerosoft.ro> wrote in message
news:d6cjmc$gga$1@news.eclipse.org...
> Hi,
>
> I've found another SWT_AWT bridge problem. I've created an AWT frame using
> the SWT_AWT bridge and added a JPanel to it.
> On this I've changed the cursor type, but it seems to be some problems
> with
> this. The cursor appears only after resizing and only in a limited area
> instead on the entire window.
> I've tested the same snippet without the SWT_AWT bridge and works fine.
> The snippet was tested using the vm from JDK 1.4.2_08-b03 and SWT version
> 3.123 on Windows 2000.
>
> Below is the snippet:
>
> import java.awt.CardLayout;
> import java.awt.Cursor;
> import java.awt.Frame;
>
> import javax.swing.JPanel;
> import javax.swing.UIManager;
> import javax.swing.UnsupportedLookAndFeelException;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.awt.SWT_AWT;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> public class SWTAWTTest {
> public static void main(String[] args) {
> final Display display = new Display();
> final Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
>
> System.getProperties().list(System.out);
>
> Composite container = new Composite(shell, SWT.EMBEDDED);
> container.setLayout(new FillLayout());
>
> Frame frame = SWT_AWT.new_Frame(container);
>
> try {
> UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClass Name());
> } catch (ClassNotFoundException e) {
> e.printStackTrace();
> } catch (InstantiationException e) {
> e.printStackTrace();
> } catch (IllegalAccessException e) {
> e.printStackTrace();
> } catch (UnsupportedLookAndFeelException e) {
> e.printStackTrace();
> }
>
> JPanel panel = new JPanel(true);
>
> panel.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
>
> frame.add(panel);
> frame.setLayout(new CardLayout());
> frame.pack();
>
>
> shell.pack();
> shell.open();
>
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> }
>
>
> Best regards,
> Boby
>
>
Re: Another SWT_AWT bridge problems [message #455559 is a reply to message #455558] Tue, 17 May 2005 13:25 Go to previous messageGo to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
I will do that in the future.

Thank you and regards,
Boby

"Veronika Irvine" <veronika_irvine@oti.com> wrote in message
news:d6cq0k$p3t$1@news.eclipse.org...
> I entered the following bug report and added you to the CC:
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=95540
>
> In the future, if you find a bug, it is best to track the resolution with
a
> bug report rather than a newsgroup posting.
>
> "Robert Bacs" <boby@zerosoft.ro> wrote in message
> news:d6cjmc$gga$1@news.eclipse.org...
> > Hi,
> >
> > I've found another SWT_AWT bridge problem. I've created an AWT frame
using
> > the SWT_AWT bridge and added a JPanel to it.
> > On this I've changed the cursor type, but it seems to be some problems
> > with
> > this. The cursor appears only after resizing and only in a limited area
> > instead on the entire window.
> > I've tested the same snippet without the SWT_AWT bridge and works fine.
> > The snippet was tested using the vm from JDK 1.4.2_08-b03 and SWT
version
> > 3.123 on Windows 2000.
> >
> > Below is the snippet:
> >
> > import java.awt.CardLayout;
> > import java.awt.Cursor;
> > import java.awt.Frame;
> >
> > import javax.swing.JPanel;
> > import javax.swing.UIManager;
> > import javax.swing.UnsupportedLookAndFeelException;
> >
> > import org.eclipse.swt.SWT;
> > import org.eclipse.swt.awt.SWT_AWT;
> > import org.eclipse.swt.layout.FillLayout;
> > import org.eclipse.swt.widgets.Composite;
> > import org.eclipse.swt.widgets.Display;
> > import org.eclipse.swt.widgets.Shell;
> >
> > public class SWTAWTTest {
> > public static void main(String[] args) {
> > final Display display = new Display();
> > final Shell shell = new Shell(display);
> > shell.setLayout(new FillLayout());
> >
> > System.getProperties().list(System.out);
> >
> > Composite container = new Composite(shell, SWT.EMBEDDED);
> > container.setLayout(new FillLayout());
> >
> > Frame frame = SWT_AWT.new_Frame(container);
> >
> > try {
> >
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClass Name());
> > } catch (ClassNotFoundException e) {
> > e.printStackTrace();
> > } catch (InstantiationException e) {
> > e.printStackTrace();
> > } catch (IllegalAccessException e) {
> > e.printStackTrace();
> > } catch (UnsupportedLookAndFeelException e) {
> > e.printStackTrace();
> > }
> >
> > JPanel panel = new JPanel(true);
> >
> > panel.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
> >
> > frame.add(panel);
> > frame.setLayout(new CardLayout());
> > frame.pack();
> >
> >
> > shell.pack();
> > shell.open();
> >
> > while (!shell.isDisposed ()) {
> > if (!display.readAndDispatch ()) display.sleep ();
> > }
> > display.dispose ();
> > }
> > }
> >
> >
> > Best regards,
> > Boby
> >
> >
>
>
Re: Another SWT_AWT bridge problems [message #455569 is a reply to message #455556] Tue, 17 May 2005 18:14 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
I believe you need to create a Panel, not a JPanel as a child of the Frame.
See the Javadoc for new_Frame().

"Robert Bacs" <boby@zerosoft.ro> wrote in message
news:d6cjmc$gga$1@news.eclipse.org...
> Hi,
>
> I've found another SWT_AWT bridge problem. I've created an AWT frame using
> the SWT_AWT bridge and added a JPanel to it.
> On this I've changed the cursor type, but it seems to be some problems
with
> this. The cursor appears only after resizing and only in a limited area
> instead on the entire window.
> I've tested the same snippet without the SWT_AWT bridge and works fine.
> The snippet was tested using the vm from JDK 1.4.2_08-b03 and SWT version
> 3.123 on Windows 2000.
>
> Below is the snippet:
>
> import java.awt.CardLayout;
> import java.awt.Cursor;
> import java.awt.Frame;
>
> import javax.swing.JPanel;
> import javax.swing.UIManager;
> import javax.swing.UnsupportedLookAndFeelException;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.awt.SWT_AWT;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> public class SWTAWTTest {
> public static void main(String[] args) {
> final Display display = new Display();
> final Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
>
> System.getProperties().list(System.out);
>
> Composite container = new Composite(shell, SWT.EMBEDDED);
> container.setLayout(new FillLayout());
>
> Frame frame = SWT_AWT.new_Frame(container);
>
> try {
> UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClass Name());
> } catch (ClassNotFoundException e) {
> e.printStackTrace();
> } catch (InstantiationException e) {
> e.printStackTrace();
> } catch (IllegalAccessException e) {
> e.printStackTrace();
> } catch (UnsupportedLookAndFeelException e) {
> e.printStackTrace();
> }
>
> JPanel panel = new JPanel(true);
>
> panel.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
>
> frame.add(panel);
> frame.setLayout(new CardLayout());
> frame.pack();
>
>
> shell.pack();
> shell.open();
>
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> }
>
>
> Best regards,
> Boby
>
>
Re: Another SWT_AWT bridge problems [message #455664 is a reply to message #455569] Thu, 19 May 2005 13:59 Go to previous messageGo to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Thanks Steve, problem solved.

"Steve Northover" <steve_northover@ca.ibm.com> wrote in message
news:d6dcab$ipq$1@news.eclipse.org...
> I believe you need to create a Panel, not a JPanel as a child of the
Frame.
> See the Javadoc for new_Frame().
>
> "Robert Bacs" <boby@zerosoft.ro> wrote in message
> news:d6cjmc$gga$1@news.eclipse.org...
> > Hi,
> >
> > I've found another SWT_AWT bridge problem. I've created an AWT frame
using
> > the SWT_AWT bridge and added a JPanel to it.
> > On this I've changed the cursor type, but it seems to be some problems
> with
> > this. The cursor appears only after resizing and only in a limited area
> > instead on the entire window.
> > I've tested the same snippet without the SWT_AWT bridge and works fine.
> > The snippet was tested using the vm from JDK 1.4.2_08-b03 and SWT
version
> > 3.123 on Windows 2000.
> >
> > Below is the snippet:
> >
> > import java.awt.CardLayout;
> > import java.awt.Cursor;
> > import java.awt.Frame;
> >
> > import javax.swing.JPanel;
> > import javax.swing.UIManager;
> > import javax.swing.UnsupportedLookAndFeelException;
> >
> > import org.eclipse.swt.SWT;
> > import org.eclipse.swt.awt.SWT_AWT;
> > import org.eclipse.swt.layout.FillLayout;
> > import org.eclipse.swt.widgets.Composite;
> > import org.eclipse.swt.widgets.Display;
> > import org.eclipse.swt.widgets.Shell;
> >
> > public class SWTAWTTest {
> > public static void main(String[] args) {
> > final Display display = new Display();
> > final Shell shell = new Shell(display);
> > shell.setLayout(new FillLayout());
> >
> > System.getProperties().list(System.out);
> >
> > Composite container = new Composite(shell, SWT.EMBEDDED);
> > container.setLayout(new FillLayout());
> >
> > Frame frame = SWT_AWT.new_Frame(container);
> >
> > try {
> >
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClass Name());
> > } catch (ClassNotFoundException e) {
> > e.printStackTrace();
> > } catch (InstantiationException e) {
> > e.printStackTrace();
> > } catch (IllegalAccessException e) {
> > e.printStackTrace();
> > } catch (UnsupportedLookAndFeelException e) {
> > e.printStackTrace();
> > }
> >
> > JPanel panel = new JPanel(true);
> >
> > panel.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
> >
> > frame.add(panel);
> > frame.setLayout(new CardLayout());
> > frame.pack();
> >
> >
> > shell.pack();
> > shell.open();
> >
> > while (!shell.isDisposed ()) {
> > if (!display.readAndDispatch ()) display.sleep ();
> > }
> > display.dispose ();
> > }
> > }
> >
> >
> > Best regards,
> > Boby
> >
> >
>
>
Re: Another SWT_AWT bridge problems [message #455704 is a reply to message #455664] Thu, 19 May 2005 18:47 Go to previous message
Jim Adams is currently offline Jim AdamsFriend
Messages: 160
Registered: July 2009
Senior Member
Not only do you need a Panel as the first child, if you want to put
Swing components in it and have them function properly you need a
RootPaneContainer as well. Note that Javasoft did not write a standalone
RootPaneContainer.

Robert Bacs wrote:
> Thanks Steve, problem solved.
>
> "Steve Northover" <steve_northover@ca.ibm.com> wrote in message
> news:d6dcab$ipq$1@news.eclipse.org...
>
>>I believe you need to create a Panel, not a JPanel as a child of the
>
> Frame.
>
>>See the Javadoc for new_Frame().
>>
>>"Robert Bacs" <boby@zerosoft.ro> wrote in message
>>news:d6cjmc$gga$1@news.eclipse.org...
>>
>>>Hi,
>>>
>>>I've found another SWT_AWT bridge problem. I've created an AWT frame
>
> using
>
>>>the SWT_AWT bridge and added a JPanel to it.
>>>On this I've changed the cursor type, but it seems to be some problems
>>
>>with
>>
>>>this. The cursor appears only after resizing and only in a limited area
>>>instead on the entire window.
>>>I've tested the same snippet without the SWT_AWT bridge and works fine.
>>>The snippet was tested using the vm from JDK 1.4.2_08-b03 and SWT
>
> version
>
>>>3.123 on Windows 2000.
>>>
>>>Below is the snippet:
>>>
>>>import java.awt.CardLayout;
>>>import java.awt.Cursor;
>>>import java.awt.Frame;
>>>
>>>import javax.swing.JPanel;
>>>import javax.swing.UIManager;
>>>import javax.swing.UnsupportedLookAndFeelException;
>>>
>>>import org.eclipse.swt.SWT;
>>>import org.eclipse.swt.awt.SWT_AWT;
>>>import org.eclipse.swt.layout.FillLayout;
>>>import org.eclipse.swt.widgets.Composite;
>>>import org.eclipse.swt.widgets.Display;
>>>import org.eclipse.swt.widgets.Shell;
>>>
>>>public class SWTAWTTest {
>>> public static void main(String[] args) {
>>> final Display display = new Display();
>>> final Shell shell = new Shell(display);
>>> shell.setLayout(new FillLayout());
>>>
>>> System.getProperties().list(System.out);
>>>
>>> Composite container = new Composite(shell, SWT.EMBEDDED);
>>> container.setLayout(new FillLayout());
>>>
>>> Frame frame = SWT_AWT.new_Frame(container);
>>>
>>> try {
>>>
>
> UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClass Name());
>
>>> } catch (ClassNotFoundException e) {
>>> e.printStackTrace();
>>> } catch (InstantiationException e) {
>>> e.printStackTrace();
>>> } catch (IllegalAccessException e) {
>>> e.printStackTrace();
>>> } catch (UnsupportedLookAndFeelException e) {
>>> e.printStackTrace();
>>> }
>>>
>>> JPanel panel = new JPanel(true);
>>>
>>> panel.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
>>>
>>> frame.add(panel);
>>> frame.setLayout(new CardLayout());
>>> frame.pack();
>>>
>>>
>>> shell.pack();
>>> shell.open();
>>>
>>> while (!shell.isDisposed ()) {
>>> if (!display.readAndDispatch ()) display.sleep ();
>>> }
>>> display.dispose ();
>>> }
>>>}
>>>
>>>
>>>Best regards,
>>>Boby
>>>
>>>
>>
>>
>
>
Previous Topic:Disposing of a shell when a child shell is disposed
Next Topic:Tabbing not working on Custom widget when key events are listened to
Goto Forum:
  


Current Time: Fri Apr 26 14:46:51 GMT 2024

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

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

Back to the top