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


Java JXTable.setValueAt方法代碼示例

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


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

示例1: testPackWithPrepareRenderer

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Issue #1215-swingx: ColumnFactory must pack with prepareRenderer.
 * Otherwise, doesn't catch sizing effective highlighters, like f.i. font.
 */
@Test
public void testPackWithPrepareRenderer() {
    JXTable table = new JXTable(1, 1);
    table.setValueAt("just a long string something utterly meaningless", 0, 0);
    table.packColumn(0, 0);
    assertEquals("sanity: no highlighter", table.prepareRenderer(
            table.getCellRenderer(0, 0), 0, 0).getPreferredSize().width,
            table.getColumn(0).getPreferredWidth());
    Highlighter hl = new BorderHighlighter(BorderFactory.createEmptyBorder(0, 50, 0, 50));
    table.addHighlighter(hl);
    table.packColumn(0, 0);
    assertEquals("highlighter which adds 100 px width", table.prepareRenderer(
            table.getCellRenderer(0, 0), 0, 0).getPreferredSize().width,
            table.getColumn(0).getPreferredWidth());
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:20,代碼來源:ColumnFactoryTest.java

示例2: interactiveNumberEditor

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Issue #393-swingx: localized NumberEditor.
 * 
 * Column type is Number, editors as noted in header text 
 * 
 * 
 */
public void interactiveNumberEditor() {
    final int doubleColumns = 3;
    final int integerColumns = 6;
    DefaultTableModel model = new DefaultTableModel(new String[] {
            "Double-core", "Double-extstrict", "Double-extnonstrict", 
            "Integer-core", "Integer-extstrict", "Integer-extnonstrict",
    "Object" }, 10) {
        
        @Override
        public Class<?> getColumnClass(int columnIndex) {
            return Number.class;
        }
        
    };
    final JXTable table = new JXTable(model);
    table.setSurrendersFocusOnKeystroke(true);
    for (int i = 0; i < table.getColumnCount(); i++) {
        if (i < doubleColumns) {
            table.setValueAt(Double.MAX_VALUE-1, 0, i);
        } else {
            table.setValueAt(Integer.MAX_VALUE-1, 0, i);
        }
        
    }
    NumberEditor numberEditor = new NumberEditor();
    table.getColumn(0).setCellEditor(numberEditor);
    table.getColumn(doubleColumns).setCellEditor(numberEditor);
    NumberEditorExt nonStrictEditor = new NumberEditorExt(false);
    table.getColumn(doubleColumns -1).setCellEditor(nonStrictEditor);
    table.getColumn(integerColumns -1).setCellEditor(nonStrictEditor);
    JXFrame frame = showWithScrollingInFrame(table, "Extended NumberEditors: Number.class");
    addStatusMessage(frame, "number-class: has no constructor with string, core/nonstrict can't handle");
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:41,代碼來源:NumberEditorExtTest.java

示例3: interactiveFloatingPointEditor

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Issue #393-swingx: localized NumberEditor.
 * 
 * Column type is Number, editors as noted in header text 
 * 
 * 
 */
public void interactiveFloatingPointEditor() {
    final int doubleColumns = 3;
    final int integerColumns = 6;
    DefaultTableModel model = new DefaultTableModel(new String[] {
            "Double-core", "Double-extstrict", "Double-extnonstrict", 
            "Integer-core", "Integer-extstrict", "Integer-extnonstrict",
            "Object" }, 10) {

        @Override
        public Class<?> getColumnClass(int columnIndex) {
            if (columnIndex < doubleColumns) {
                return Double.class;
            }
            if (columnIndex < integerColumns) {
                return Integer.class;

            }
            return Object.class;
        }

    };
    final JXTable table = new JXTable(model);
    table.setSurrendersFocusOnKeystroke(true);
    for (int i = 0; i < table.getColumnCount(); i++) {
        if (i < doubleColumns) {
            table.setValueAt(Double.MAX_VALUE, 0, i);
        } else {
            table.setValueAt(Integer.MAX_VALUE, 0, i);
        }

    }
    NumberEditor numberEditor = new NumberEditor();
    table.getColumn(0).setCellEditor(numberEditor);
    table.getColumn(doubleColumns).setCellEditor(numberEditor);
    NumberEditorExt nonStrictEditor = new NumberEditorExt(false);
    table.getColumn(doubleColumns -1).setCellEditor(nonStrictEditor);
    table.getColumn(integerColumns -1).setCellEditor(nonStrictEditor);
    showWithScrollingInFrame(table, "Extended NumberEditors: concrete classes Double/Integer");
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:47,代碼來源:NumberEditorExtTest.java

示例4: testPackMargin

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Issue #266-swingx: support customization of pack margin.
 * 
 * added property to ColumnFactory. 
 *  
 */
@Test
public void testPackMargin() {
    final int special = 1;
    JXTable table = new JXTable(1, 2);
    ColumnFactory factory = new ColumnFactory();
    table.setColumnFactory(factory);
    table.setValueAt("something that's wider than 75", 0, special);
    TableColumnExt columnExt = table.getColumnExt(special);
    table.packAll();
    TableCellRenderer renderer = table.getCellRenderer(0, special);
    Component comp = table.prepareRenderer(renderer, 0, special);
    int realPrefWidth = 2 * factory.getDefaultPackMargin() // magic value - JXTable's default margin, 
                              //  needs to be made configurable, see Issue 266 
        + comp.getPreferredSize().width;
    // sanity - default margin kicks in
    assertEquals(realPrefWidth, columnExt.getPreferredWidth());
    
    int margin = 10;
    factory.setDefaultPackMargin(margin);
    table.packAll();
    table.prepareRenderer(renderer, 0, special);
    int otherPrefWidth = 2 * margin + comp.getPreferredSize().width;
    assertEquals(otherPrefWidth, columnExt.getPreferredWidth());
    
    
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:33,代碼來源:ColumnFactoryTest.java


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