Example usage for javax.swing.table JTableHeader add

List of usage examples for javax.swing.table JTableHeader add

Introduction

In this page you can find the example usage for javax.swing.table JTableHeader add.

Prototype

public Component add(String name, Component comp) 

Source Link

Document

Adds the specified component to this container.

Usage

From source file:org.apache.cayenne.modeler.editor.AbstractCallbackMethodsTab.java

private void addButtonAtHeader(JTable table, JButton button, ActionListener buttonListener,
        ImageIcon buttonIcon) {/*  ww w.ja  v a2  s  .c  o  m*/
    PanelBuilder builder = new PanelBuilder(new FormLayout("left:10dlu, 2dlu", "center:10dlu"));
    CellConstraints cc = new CellConstraints();

    button.setIcon(buttonIcon);
    button.setOpaque(false);
    button.setBorderPainted(false);
    button.setContentAreaFilled(false);
    button.addActionListener(buttonListener);

    builder.add(button, cc.xy(1, 1));

    JPanel buttonPanel = builder.getPanel();
    buttonPanel.setOpaque(false);

    JTableHeader header = table.getTableHeader();
    header.setLayout(new BorderLayout());
    header.setReorderingAllowed(false);
    header.setPreferredSize(new Dimension(150, 20));
    header.add(buttonPanel, BorderLayout.EAST);
}