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


Java JTableHeader.addMouseListener方法代码示例

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


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

示例1: addMouseListenerToHeaderInTable

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
public void addMouseListenerToHeaderInTable(JTable table) { 
    final TableSorter sorter = this; 
    final JTable tableView = table; 
    tableView.setColumnSelectionAllowed(false); 
    MouseAdapter listMouseListener = new MouseAdapter() {
        boolean ascending = false;
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
            int column = tableView.convertColumnIndexToModel(viewColumn); 
            if (e.getClickCount() == 1 && column != -1) {
                //System.out.println("Sorting ..."); 
                //int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK; 
                //boolean ascending = (shiftPressed == 0);
                if (column == sortBy)                    
                    ascending = !ascending;
                else
                    ascending = true; 
                sorter.sortByColumn(column, ascending);   
                tableView.getTableHeader().updateUI();                  
            }
        }
    };
    JTableHeader th = tableView.getTableHeader(); 
    th.addMouseListener(listMouseListener); 
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:27,代码来源:TableSorter.java

示例2: addMouseListenerToHeaderInTable

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
public void addMouseListenerToHeaderInTable(JTable table) { 
    final TableSorter sorter = this; 
    final JTable tableView = table; 
    tableView.setColumnSelectionAllowed(false); 
    MouseAdapter listMouseListener = new MouseAdapter() {
        boolean ascending = false;
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
            int column = tableView.convertColumnIndexToModel(viewColumn); 
            if (e.getClickCount() == 1 && column != -1) {
                //Util.debug("Sorting ...");
                //int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK; 
                //boolean ascending = (shiftPressed == 0);
                if (column == sortBy)                    
                    ascending = !ascending;
                else
                    ascending = true; 
                sorter.sortByColumn(column, ascending);   
                tableView.getTableHeader().updateUI();                  
            }
        }
    };
    JTableHeader th = tableView.getTableHeader(); 
    th.addMouseListener(listMouseListener); 
}
 
开发者ID:ser316asu,项目名称:SER316-Dresden,代码行数:27,代码来源:TableSorter.java

示例3: addMouseListenerToHeaderInTable

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
public void addMouseListenerToHeaderInTable(JTable table) {
    final TableSorter sorter = this;
    final JTable tableView = table;
    tableView.setColumnSelectionAllowed(false);
    MouseAdapter listMouseListener = new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX());
            int column = tableView.convertColumnIndexToModel(viewColumn);
            if (e.getClickCount() == 1 && column != -1) {
                System.out.println("Sorting ...");
                int shiftPressed = e.getModifiers() & InputEvent.SHIFT_MASK;
                boolean ascending = (shiftPressed == 0);
                sorter.sortByColumn(column, ascending);
            }
        }
    };
    JTableHeader th = tableView.getTableHeader();
    th.addMouseListener(listMouseListener);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:TableSorter.java

示例4: tableHeaderDuplicates

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
public void tableHeaderDuplicates() throws Throwable {
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override public void run() {
            tableHeader = (JTableHeader) ComponentUtils.findComponent(JTableHeader.class, frame);
            JTable table = (JTable) ComponentUtils.findComponent(JTable.class, frame);
            table.getColumnModel().getColumn(1).setHeaderValue("Movie Title");
            int columnIndex = 2; // Award Category
            Rectangle rect = tableHeader.getHeaderRect(columnIndex);
            p = new Point(rect.x + rect.width / 2, rect.y + rect.height / 2);
        }
    });

    tableHeader.addMouseListener(new MouseAdapter() {
        @Override public void mousePressed(MouseEvent e) {
            RTableHeader rtableHeader = new RTableHeader(tableHeader, null, e.getPoint(), lr);
            rtableHeader.mouseButton1Pressed(e);
        }
    });

    IDevice device = Device.getDevice();
    device.click(tableHeader, Buttons.LEFT, 1, p.x, p.y);

    new Wait("Waiting for logging recorder callback") {
        @Override public boolean until() {
            return lr.getCalls().size() > 0;
        }
    };

    Call call = lr.getCall();
    AssertJUnit.assertEquals("click", call.getFunction());
    AssertJUnit.assertEquals("Movie Title(1)", call.getCellinfo());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:34,代码来源:RTableHeaderTest.java

示例5: addMouseListenerToHeaderInTable

import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
public void addMouseListenerToHeaderInTable(JTable table) {
    tableView = table;
    columnModel = tableView.getColumnModel();
    JTableHeader th = tableView.getTableHeader();
    th.addMouseListener(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:TableSorter.java


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