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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.