本文整理汇总了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);
}
}
示例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();
}
}
}
示例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);
}
}
示例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();
}
}
}
}
示例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();
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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 );
}
}
示例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;
}
示例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();
}
示例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);
}
}