Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT AWT bridge(mouse wheel listeners don't work)
SWT AWT bridge [message #511695] Tue, 02 February 2010 14:56 Go to next message
David Crecente is currently offline David CrecenteFriend
Messages: 18
Registered: July 2009
Junior Member
Hi all,
I'm using the bridge awt swt to work with JXMapKit.

When I use JXMapKit in a swing component like a JFrame I can manage the zoom with the wheel in the mouse.
If I move this compnent to the bridge this event is lost.

I simplify my code and I did the same test with a button in a panel. The result was the same. The event mouse wheel is fired only when I use JFrame and is not fired with the bridge.
The next code made with swing works:
        JPanel panel = new JPanel();
        JButton button = new JButton();
        button.setText( "moves the wheel" );
        button.addMouseWheelListener( new MouseWheelListener() {
            
            @Override
            public void mouseWheelMoved( MouseWheelEvent e )
            {
                System.out.println("wheel moved");
                
            }
        });
        panel.add( button, BorderLayout.CENTER );

        JFrame frame = new JFrame( "title" );
        frame.add( panel );

        frame.pack();
        frame.setVisible( true );


The next code made using the bridge in a view doesn't work:
    public void createPartControl(final Composite parent) {
        Composite composite = new Composite(parent, SWT.EMBEDDED | SWT.NO_BACKGROUND);
        composite.setLayout( new MigLayout("wrap 1, fillx") );
        composite.setLayoutData( "pushx, growx" );
        java.awt.Frame frame = SWT_AWT.new_Frame(composite);
        JPanel panel = new JPanel( new BorderLayout() );
        frame.add( panel );
        JButton button = new JButton();
        button.setText( "moves the wheel" );
        button.addMouseWheelListener( new MouseWheelListener() {
            
            @Override
            public void mouseWheelMoved( MouseWheelEvent e )
            {
                System.out.println("wheel moved");
                
            }
        });
        panel.add( button, BorderLayout.CENTER );






Re: SWT AWT bridge [message #511719 is a reply to message #511695] Tue, 02 February 2010 16:02 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi,

It looks like you're seeing
https://bugs.eclipse.org/bugs/show_bug.cgi?id=261764 . I would suggest
CC'ing yourself to this report in order to be notified of its progress. I
don't know of a workaround to suggest.

Grant


"David Crecente" <david.crecente@gmail.com> wrote in message
news:hk9ef8$gms$1@build.eclipse.org...
> Hi all,
> I'm using the bridge awt swt to work with JXMapKit.
>
> When I use JXMapKit in a swing component like a JFrame I can manage the
zoom with the wheel in the mouse.
> If I move this compnent to the bridge this event is lost.
>
> I simplify my code and I did the same test with a button in a panel.
The result was the same. The event mouse wheel is fired only when I use
JFrame and is not fired with the bridge.
> The next code made with swing works:
> JPanel panel = new JPanel();
> JButton button = new JButton();
> button.setText( "moves the wheel" );
> button.addMouseWheelListener( new MouseWheelListener() {
>
> @Override
> public void mouseWheelMoved( MouseWheelEvent e )
> {
> System.out.println("wheel moved");
>
> }
> });
> panel.add( button, BorderLayout.CENTER );
>
> JFrame frame = new JFrame( "title" );
> frame.add( panel );
>
> frame.pack();
> frame.setVisible( true );
>
> The next code made using the bridge in a view doesn't work:
> public void createPartControl(final Composite parent) {
> Composite composite = new Composite(parent, SWT.EMBEDDED |
SWT.NO_BACKGROUND);
> composite.setLayout( new MigLayout("wrap 1, fillx") );
> composite.setLayoutData( "pushx, growx" );
> java.awt.Frame frame = SWT_AWT.new_Frame(composite);
> JPanel panel = new JPanel( new BorderLayout() );
> frame.add( panel );
> JButton button = new JButton();
> button.setText( "moves the wheel" );
> button.addMouseWheelListener( new MouseWheelListener() {
>
> @Override
> public void mouseWheelMoved( MouseWheelEvent e )
> {
> System.out.println("wheel moved");
>
> }
> });
> panel.add( button, BorderLayout.CENTER );
>
>
>
>
>
>
Previous Topic:problem with setSelection() for Graphical view
Next Topic:Save view as jpg image
Goto Forum:
  


Current Time: Thu Apr 25 17:19:03 GMT 2024

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

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

Back to the top