本文整理匯總了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);
}
}