Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8714423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:35:33+00:00 2026-06-13T05:35:33+00:00

Using SWT on Mac. I create a Unified ToolBar. On this toolbar there is

  • 0

Using SWT on Mac. I create a Unified ToolBar. On this toolbar there is a Scale widget, and a Label widget. The label displays the current value of the scale, updated by a SelectionListener on the Scale

Here is the simple test code (included below) running

On program launch, the thumb of the scale widget will not move. The label shows the value is changing exactly as expected, the Scale widget is correctly tracking cursor movement, and reporting the changed value. The thumb does not move.

Closing the Unified toolbar and re-opening it (using the small button top right) makes the thumb fully operational. The thumb tracks the cursor.

Simple, compilable, runnable test code replicating problem is here:

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.*;


public class scaleTest
    {
        private static Shell shell;
        private static Display display;
        private ToolBar UnifiedToolBar;
        private Scale scale;


        private scaleTest()
            {
                UnifiedToolBar = shell.getToolBar();

            ToolItem containScale = new ToolItem( UnifiedToolBar, SWT.SEPARATOR );
            containScale.setWidth( 200 );

            scale = new Scale( UnifiedToolBar, SWT.HORIZONTAL );
            scale.setMaximum( 72 );
            scale.setSelection( 2 );
            scale.setMinimum( 6 );
            scale.setIncrement( 4 );
            scale.setPageIncrement( 4 );
            scale.setSize( 180, 24 );
            containScale.setControl( scale );


            ToolItem containLabel = new ToolItem( UnifiedToolBar, SWT.SEPARATOR );
            containLabel.setWidth( 20 );
            final Label label = new Label( UnifiedToolBar, SWT.NONE );
            label.setText( "32" );
            containLabel.setControl( label );


            scale.addSelectionListener( new SelectionAdapter()
            {
                @Override
                public void widgetSelected( SelectionEvent selectionEvent )
                    {
                        label.setText( String.valueOf( scale.getSelection() ) );

                    }
            } ); // end addSelectionListener


        } // end of constructor


    public static void main( String[] args )
        {


            display = Display.getDefault();
            shell = new Shell( display );


            shell.setText( "scaleTest App" );
            shell.setSize( 400, 200 );
            shell.setLocation( (display.getClientArea().width / 2) - 200
                                                    ,(display.getClientArea().height / 2) - 100 );
            shell.setLayout( new FormLayout() );


            scaleTest testExample = new scaleTest();

            shell.open();
            while( !shell.isDisposed() )
                {
                    if( !display.readAndDispatch() )
                        display.sleep();
                }
            display.dispose();
        }
} // end scaleTest class

I have tried layout(), layout(true, true), redraw(), paint(), pack(), on the shell, the toolbar, and the Scale widget in as many combinations as seemed reasonable. A normal human being would consider it an unreasonably large number of combinations.

Question 1: How to get the thumb working normally on start-up?

Follow up question, of much lesser importance:

Question 2: The Scale widget appears to ignore both pageIncrement and increment settings. Why?

Any assistance would be very much appreciated.

Update: Late night playing around. Moving the Scale widget to the shell – and no other change to the test code included above, widget works as desired – thumb works right off the bat. It would see the Scale and the unified toolbar don’t like each other too much on first sight.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:35:34+00:00Added an answer on June 13, 2026 at 5:35 am

    Question 2:

    You can achieve the “snapping” to the step values by adding a Listener to SWT.Selection. In the code below it will snap to all multiples of 5:

    scale.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            // get the current selection and "round" it to the next 5er step
            int scaleValue = scale.getSelection();
            scaleValue = (int)(Math.round(scaleValue / 5.0) * 5);
    
            // update the label
            label.setText("" + (scaleValue));
            label.pack();
    
            // update the scale selection
            scale.setSelection(scaleValue);
        }
    });
    

    I can’t really help you with Question 1 though…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the most stable SWT Cocoa downloads for Mac OS X and
Is there a way using SWT to get a list of all processes currently
I'd like to create an MDI application using SWT. I've done extensive searches and
I would like to ask the same thing than this question but using SWT:
I am using SWT, I want to create a new control which will include
I am trying to create a base dialog class using SWT and JFace: public
I have a Java SWT application and i'm using this snippet of code to
I'm writing a project in Java using SWT. I would like to create a
I write application in Java using SWT. I would like to create unique file
I'm quite new to creating layout using SWT. This is what I have to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.