Install JLabel in JTabbedPane (JAVA)

I'm trying to put the JLabel in the JTabbedPane but it doesn't show up ... here is the code I'm using:

...
public class FormulariosTabbedPane extends JTabbedPane implements IEventoListener<TipoDeEvento> {

...
    @Override
    public void eventoDisparado(EventoGenerado<TipoDeEvento> eventoGenerado) {
        ...

        addTab(null, pnlCrearEditarProceso);

        JLabel labelPest = new JLabel("Crear proceso");
        labelPest.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
        labelPest.setForeground(Color.WHITE);

        setTabComponentAt(indexOfComponent(pnlCrearEditarProceso), labelPest);
        setTabComponentAt(indexOfComponent(pnlCrearEditarProceso), new ButtonTabPanel(this));
        setSelectedIndex(indexOfComponent(pnlCrearEditarProceso));

        ...
    }
...

}

      

And here's the result:

enter image description here

What could be wrong? ... thanks in advance

+3


source to share


1 answer


It can be caused due to this:

setTabComponentAt(indexOfComponent(pnlCrearEditarProceso),labelPest);
setTabComponentAt(indexOfComponent(pnlCrearEditarProceso),new ButtonTabPanel(this));

      



This won't merge labelPest

and ButtonTabPanel

together, it uses labelPest first, but then ButtonTabPanel overwrites labelPest.

Your ButtonTabPanel must contain a label, then this will work. Without the source code for this class, I can't help you at all.

+3


source







All Articles