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

  • SEARCH
  • Home
  • 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 6733281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:45:00+00:00 2026-05-26T10:45:00+00:00

How can i step space as between 3 buttons in right and bottom items;

  • 0

How can i step space as between 3 buttons in right and bottom items; and memory and labelM ???
There must be equal space, moreover memory buttons and digit buttons must be equal height, help me to do this please, becouse my brain couldn’t imagine how to do this
this is code

package calc;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.wb.swt.SWTResourceManager;

public class View extends ViewPart {
    public Text inputText;
    public Text inputText2;
    public Label label;
    public Label label2;
    public Composite mainComposite;
    public Calculation calcul;

    public View()
    {
        calcul = new Calculation();

    }

    public void createPartControl(Composite parent) {
        Composite mainComposite = new Composite(parent, SWT.NONE);
        GridLayout gltop = new GridLayout(1, false);        
        gltop.numColumns = 1;       
        mainComposite.setLayout(gltop);
        //mainComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
        createTop(mainComposite);
        createBott(mainComposite);      
    }

    private void createTop(Composite parent)
    {
        GridLayout gltop = new GridLayout(1, false);        
        gltop.numColumns = 1;
        GridData data = new GridData(GridData.FILL_HORIZONTAL);     
        Composite topComposite = new Composite(parent, SWT.NONE);       
        topComposite.setLayout(gltop);
        topComposite.setLayoutData(data);
        //topComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_RED));

        /*inputText = new Text(topComposite, SWT.BORDER);
        inputText.setLayoutData(data);
        inputText.setFont(SWTResourceManager.getFont("", 18, SWT.BOLD));*/
        label = new Label(topComposite,SWT.RIGHT | SWT.BORDER);
        label.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
        label.setLayoutData(data);
        label.setFont(SWTResourceManager.getFont("", 18, SWT.BOLD));
        label.setText(calcul.output);
    }

    private void createBott(Composite parent)
    {
        GridLayout glbot = new GridLayout(1, false);        
        glbot.numColumns = 2;
        GridData data = new GridData(GridData.FILL_BOTH);       
        Composite botComposite = new Composite(parent, SWT.NONE);       
        botComposite.setLayout(glbot);
        botComposite.setLayoutData(data);
        //botComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_YELLOW));            

        createLeft(botComposite);       
        createRight(botComposite);      
    }

    private void createLeft(Composite parent)
    {           
        Composite leftComposite = new Composite(parent, SWT.NONE);  
        GridLayout glleft = new GridLayout(1, false);       
        GridData data = new GridData(GridData.FILL_BOTH);   
        leftComposite.setLayout(glleft);
        leftComposite.setLayoutData(data);
        //leftComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_CYAN)); 
        glleft.marginBottom = 5;
        glleft.marginTop = 7;
        label2 = new Label(leftComposite,SWT.BORDER | SWT.CENTER);
        label2.setLayoutData(data);
        double a = Double.parseDouble(label.getText());
        Button buttonMC = createFuncDigButtons(leftComposite, data, "M+", 'P');
        Button buttonMR = createFuncDigButtons(leftComposite, data, "M-", 'M');
        Button buttonMS = createFuncDigButtons(leftComposite, data, "MR", 'R');
        Button buttonMpl = createFuncDigButtons(leftComposite, data, "MC", 'c');
    }

    private void createRight(Composite parent)
    {
        GridLayout glright = new GridLayout(1, false);      
        GridData data = new GridData(GridData.FILL_BOTH);       
        Composite rightComposite = new Composite(parent, SWT.NONE);
        glright.numColumns = 1;
        glright.horizontalSpacing = 0;
        glright.verticalSpacing = 0;
        rightComposite.setLayout(glright);
        rightComposite.setLayoutData(data);
        //rightComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN));  

        createRightTop(rightComposite);
        createRightBot(rightComposite);
    }

    private void createRightTop(Composite parent)
    {
        Composite rightTopComposite = new Composite(parent, SWT.NONE);
        GridLayout glltop = new GridLayout(1, false);       
        GridData data = new GridData(GridData.FILL_BOTH);   
        glltop.numColumns = 3;
        glltop.marginBottom = 0;
        rightTopComposite.setLayout(glltop);
        rightTopComposite.setLayoutData(data);
        //rightTopComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_MAGENTA)); 

        Button buttonBack = createFuncDigButtons(rightTopComposite, data, "Backspace", 'B');
        Button buttonC = createFuncDigButtons(rightTopComposite, data, "C", 'C');
        Button buttonCE = createFuncDigButtons(rightTopComposite, data, "CE", 'E');
    }

