Title Image is not centered in the Toolbar

15 Views Asked by At

I was playing with the Netflix Clone App that was in one of the Codenameone Tutorials. I noticed in the simulator, the "Netflix" image title was not centered as expected according to the video:

Title Image not Centered

The code that is supposed to display the title is:

((Label)tb.getTitleComponent()).setIcon(r.getImage("netflix-logo.png"));

After invoking a deprecated method setAlignment:

Label title = (Label)tb.getTitleComponent();
title.setAlignment(Component.CENTER);

Now the title is displayed properly in the simulator:

Title Image Centered

Since the example was done a few years ago, can anyone tell me which is the correct way of centering an image title in the Toolbar?

Thanks.

1

There are 1 best solutions below

0
Shai Almog On

I'm looking at the code right now and can't find setAlignment there.

I don't think I would have used it. The right way to center a title is tb.setTitleCentered(true);.