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 09:56 Go to next message
David Crecente is currently offline David Crecente
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 11:02 Go to previous message
Grant Gayed is currently offline Grant Gayed
Messages: 2148
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 Jul 24 00:35:10 EDT 2014

Powered by FUDForum. Page generated in 0.02698 seconds