package ui.label;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import javax.swing.JPanel;
import ui.misc.CloseButton;
import ui.tabs.AbstractDynamicTab;
public class DynamicTabLabel extends JPanel
{
private static final long serialVersionUID = -3914929158639846160L;
private AbstractDynamicTab tab;
public DynamicTabLabel(AbstractDynamicTab tab, String title)
{
setOpaque(false);
BorderLayout layout = new BorderLayout();
layout.setHgap(4);
setLayout(layout);
this.tab = tab;
add(new JLabel(title), BorderLayout.CENTER);
CloseButton closeButton = new CloseButton(new CloseButtonListener());
add(closeButton, BorderLayout.EAST);
}
private class CloseButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
tab.close();
}
}
}