Example usage for javax.swing.table JTableHeader setResizingAllowed

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

Introduction

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

Prototype

@BeanProperty(description = "Whether the user can resize columns by dragging between headers.")
public void setResizingAllowed(boolean resizingAllowed) 

Source Link

Document

Sets whether the user can resize columns by dragging between headers.

Usage

From source file:com.archivas.clienttools.arcmover.gui.panels.ProfilePanel.java

/**
 * Enables/disables all subcomponents of this panel. This also toggles the ability to drag and
 * drop and conditionally freezes the ability to resize the file list column headers.
 *
 * @param enabled/*w ww . j a v  a  2  s. c o m*/
 *            Whether or not this panel is enabled
 */
private void subSetEnabled(final boolean enabled) {
    if (!SwingUtilities.isEventDispatchThread()) {
        String errMsg = "subSetEnabled is not on the EDT but it should be";
        IllegalStateException ex = new IllegalStateException(errMsg);
        LOG.log(Level.SEVERE, errMsg, ex);
        throw ex;
    }
    enableDragAndDrop(enabled);
    GUIHelper.enableComponent(this, enabled);
    setEnabled(true); // Re-enable the panel since GUIHelper.enableComponent disables it
    sslButton.setEnabled(enabled && profileModel.getProfileAdapter() != null
            && profileModel.getProfileAdapter().getSSLCertChain() != null);
    browseDirectoryButton.setEnabled(enabled && getSelectedProfile().getType() == ProfileType.FILESYSTEM);
    JTableHeader header = fileList.getTableHeader();
    if (header != null) {
        header.setResizingAllowed(enabled);
    }
}

From source file:edu.ucla.stat.SOCR.chart.Chart.java

public void updateEditableHeader(TableColumnModel aColumnModel) {
    dTableHeader = new EditableHeader(aColumnModel);
    /*for (int i=0; i<aColumnModel.getColumnCount(); i++){
       System.out.println("H "+aColumnModel.getColumn(i).getHeaderValue());
    }*///from  w  w  w  .  j a  v a  2 s.c o  m
    dTableHeader.setEditingColumn(-1);
    dataTable.setTableHeader(dTableHeader);
    dataTable.validate();

    dataPanel.removeAll();

    JTableHeader corner = headerTable.getTableHeader();
    corner.setReorderingAllowed(false);
    corner.setResizingAllowed(false);
    JScrollPane tablePanel = new JScrollPane(dataTable);
    tablePanel.setRowHeaderView(headerTable);
    tablePanel.setCorner(JScrollPane.UPPER_LEFT_CORNER, corner);
    new JScrollPaneAdjuster(tablePanel);
    new JTableRowHeaderResizer(tablePanel).setEnabled(true);
    dataPanel.add(tablePanel);

    JScrollPane st = new JScrollPane(summaryPanel);
    st.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 3));
    dataPanel.add(new JScrollPane(st));
    dataPanel.validate();
    //System.out.println("table Header updated");
}

From source file:edu.ucla.stat.SOCR.chart.Chart.java

/**
 * clear data panel/*  w w w  .  j  ava 2  s.co m*/
 *
 */
public void resetTable() {

    //   System.out.println("resetTable get called");
    for (int i = 0; i < columnNumber; i++)
        columnNames[i] = new String(DEFAULT_HEADER + (i + 1));

    tModel = new javax.swing.table.DefaultTableModel(dataObject, columnNames);
    hModel = new DefaultTableModel(0, 1);

    for (int i = 0; i < tModel.getRowCount(); i++)
        hModel.addRow(new Object[] { (i + 1) + ":" });

    dataTable = new JTable(tModel);
    /*   System.out.println("here2");
       dataTable.getTableHeader().addMouseListener(new MouseAdapter(){  
           public void mouseClicked(MouseEvent e) {  
     TableColumnModel colModel = dataTable.getColumnModel();
       int columnModelIndex = colModel.getColumnIndexAtX(e.getX());
       selectedHeaderColumnIndex = colModel.getColumn(columnModelIndex)
           .getModelIndex();
               
        System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex);
     }  
       });*/
    /*final JTableHeader heading = dataTable.getTableHeader();
    heading.addMouseListener(new MouseAdapter(){  
        public void mouseClicked(MouseEvent e) {  
           selectedHeaderColumnIndex = heading.columnAtPoint(e.getPoint());  
           System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex);
        }  
     });  */
    dataTable.setGridColor(Color.gray);
    dataTable.setShowGrid(true);
    dataTable.doLayout();
    dataTable.setCellSelectionEnabled(true);
    dataTable.setColumnSelectionAllowed(true);
    dataTable.setRowSelectionAllowed(true);

    columnModel = dataTable.getColumnModel();
    dTableHeader = new EditableHeader(columnModel);
    dataTable.setTableHeader(dTableHeader);

    listIndex = new int[dataTable.getColumnCount()];
    for (int j = 0; j < listIndex.length; j++)
        listIndex[j] = 1;

    hookTableAction();

    headerTable = new JTable(hModel);
    headerTable.setCellSelectionEnabled(false);
    LookAndFeel.installColorsAndFont(headerTable, "TableHeader.background", "TableHeader.foreground",
            "TableHeader.font");
    headerTable.setIntercellSpacing(new Dimension(0, 0));
    Dimension d = headerTable.getPreferredScrollableViewportSize();
    d.width = headerTable.getPreferredSize().width;
    headerTable.setPreferredScrollableViewportSize(d);
    headerTable.setRowHeight(dataTable.getRowHeight());
    headerTable.setDefaultRenderer(Object.class, new RowHeaderRenderer());
    JTableHeader corner = headerTable.getTableHeader();
    corner.setReorderingAllowed(false);
    corner.setResizingAllowed(false);

    //      summaryPanel.setPreferredSize(new Dimension(CHART_SIZE_X,CHART_SIZE_Y/2));
    summaryPanel.removeAll();

    dataPanel.removeAll();
    JScrollPane tablePanel = new JScrollPane(dataTable);
    tablePanel.setRowHeaderView(headerTable);
    tablePanel.setCorner(JScrollPane.UPPER_LEFT_CORNER, corner);
    new JScrollPaneAdjuster(tablePanel);
    new JTableRowHeaderResizer(tablePanel).setEnabled(true);
    dataPanel.add(tablePanel);

    JScrollPane st = new JScrollPane(summaryPanel);
    st.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 3));
    dataPanel.add(new JScrollPane(st));
    dataPanel.validate();

}

