當前位置: 首頁>>代碼示例>>Java>>正文


Java TableColumn.setHeaderValue方法代碼示例

本文整理匯總了Java中javax.swing.table.TableColumn.setHeaderValue方法的典型用法代碼示例。如果您正苦於以下問題:Java TableColumn.setHeaderValue方法的具體用法?Java TableColumn.setHeaderValue怎麽用?Java TableColumn.setHeaderValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.table.TableColumn的用法示例。


在下文中一共展示了TableColumn.setHeaderValue方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: tableChanged

import javax.swing.table.TableColumn; //導入方法依賴的package包/類
@Override
public void tableChanged(TableModelEvent e) {
    // update tree column name
    int modelColumn = getTreeColumnIndex();

    if ((e.getFirstRow() <= 0) && (modelColumn != -1) && (getColumnCount() > 0)) {
        String columnName = getModel().getColumnName(modelColumn);
        TableColumn aColumn = getColumnModel().getColumn(modelColumn);
        aColumn.setHeaderValue(columnName);
    }

    ignoreClearSelection = true;

    try {
        super.tableChanged(e);
        //#61728 - force update of tree's horizontal scrollbar
        if( null != getTree() ) {
            firePropertyChange( "positionX", -1, getPositionX() );
        }
    } finally {
        ignoreClearSelection = false;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:TreeTable.java

示例2: fireTableColumnChanged

import javax.swing.table.TableColumn; //導入方法依賴的package包/類
/** Fires a TableModelEvent - change of one column */
public void fireTableColumnChanged(int index) {
    int columnModelIndex = index;
    
    // reset the header value as well
    Object list[] = listenerList.getListenerList();
    for (int i = 0; i < list.length; i++) {
        if (list[i] instanceof JTable) {
            JTable jt = (JTable)list[i];
            try {
                TableColumn column = jt.getColumnModel().getColumn(index);
                columnModelIndex = column.getModelIndex();
                column.setHeaderValue(jt.getModel().getColumnName(columnModelIndex));
            } catch (ArrayIndexOutOfBoundsException abe) {
                // only catch exception
            }
            jt.getTableHeader().repaint();
        }
    }
    fireTableChanged(new TableModelEvent(this, 0, getRowCount() - 1, columnModelIndex));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:PropertiesTableModel.java

示例3: RowHeader

import javax.swing.table.TableColumn; //導入方法依賴的package包/類
/**
 * Constructor.
 */
public RowHeader() {
    Table.this.addPropertyChangeListener(this);
    
    // row header should not allow to sort.
    setSortable(false);
    
    setFocusable(false);
    setAutoCreateColumnsFromModel(false);
    setModel(Table.this.getModel());
    setSelectionModel(Table.this.getSelectionModel());

    TableColumn column = new TableColumn();
    column.setHeaderValue(" ");
    addColumn(column);
    column.setCellRenderer(new RowNumberRenderer());

    getColumnModel().getColumn(0).setPreferredWidth(50);
    setPreferredScrollableViewportSize(getPreferredSize());
}
 
開發者ID:takun2s,項目名稱:smile_1.5.0_java7,代碼行數:23,代碼來源:Table.java

示例4: mouseClicked

import javax.swing.table.TableColumn; //導入方法依賴的package包/類
@Override
public void mouseClicked(MouseEvent e) {
    JTableHeader header = (JTableHeader) e.getSource();
    JTable table = header.getTable();
    TableColumnModel columnModel = table.getColumnModel();
    int vci = columnModel.getColumnIndexAtX(e.getX());
    int mci = table.convertColumnIndexToModel(vci);
    if (mci == targetColumnIndex) {
        if (SwingUtilities.isLeftMouseButton(e)) {
            TableColumn column = columnModel.getColumn(vci);
            Object v = column.getHeaderValue();
            boolean b = Status.DESELECTED.equals(v);
            TableModel m = table.getModel();
            for (int i = 0; i < m.getRowCount(); i++) {
                m.setValueAt(b, i, mci);
            }
            column.setHeaderValue(b ? Status.SELECTED : Status.DESELECTED);
        } else if (SwingUtilities.isRightMouseButton(e)) {
            if (popupMenu != null) {
                popupMenu.show(table, e.getX(), 0);
            }
        }
    }
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:25,代碼來源:TableCheckBoxColumn.java

示例5: setupInstance

import javax.swing.table.TableColumn; //導入方法依賴的package包/類
protected void setupInstance(TableColumn instance) {
    super.setupInstance(instance);
    
    instance.setHeaderValue(headerValue);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,代碼來源:DataViewBuilders.java

示例6: populateTableHeaders

import javax.swing.table.TableColumn; //導入方法依賴的package包/類
public void populateTableHeaders() {

        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        final Calendar c = Calendar.getInstance();
        c.setTime(masterDate.getTime());

        JTableHeader tableHeader = table.getTableHeader();
        TableColumnModel tableColumnModel = tableHeader.getColumnModel();
        TableColumn tableColumn;

        tableColumn = tableColumnModel.getColumn(0);
        tableColumn.setHeaderValue("ROOM");
        tableColumn = tableColumnModel.getColumn(1);
        tableColumn.setHeaderValue("TYPE");
        tableColumn = tableColumnModel.getColumn(2);
        tableColumn.setHeaderValue("STATUS");

        //start the date from minus 1 to get today date.
        c.add(Calendar.DATE, -1);

        //start the loop from 3 because first 3 columns already 
        //populated up and the loop on 10 to get one week 
        for (int i = 3; i < 10; i++) {
            c.add(Calendar.DATE, 1);
            today = simpleDateFormat.format(c.getTime());
            tableColumn = tableColumnModel.getColumn(i);
            tableColumn.setHeaderValue(today);

            //store dates in special array to use it in bottom
            weekDates[i] = today;
        }

        tableHeader.revalidate();
        tableHeader.repaint();

    }
 
開發者ID:Coder-ACJHP,項目名稱:Hotel-Properties-Management-System,代碼行數:37,代碼來源:Main_Blockade.java

示例7: tableChanged

import javax.swing.table.TableColumn; //導入方法依賴的package包/類
@Override
public void tableChanged(TableModelEvent e) {
    if (e.getType() == TableModelEvent.UPDATE && e.getColumn() == 0) {
        int mci = 0;
        int vci = table.convertColumnIndexToView(mci);
        TableColumn column = table.getColumnModel().getColumn(vci);
        Object title = column.getHeaderValue();
        if (!Status.INDETERMINATE.equals(title)) {
            column.setHeaderValue(Status.INDETERMINATE);
        } else {
            int selected = 0, deselected = 0;
            TableModel m = table.getModel();
            for (int i = 0; i < m.getRowCount(); i++) {
                if (Boolean.TRUE.equals(m.getValueAt(i, mci))) {
                    selected++;
                } else {
                    deselected++;
                }
            }
            if (selected == 0) {
                column.setHeaderValue(Status.DESELECTED);
            } else if (deselected == 0) {
                column.setHeaderValue(Status.SELECTED);
            } else {
                return;
            }
        }
        table.getTableHeader().repaint();
    }
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:31,代碼來源:TableCheckBoxColumn.java

示例8: InternalTableColumnModel

import javax.swing.table.TableColumn; //導入方法依賴的package包/類
public InternalTableColumnModel() {
    TableColumn col = new TableColumn(0, 75);
    col.setHeaderValue("#");
    addColumn(col);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,代碼來源:JXTableRowHeader.java

示例9: addColumn

import javax.swing.table.TableColumn; //導入方法依賴的package包/類
private void addColumn(int i, String name) {
    final TableColumn column = new TableColumn(i);
    column.setHeaderValue(name);
    addColumn(column);
}
 
開發者ID:imgruntw,項目名稱:date-time-converter-plugin,代碼行數:6,代碼來源:DateTimeColumnModel.java


注:本文中的javax.swing.table.TableColumn.setHeaderValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。