I have JTabbedPanewith custom component tabs. This component contains JLabel(to display the tab title) and JButton(close button). When I change the text in JLabel, it JLabelstops receiving mouse events, and I can no longer select this tab, when I click on the label directly, if I click on the shortcut, then I can select the tab. Any ideas?
Code snippet:
class ShellPanelTabComponent extends JPanel implements ActionListener{
private ShellPanel panel;
private JLabel label;
public ShellPanelTabComponent(final ShellPanel panel){
super(new FlowLayout(FlowLayout.LEFT, 0, 0));
this.panel = panel;
setOpaque(false);
label = new JLabel(panel.getTitle());
label.setFocusable(false);
add(label);
label.setBorder(BorderFactory.createEmptyBorder(2,0,0,5));
CloseButton closeButton = new CloseButton(panel);
add(closeButton);
closeButton.addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
panel.getShell().removeShellPanel(panel);
}
public JLabel getLabel() {
return label;
}
}
source
share