From source file:edu.ucla.stat.SOCR.chart.Chart.java

/**
 * setup GUI layout for the data panel including datatable and summary textArea
 *
 *//*w  w w  .j  a v  a2 s. c  o m*/
protected void initTable() {

    tModel = new DefaultTableModel(dataObject, columnNames);
    hModel = new DefaultTableModel(0, 1);

    dataTable = new JTable(tModel);
    /*   System.out.println("here");
       dataTable.getTableHeader().addMouseListener(new MouseAdapter(){  
           public void mouseClicked(MouseEvent e) {  
     TableColumnModel colModel = dataTable.getColumnModel();
       int columnModelIndex = colModel.getColumnIndexAtX(e.getX());
       selectedHeaderColumnIndex = colModel.getColumn(columnModelIndex)
           .getModelIndex();
               
        System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex);
     }  
       });*/

    /*final JTableHeader heading = dataTable.getTableHeader();
    dataTable.addMouseListener(new MouseAdapter(){  
        public void mouseClicked(MouseEvent e) {  
           selectedHeaderColumnIndex = heading.columnAtPoint(e.getPoint());  
           System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex);
        }  
     });  */
    dataTable.addKeyListener(this);
    dataTable.setGridColor(Color.gray);
    dataTable.setShowGrid(true);

    for (int i = 0; i < tModel.getRowCount(); i++)
        hModel.addRow(new Object[] { (i + 1) + ":" });

    headerTable = new JTable(hModel);

    headerTable.setCellSelectionEnabled(false);
    headerTable.setEnabled(false);
    headerTable.setGridColor(Color.gray);
    headerTable.setShowGrid(true);
    LookAndFeel.installColorsAndFont(headerTable, "TableHeader.background", "TableHeader.foreground",
            "TableHeader.font");
    headerTable.setIntercellSpacing(new Dimension(0, 0));
    Dimension d = headerTable.getPreferredScrollableViewportSize();
    d.width = headerTable.getPreferredSize().width;
    headerTable.setPreferredScrollableViewportSize(d);
    headerTable.setRowHeight(dataTable.getRowHeight());
    headerTable.setDefaultRenderer(Object.class, new RowHeaderRenderer());

    JTableHeader corner = headerTable.getTableHeader();
    corner.setReorderingAllowed(false);
    corner.setResizingAllowed(false);

    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        dataTable.setDragEnabled(true);
    } catch (Exception e) {
    }
    columnModel = dataTable.getColumnModel();
    dTableHeader = new EditableHeader(columnModel);
    dataTable.setTableHeader(dTableHeader);
    dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    dataTable.setCellSelectionEnabled(true);
    dataTable.setColumnSelectionAllowed(true);
    dataTable.setRowSelectionAllowed(true);

    hookTableAction();

    dataPanel = new JPanel();

    summaryPanel = new JTextArea();
    //      summaryPanel.setPreferredSize(new Dimension(CHART_SIZE_X,CHART_SIZE_Y/2));
    Color bg = dataPanel.getBackground();
    summaryPanel.setBackground(bg);
    summaryPanel.setEditable(false);
    summaryPanel.setForeground(Color.BLACK);

    dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.Y_AXIS));
    JScrollPane tablePanel = new JScrollPane(dataTable);

    tablePanel.setRowHeaderView(headerTable);
    tablePanel.setCorner(JScrollPane.UPPER_LEFT_CORNER, corner);
    new JScrollPaneAdjuster(tablePanel);

    new JTableRowHeaderResizer(tablePanel).setEnabled(true);

    dataPanel.add(tablePanel);
    JScrollPane st = new JScrollPane(summaryPanel);
    st.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 3));
    dataPanel.add(new JScrollPane(st));

    dataPanel.validate();
}