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