当前位置: 首页>>代码示例>>Java>>正文


Java JTableHeader.getColumnModel方法代码示例

本文整理汇总了Java中javax.swing.table.JTableHeader.getColumnModel方法的典型用法代码示例。如果您正苦于以下问题:Java JTableHeader.getColumnModel方法的具体用法?Java JTableHeader.getColumnModel怎么用?Java JTableHeader.getColumnModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.table.JTableHeader的用法示例。


在下文中一共展示了JTableHeader.getColumnModel方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mouseClicked

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e) {

            JTableHeader     h           = (JTableHeader) e.getSource();
            TableColumnModel columnModel = h.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX());
            int column = columnModel.getColumn(viewColumn).getModelIndex();

            if (column != -1) {
                int status = getSortingStatus(column);

                if (!e.isControlDown()) {
                    cancelSorting();
                }

                // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
                // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
                status = status + (e.isShiftDown() ? -1
                                                   : 1);
                status = (status + 4) % 3 - 1;    // signed mod, returning {-1, 0, 1}

                setSortingStatus(column, status);
            }
        }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:24,代码来源:TableSorter.java

示例2: mouseClicked

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    JTableHeader h = (JTableHeader) e.getSource();
    TableColumnModel columnModel = h.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(e.getX());
    int column = columnModel.getColumn(viewColumn).getModelIndex();
    if (column != -1) {
        int status = getSortingStatus(column);
        if (!e.isControlDown()) {
            cancelSorting();
        }
        // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or 
        // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed. 
        status += e.isShiftDown() ? -1 : 1;
        status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
        setSortingStatus(column, status);
        if(issueTable != null) {
            issueTable.sortOrderChanged();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:TableSorter.java

示例3: mouseClicked

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e) {
    JTableHeader h = (JTableHeader) e.getSource();
    TableColumnModel columnModel = h.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(e.getX());
    int column = columnModel.getColumn(viewColumn).getModelIndex();
    if (column != -1) {
        int status = getSortingStatus(column);
        if (!e.isControlDown()) {
            cancelSorting();
        }
        // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or 
        // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed. 
        status = status + (e.isShiftDown() ? -1 : 1);
        status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
        setSortingStatus(column, status);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:TableSorter.java

示例4: mouseClicked

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
	if (!e.isPopupTrigger()) {
		JTableHeader h = (JTableHeader) e.getSource();
		TableColumnModel columnModel = h.getColumnModel();
		int viewColumn = columnModel.getColumnIndexAtX(e.getX());
		int column = columnModel.getColumn(viewColumn).getModelIndex();
		if (column != -1) {
			if (columnModel.getColumn(viewColumn).getHeaderValue().equals("File Name")) {
				FileTable.this.fileList.orderBy(FileList.ORDER_BY_FILE_NAME, false);
				FileTable.this.fileList.updateTableData();
			} else if (columnModel.getColumn(viewColumn).getHeaderValue().equals("Type")) {
				FileTable.this.fileList.orderBy(FileList.ORDER_BY_FILE_TYPE, false);
				FileTable.this.fileList.updateTableData();
			} else if (columnModel.getColumn(viewColumn).getHeaderValue().equals("Last Modified")) {
				FileTable.this.fileList.orderBy(FileList.ORDER_BY_FILE_MODIFIED, false);
				FileTable.this.fileList.updateTableData();
			} else if (columnModel.getColumn(viewColumn).getHeaderValue().equals("Size")) {
				FileTable.this.fileList.orderBy(FileList.ORDER_BY_FILE_SIZE, false);
				FileTable.this.fileList.updateTableData();
			}
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:25,代码来源:FileTable.java

示例5: mouseClicked

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
	JTableHeader h = (JTableHeader) e.getSource();
	TableColumnModel columnModel = h.getColumnModel();
	int viewColumn = getSortingColumnIndex(h, e.getPoint());
	if (viewColumn != -1) {
		int column = columnModel.getColumn(viewColumn).getModelIndex();
		if (column != -1) {
			int status = getSortingStatus(column);
			if (!SwingTools.isControlOrMetaDown(e)) {
				cancelSorting();
			}
			// Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
			// {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is
			// pressed.
			status = status + (e.isShiftDown() ? -1 : 1);
			status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
			setSortingStatus(column, status);
		}
		e.consume();
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:ExtendedJTableSorterModel.java

示例6: setSortingStatus

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
public void setSortingStatus(final int status, final boolean cancelSorting) {
	if (getModel() instanceof ExtendedJTableSorterModel) {
		ExtendedJTableSorterModel sorterModel = (ExtendedJTableSorterModel) getModel();

		JTableHeader h = getTableHeader();
		TableColumnModel columnModel = h.getColumnModel();
		int viewColumn = getSelectedColumn();
		if (viewColumn != -1) {
			int column = columnModel.getColumn(viewColumn).getModelIndex();
			if (column != -1) {
				if (sorterModel.isSorting()) {
					if (cancelSorting) {
						sorterModel.cancelSorting();
					}
				}
				sorterModel.setSortingStatus(column, status);
			}
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:21,代码来源:ExtendedJTable.java

示例7: mouseClicked

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e) {

            JTableHeader     h           = (JTableHeader) e.getSource();
            TableColumnModel columnModel = h.getColumnModel();
            int              viewColumn  = h.columnAtPoint(e.getPoint());
            int column = columnModel.getColumn(viewColumn).getModelIndex();

            if (column != -1) {
                int status = getSortingStatus(column);

                if (!e.isControlDown()) {
                    cancelSorting();
                }

                // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
                // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
                status = status + (e.isShiftDown() ? -1
                                                   : 1);
                status = (status + 4) % 3 - 1;    // signed mod, returning {-1, 0, 1}

                setSortingStatus(column, status);
            }
        }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:24,代码来源:TableSorter.java

示例8: mouseClicked

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e)
{
	JTableHeader h = (JTableHeader) e.getSource();
	TableColumnModel columnModel = h.getColumnModel();
	int viewColumn = columnModel.getColumnIndexAtX(e.getX());
	int column = columnModel.getColumn(viewColumn).getModelIndex();
	if( column != -1 )
	{
		int status = getSortingStatus(column);
		if( !e.isControlDown() )
		{
			cancelSorting();
		}
		// Cycle the sorting states through {NOT_SORTED, ASCENDING,
		// DESCENDING} or
		// {NOT_SORTED, DESCENDING, ASCENDING} depending on whether
		// shift is pressed.
		status = status + (e.isShiftDown() ? -1 : 1);
		status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0,
		// 1}
		setSortingStatus(column, status);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:TableSorter.java

示例9: mouseClicked

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
	JTableHeader h = (JTableHeader) e.getSource();
	TableColumnModel columnModel = h.getColumnModel();
	int viewColumn = columnModel.getColumnIndexAtX(e.getX());
	int column = columnModel.getColumn(viewColumn).getModelIndex();
	if (column != -1) {
		int status = getSortingStatus(column);
		if (!e.isControlDown()) {
			cancelSorting();
		}
		// Cycle the sorting states through {NOT_SORTED, ASCENDING,
		// DESCENDING} or
		// {NOT_SORTED, DESCENDING, ASCENDING} depending on whether
		// shift is pressed.
		status = status + (e.isShiftDown() ? -1 : 1);
		status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0,
										// 1}
		setSortingStatus(column, status);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:22,代码来源:TableSorter.java

示例10: mousePressed

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
@Override
public void mousePressed(MouseEvent e)
{
	JTableHeader header = (JTableHeader)e.getComponent();
	TableColumnModel tcm = header.getColumnModel();
	int columnIndex = tcm.getColumnIndexAtX( e.getX() );
	Cursor cursor = header.getCursor();

	if (columnIndex == tcm.getColumnCount() - 1
	&&  cursor == Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR))
	{
		column = tcm.getColumn( columnIndex );
		columnWidth = column.getWidth();
		pressedX = e.getX();
		header.addMouseMotionListener( this );
	}
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:18,代码来源:DriverTable.java

示例11: findmatch

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
private List<IJavaElement> findmatch(ArrayList<IJavaElement> r, PropertyPredicate p) {
    JTableHeader header = (JTableHeader) component;
    TableColumnModel columnModel = header.getColumnModel();
    int col = columnModel.getColumnCount();
    for (int i = 0; i < col; i++) {
        JTableHeaderItemJavaElement e = new JTableHeaderItemJavaElement(this, i);
        if (p.isValid(e)) {
            r.add(e);
        }
    }
    return r;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:13,代码来源:JTableHeaderJavaElement.java

示例12: populateTableHeaders

import javax.swing.table.JTableHeader; //导入方法依赖的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

示例13: mouseClicked

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    JTableHeader h = (JTableHeader) e.getSource();
    JTable table = h.getTable();
    int selectedRow = table.getSelectedRow();
    TableModel model = table.getModel();
    //remember selection to keep after sorting
    Object selectedAction=null;
    int objectColumn=-1;
    if(selectedRow>-1) {
        for(int i=0; i<table.getColumnCount(); i++) {
            //first find colum with appropriate object
            if(model.getValueAt(selectedRow, i) instanceof ActionHolder) {
                //remember this object
                selectedAction=model.getValueAt(selectedRow, i);
                objectColumn=i;
                //stop edition as we click somewhere ouside of editor
                TableCellEditor editor=table.getCellEditor();
                if(editor!=null) {
                    editor.stopCellEditing();
                }
                break;
            }
        }
    }
    TableColumnModel columnModel = h.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(e.getX());
    int column = columnModel.getColumn(viewColumn).getModelIndex();
    if (column != -1) {
        int status = getSortingStatus(column);
        if (!e.isControlDown()) {
            cancelSorting();
        }
        // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or 
        // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed. 
        status = status + (e.isShiftDown() ? -1 : 1);
        status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
        setSortingStatus(column, status);
        //reselect the same object
        if(selectedAction!=null)setSelectedRow(table, selectedAction, objectColumn);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:TableSorter.java


注:本文中的javax.swing.table.JTableHeader.getColumnModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。