Reputation: 99
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:
What can be wrong?... thanks in advance
Upvotes: 3
Views: 400
Reputation: 3084
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.
Upvotes: 3