Hello All

This is probably an easy one (I hope). I have a JLabel whose text I am trying to right justify. Should be <labelname>.setHorizontalTextPosition(JLabel.RIGHT). Simple, right? (wrong).

It does nothing to the text on the label. The text just shows up with it's default left justification. However, when I set this property to right justify when the label is created in the constructor, it works fine. I've run into this snag before and have not been able to ever get the method to work. I've tried setting the horizontal position BEFORE setting the text thinking it needs text in order to know what to do but that fails also.

Forgive my newness to Java, this is probably something very simple..but I can't see it.

Thank you all very much. I appreciate any help.

public void focusLost(FocusEvent e)
{

   updateEL();

} // end focusLost


public void updateEl()
{
   float workingEl = 0.0f;
   int i;

   workingEl = startingEl;

   for (i=0; i<=SETUPS; i++)
   {
      try
      {
          workingEl += Float.parseFloat(bsTextFields[i].getText());
				dtlLabels[(i*2)+1][2].setText(String.valueOf(workingEl)); 
				dtlLabels[(i*2)+1][2].setHorizontalTextPosition(JLabel.CENTER);

				workingEl -= Float.parseFloat(fsTextFields[i].getText());
				dtlLabels[(i+1)*2][4].setText(String.valueOf(workingEl));


       }
       catch (NumberFormatException e) // this will happen on the first field that has no data entered yet, done w/screen update!!
       {

           i = SETUPS; // 1st field that has no value, nothing else on screen to update, done!
        }

    }
} // end updateEL

I figured it out. Knew it was something simple (don't you just hate that!!) The SetHorizontalTextPosition method is only for labels that have an image. For labels that have only text the method is setHorizontalAlignment. I used the wrong method. Problem solved.

I apologize for taking up space on this one. If I figure out my own problem, I hope its ok to mark it solved (I'm new at this forum).

This question has already been answered. Start a new discussion instead.