Solved

center the text with this setup inside the button

Posted on 2004-04-27
4
201 Views
Last Modified: 2011-10-03
How could I center the text with this setup inside the button would it be:

 b.setHorizontalTextPosition(SwingConstants.CENTER);

JButton b = new JColoredButton("", Color.green, Color.black);
          b.setPreferredSize( new Dimension( 40, 20 ) );
          b.setHorizontalTextPosition(SwingConstants.LEFT);
          buttons.put("b"+(i+1), b);
          b.addActionListener(this);
          gridPanel.add(b);
         }
     JButton b1 = (JButton) buttons.get("b1");             // this is where I would place them
     b1.setText("Axe Kick");
0
Comment
Question by:Drop_of_Rain
  • 2
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 75 total points
Comment Utility
b.setHorizontalAlignment(SwingConstants.CENTER);
0
 

Author Comment

by:Drop_of_Rain
Comment Utility
That is what I though it would be. I am going to close this question.

I want to ask you a couple of questions so I will post them soon.

Thanks for the help
Christopher

P.S.
I am learning so much from you. What I am learning, I think is very important. I am learning to think in less code to do the same job. I have been very impressed with your style of code writing, you have doon just that, less code for the same job. Thanks for being my teacher.
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
stop it your embarassing me :)
0
 

Author Comment

by:Drop_of_Rain
Comment Utility
Thanks,
Christopher
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now