    private void createRightBot(Composite parent)
    {
        GridLayout glright = new GridLayout(1, false);      
        GridData data = new GridData(GridData.FILL_BOTH);       
        Composite rightBotComposite = new Composite(parent, SWT.NONE);      
        glright.numColumns = 5;
        glright.marginTop = 0;
        rightBotComposite.setLayout(glright);
        rightBotComposite.setLayoutData(data);
    //  rightBotComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY));      
        Button button7 = createFuncDigButtons(rightBotComposite, data, "7", '7');
        Button button8 = createFuncDigButtons(rightBotComposite, data, "8", '8');
        Button button9 = createFuncDigButtons(rightBotComposite, data, "9", '9');
        Button buttonDev = createFuncDigButtons(rightBotComposite, data, "/", '/');
        Button buttonSQRT = createFuncDigButtons(rightBotComposite, data, "sqrt", 't');
        Button button4 = createFuncDigButtons(rightBotComposite, data, "4", '4');
        Button button5 = createFuncDigButtons(rightBotComposite, data, "5", '5');
        Button button6 = createFuncDigButtons(rightBotComposite, data, "6", '6');
        Button buttonMult = createFuncDigButtons(rightBotComposite, data, "*", '*');
        Button buttonPer = createFuncDigButtons(rightBotComposite, data, "%", '%');
        Button button1 = createFuncDigButtons(rightBotComposite, data, "1", '1');
        Button button2 = createFuncDigButtons(rightBotComposite, data, "2", '2');
        Button button3 = createFuncDigButtons(rightBotComposite, data, "3", '3');
        Button buttonMinus = createFuncDigButtons(rightBotComposite, data, "-", '-');
        Button buttonDev1 = createFuncDigButtons(rightBotComposite, data, "1/x", 'X');
        Button button0 = createFuncDigButtons(rightBotComposite, data, "0", '0');
        Button buttonPM = createFuncDigButtons(rightBotComposite, data, "+/-", 'p');
        Button buttonD = createFuncDigButtons(rightBotComposite, data, ".", '.');       
        Button buttonPlus = createFuncDigButtons(rightBotComposite, data, "+", '+');        
        Button buttonR = createFuncDigButtons(rightBotComposite, data, "=", '=');
    }

    public Button createFuncDigButtons(Composite parent, GridData gridData, final String digit, final char formethod)
    {
        Button button = new Button(parent, SWT.PUSH);
          button.setLayoutData(gridData);
          button.setText(String.valueOf(digit));
          button.addSelectionListener(new SelectionListener() {
            @Override
            public void widgetSelected(SelectionEvent arg0) {
                calcul.getDigit(formethod);
                label.setText(calcul.output);
                if (calcul.memtrue)
                {
                    label2.setText("M");
                }
                else
                {
                    label2.setText("");
                }
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent arg0) {
              /* do nothing */
            }
          });
          button.addKeyListener(new KeyListener() {

            @Override
            public void keyReleased(KeyEvent arg0) {
            }

            @Override
            public void keyPressed(KeyEvent arg0) {         
                    calcul.getDigit(arg0.character);
                    label.setText(calcul.output);
            }});
          button.setFocus();
        return button;
    }

    public void setFocus() {
    }
}

and this is image: calculator

http://s008.radikal.ru/i306/1110/65/0708165834c9.jpg

  • 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-05-26T10:45:01+00:00Added an answer on May 26, 2026 at 10:45 am

    Don’t create left and right composites. Instead put all buttons (except Backspace, C, and CE, which should go under a single composite with horizontalSpan = 3) directly under botComposite and use empty labels for spacing. As @Chris Dennett pointed out, make sure every widget has its own layout data.

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

Sidebar

Related Questions

Is there a way that i can save data on each step in wizard
I have the problem that an specific step in Ant can only be executed
In SAS 9, how can I in a simple data step, rearrange the order
Can you tell me what is the difference between abstraction and information hiding in
How can i pass a string delimited by space or comma to stored procedure
Can somebody point me to a resource that explains how to go about having
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can you cast a List<int> to List<string> somehow? I know I could loop through
can you recommend some good ASP.NET tutorials or a good book? Should I jump
Can a LINQ enabled app run on a machine that only has the .NET

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.