/** @param parent the profile form which will own the this tab component. */ public ProfileTabComponent(final ProfileForm parent) { // unset default FlowLayout' gaps super(new FlowLayout(FlowLayout.LEFT, 0, 0)); this.parent = parent; setOpaque(false); final JLabel label = new JLabel(); label.setText(parent.getName()); parent.addPropertyChangeListener( "name", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { label.setText(evt.getNewValue().toString()); } }); add(label); // add more space between the label and the button label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, BORDER_RIGHT)); // tab button button = new CloseTabButton(); button.setVisible(false); add(button); // add more space to the top of the component setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); }