3

I am trying to put a JLabel in tab of JTabbedPane but it isn't showing... here is the code that i am 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 the result:

enter image description here

What can be wrong?... thanks in advance

kid_goth
  • 89
  • 12
  • 1
    Rather than animated images of your IDE and uncompilable code snippets.. For better help sooner, post an [MCVE](http://stackoverflow.com/help/mcve) (Minimal Complete Verifiable Example) or [SSCCE](http://www.sscce.org/) (Short, Self Contained, Correct Example). – Andrew Thompson Jul 02 '15 at 21:57

1 Answers1

3

This can be caused because of this:

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

This won't merge the labelPest and ButtonTabPanel together, this firstly use labelPest, but then ButtonTabPanel overwrites labelPest.

Your ButtonTabPanel should contain a Label, then this will work. Without the source code of this class I cant help you in general.

maskacovnik
  • 3,080
  • 5
  • 20
  • 26
  • ooooh yeaahh... thanks..!!! that was my wrong in ButtonTabPanel i added the label and it's work perfectly... – kid_goth Jul 02 '15 at 22:01