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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:47:40+00:00 2026-06-05T10:47:40+00:00

I want to position my image which I have placed inside a JLabel. Here

  • 0

I want to position my image which I have placed inside a JLabel. Here is my code:

public Main() {
    setLayout (new FlowLayout());
            image = new ImageIcon(getClass().getResource("title.gif"));
            image1 = new JLabel(image);
            image1.setAlignmentX(400);
            image1.setAlignmentY(400);
            add(image1);
}

It displays the image, but the lines

image1.setAlignmentX(400);
image1.setAlignmentY(400);

Do not do anything.
I’m new to Java, any help appreciated.

(I would appreciate an example.)

  • 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-05T10:47:43+00:00Added an answer on June 5, 2026 at 10:47 am

    Issues:

    • You’re using FlowLayout which won’t respect absolute positioning even if you were doing it correctly.
    • setAlignmentX(...) is for suggesting to the container the component’s alignment along the x-axis. As noted above, it takes a float number from 0.0f to 1.0f, with 0f meaning alignment to the left, 0.5f centered, and 1.0f to the right. You definitely do not want to use this method or it’s y counterpart here.
    • Absolute positioning requires a container that uses a null layout, not FlowLayout.
    • Absolute positioning is done via the setBounds(...) or the setLocation(...) method.
    • Having said this, I suggest that you don’t try to position things absolutely unless there’s an absolute need, and there’s a good chance here that you don’t, that there’s a better way.

    Please tell us more of the details of your problem, not how you’re trying to solve it, and we’ll probably be able to help you better.

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

Sidebar

Related Questions

I have an image which is at a random position every time the application
I have these following code in which I want to enable 2nd hover state
I have an image which constitutes the subject of a question and I want
I have two div's, nested, and want to have an image placed in front
I have sprites image, which contain set of sprites. i want to pull out
I want to position divs on top of one another. I have created a
I have a code like <a href='javascript:showImage()'><img src='/public/visit_images/img1.jpg' width=100 height=100></img></a> <div class='orig_image' style=position:absolute; width:200px;
I want to caputure an image of a control which is an ActiveX imported
i have a grid view which contain images when click on one image it
Have some data in a sybase image type column that I want to use

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.