Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Label text allignment

Posted on 2004-10-23
Medium Priority
Last Modified: 2010-03-31
Hi Experts!!
Here is a piece of code i am using to postion the text in my label in center, but it not working. Could u please tell me what is wrong?

aDie = new JLabel( String.valueOf(top)  );
      aDie.setBounds(10, 10, 10, 10);
      aDie.setPreferredSize(new Dimension(90,90));
     aDie.setFont(new Font("Sansserif", Font.BOLD, 80));

     aDie.setBackground( Color.white );
Question by:komlaaa
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 86

Accepted Solution

CEHJ earned 500 total points
ID: 12389058
JLabel aDie = new JLabel(String.valueOf(top), SwingConstants.CENTER);

Author Comment

ID: 12389116
Thanks CEHJ, the answer was quick!!
thanks again.
LVL 86

Expert Comment

ID: 12389130

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question