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


Java JXTable.setDefaultEditor方法代碼示例

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


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

示例1: interactiveEscapeNonStrict

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Issue #1293-swingx: NumberEditorExt removes Escape binding for all formatted text fields.
 * 
 * Here we assure that the fix for the issue doesn't effect the table edit - must
 * pass-through to allow correct cancel processing (non-strict number editor).
 */
public void interactiveEscapeNonStrict() {
    JXTable table = new JXTable(this.table.getModel());
    table.setDefaultEditor(Number.class, new NumberEditorExt(false));
    JXFrame frame = wrapWithScrollingInFrame(table, "non-strict: escape must cancel edit");
    addStatusMessage(frame, "edit number column, press escape, verify editingCanceled");
    final CellEditorReport report = new CellEditorReport();
    table.getDefaultEditor(Number.class).addCellEditorListener(report);
    Action verify = new AbstractAction("verify cancelled") {
        
        @Override
        public void actionPerformed(ActionEvent e) {
            int cancelledCount = report.getCanceledEventCount();
            report.clear();
            LOG.info("cancelled event count must be > 0, was: " + cancelledCount);
        }
    };
    addAction(frame, verify);
    show(frame);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:26,代碼來源:NumberEditorExtTest.java

示例2: interactiveNonStrictNumberEditorAllTypes

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
     * Issue ??-swingx: localized NumberEditor not using strict.
     * 
     * Column class is concrete type.
     * 
     */
    public void interactiveNonStrictNumberEditorAllTypes() {
        final Class<?>[] classes = new Class[] {Byte.class, Short.class, Integer.class,
                Float.class, Double.class, BigInteger.class, BigDecimal.class, Number.class};
        DefaultTableModel model = new DefaultTableModel(new String[] {
                "Byte", "Short", "Integer", "Float", "Double", "BigInteger", 
                "BigDecimal", "Number"}, 10) {
            
            @Override
            public Class<?> getColumnClass(int columnIndex) {
                return classes[columnIndex];
            }
            
        };
        model.setValueAt(Byte.MAX_VALUE, 0, 0);
        model.setValueAt(Short.MAX_VALUE, 0, 1);
        model.setValueAt(Integer.MAX_VALUE, 0, 2);
        model.setValueAt(Float.MAX_VALUE, 0, 3);
        model.setValueAt(Double.MAX_VALUE, 0, 4);
        model.setValueAt(new BigInteger(TOO_BIG_INTEGER), 0, 5);
        model.setValueAt(new BigDecimal("44444444444444.666666666666666666"), 0, 6);
        // negative/min
        model.setValueAt(Byte.MIN_VALUE, 1, 0);
        model.setValueAt(Short.MIN_VALUE, 1, 1);
        model.setValueAt(Integer.MIN_VALUE, 1, 2);
        model.setValueAt(-Float.MAX_VALUE, 1, 3);
        model.setValueAt(-Double.MAX_VALUE, 1, 4);
//        model.setValueAt(new BigInteger(TOO_BIG_INTEGER), 1, 5);
        model.setValueAt(new BigDecimal("-44444444444444.666666666666666666"), 1, 6);
        
        final JXTable table = new JXTable(model);
        table.setSurrendersFocusOnKeystroke(true);
        NumberEditorExt strictEditor = new NumberEditorExt(false);
        table.setDefaultEditor(Number.class, strictEditor);
        JXFrame frame = showWithScrollingInFrame(table, "Extended NumberEditors(non-strict): concrete Number classes");
        addStatusMessage(frame, "concrete number classes and non-strict formatter: error not shown, fails on commit");
    }
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:43,代碼來源:NumberEditorExtTest.java

示例3: interactiveMixedColumnEditors

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
     * Issue #1236-swingx: NumberEditorExt only handles columns with type
     *    Number.
     *    
     * Perceived as overly restrictive, fails f.i. in usage in property sheet.   
     * 
     */
//    @Test
    public void interactiveMixedColumnEditors() {
        // mixed types in column
        Object[] values = new Object[] {new Integer(10), new Double(10.5), new Date(),
                new JLabel("dummy"),
                new Point(4, 6)};
        DefaultTableModel model = new DefaultTableModel(10, 2) {

            @Override
            public Class<?> getColumnClass(int columnIndex) {
                if (columnIndex == getColumnCount() - 1) {
                    return Point.class;
                }
                return super.getColumnClass(columnIndex);
            }
            
        };
        for (int i = 0; i < values.length; i++) {
            model.setValueAt(values[i], i, 0);
            model.setValueAt(new Point(1, i), i, 1);
        }
        
        JXTable table = new JXTable(model) {

            @Override
            public TableCellEditor getCellEditor(int row, int column) {
                Object value = getValueAt(row, column);
                if (value instanceof Number) {
                    return getDefaultEditor(Number.class);
                }
                if (value instanceof Date) {
                    return getDefaultEditor(Date.class);
                }
                if (value instanceof JLabel) {
                    // pathological: something with a string param constructor
                    return getDefaultEditor(Number.class);
                }
                return super.getCellEditor(row, column);
            }
            
        };
        table.setDefaultEditor(Date.class, new DatePickerCellEditor());
//        table.setDefaultEditor(Number.class, new NumberEditorExt(false));
        JXFrame frame = showWithScrollingInFrame(table, "per-cell number editor? ");
        JFormattedTextField field = new JFormattedTextField(new Date());
        addStatusComponent(frame, field);
    }
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:55,代碼來源:NumberEditorExtIssues.java


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