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 6886995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:49:47+00:00 2026-05-27T05:49:47+00:00

Im doing a tutorial and i added a few labels myself to test it

  • 0

Im doing a tutorial and i added a few labels myself to test it out and throw a few things around to get a better grip on it, and labellast.setLocation seems to just do nothing to labellast, the location of the label wont change…

Here is my source:

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setSize(250, 350);

    Label label1 = new Label(shell, SWT.BORDER);
    label1.setText("Hello World!");
    label1.setSize(100, 20);
    label1.setLocation(30, 30);

    Text text1 = new Text(shell, SWT.BORDER);
    text1.setText("Type Here");
    text1.setTextLimit(50);
    text1.setBounds(10, 10, 200, 20);
    text1.setLocation(30, 60);

    Label hello = new Label(shell, SWT.BORDER);
    hello.setText("type what the top line says.");
    hello.setSize(190, 20);
    hello.setLocation(30, 90);

    Label sep1 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL
            | SWT.SHADOW_IN);
    sep1.setBounds(30, 60, 100, 120);
    Label label2 = new Label(shell, SWT.NONE);
    label2.setText("World Hello");
    label2.setSize(100, 20);
    label2.setLocation(30, 150);

    Label sep2 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    sep2.setBounds(30, 120, 100, 20);

    Label label3 = new Label(shell, SWT.NONE);
    label3.setSize(100, 20);
    label3.setLocation(30, 210);
    label3.setBackground(new Color(display, 200, 111, 50));
    label3.setText("World World.");

    Text text2 = new Text(shell, SWT.NONE);
    text2.setEchoChar('*');
    text2.setBounds(10, 50, 200, 20);
    text2.setText("Password");
    text2.setLocation(30, 250);
    text2.setEditable(false);

    Label labellast = new Label(shell, SWT.NONE);
    labellast.setLocation(30, 300);
    labellast.setText("You cant edit that^^^");
    labellast.setBounds(10, 50, 200, 20);

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

    }
    display.dispose();
}

}
  • 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-27T05:49:47+00:00Added an answer on May 27, 2026 at 5:49 am

    The method setBounds sets both the position and size.

    setBounds(int x, int y, int width, int height)
    

    Get rid of the call to setLocation and just use setBounds:

    labellast.setText("You cant edit that^^^");
    labellast.setBounds(30, 300, 200, 20);
    

    In your code you are calling setLocation first, then later overriding the position when you call setBounds which makes it look like you can’t change the location.

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

Sidebar

Related Questions

I was doing the tutorial from the book teach yourself django in 24 hours
Sorry for stupid questions, I'm doing everything as described in this tutorial: http://www.functionx.com/visualc/howto/calldlgfromdlg.htm I
Doing an ajax get request works as expected using the following code: $.ajax({ type:
I'm trying to get a list of changed/added/deleted/etc. files for a commit in my
I was doing RoR tutorial wherein we could add,update,delete user details in the application
I am doing [this tutorial][1] over at www.asp.net. It is written for ASP.NET MVC
I was doing a tutorial and the author shows an example however I am
I'm doing wiki in django tutorial and in tutorial earlier version of django is
I'm doing this tutorial on how to reset a forgotten password. It all works,
I’m looking for some samples/tutorials/general pointers in doing either of the following. 1) Create

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.