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


Java DefaultTreeCellEditor類代碼示例

本文整理匯總了Java中javax.swing.tree.DefaultTreeCellEditor的典型用法代碼示例。如果您正苦於以下問題:Java DefaultTreeCellEditor類的具體用法?Java DefaultTreeCellEditor怎麽用?Java DefaultTreeCellEditor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: testStartEditing

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
public void testStartEditing() {
    assertFalse(ui.isEditing(tree));
    ui.startEditing(new TreePath(root), null);
    assertFalse(ui.isEditing(tree));
    tree.setEditable(true);
    assertFalse(ui.isEditing(tree));
    ui.startEditing(new TreePath(root), null);
    assertTrue(ui.isEditing(tree));
    ui.cancelEditing(tree);
    assertFalse(ui.isEditing(tree));
    tree.setCellEditor(new DefaultTreeCellEditor(tree, (DefaultTreeCellRenderer) tree
            .getCellRenderer()) {
        @Override
        public boolean shouldSelectCell(final EventObject event) {
            return false;
        }
    });
    ui.startEditing(new TreePath(root), null);
    assertTrue(ui.isEditing(tree));
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:21,代碼來源:BasicTreeUITest.java

示例2: createDefaultCellEditor

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:SynthTreeUI.java

示例3: testEditorListenerRemovedOnEditorStopped

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
 * focus issues with popup in editors: tweak with 
 * custom cellEditorListener.
 *
 */
@Test
public void testEditorListenerRemovedOnEditorStopped() {
    JXTree tree = createEditingTree();
    DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
    // core doesn't remove the listener ... dooh
    cellEditor.stopCellEditing();
    // but we do ... 
    assertEquals(1, cellEditor.getCellEditorListeners().length);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:15,代碼來源:JXTreeUnitTest.java

示例4: testEditorListenerRemovedOnEditorCancel

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
 * focus issues with popup in editors: tweak with 
 * custom cellEditorListener.
 *
 */
@Test
public void testEditorListenerRemovedOnEditorCancel() {
    JXTree tree = createEditingTree();
    DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
    // core doesn't remove the listener ... dooh
    cellEditor.cancelCellEditing();
    // but we do ... 
    assertEquals(1, cellEditor.getCellEditorListeners().length);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:15,代碼來源:JXTreeUnitTest.java

示例5: testEditorListenerRemovedOnTreeCancel

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
 * focus issues with popup in editors: tweak with 
 * custom cellEditorListener.
 *
 */
@Test
public void testEditorListenerRemovedOnTreeCancel() {
    JXTree tree = createEditingTree();
    DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
    // core doesn't remove the listener ... dooh
    tree.cancelEditing();
    // but we do ... 
    assertEquals(1, cellEditor.getCellEditorListeners().length);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:15,代碼來源:JXTreeUnitTest.java

示例6: testEditorListenerRemovedOnTreeStop

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
 * focus issues with popup in editors: tweak with 
 * custom cellEditorListener.
 *
 */
@Test
public void testEditorListenerRemovedOnTreeStop() {
    JXTree tree = createEditingTree();
    DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
    // core doesn't remove the listener ... dooh
    tree.stopEditing();
    // but we do ... 
    assertEquals(1, cellEditor.getCellEditorListeners().length);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:15,代碼來源:JXTreeUnitTest.java

示例7: testEditorListenerOnXTree

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
 * focus issues with popup in editors: tweak with 
 * custom cellEditorListener.
 *
 */
@Test
public void testEditorListenerOnXTree() {
    JTree core = new JTree();
    int coreCount = getListenerCountAfterStartEditing(core);
    JXTree tree = createEditingTree();
    DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
    assertEquals("need one more listener than core", 
            coreCount + 1, cellEditor.getCellEditorListeners().length);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:15,代碼來源:JXTreeUnitTest.java

示例8: testEditorListenerOnCoreTree

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
 * characterization: listeners in core tree.
 *
 */
@Test
public void testEditorListenerOnCoreTree() {
    JTree tree = new JTree();
    int listenerCount = getListenerCountAfterStartEditing(tree);
    assertEquals(1, listenerCount);
    tree.stopEditing();
    // doesn't remove the listener ... dooh
    assertEquals(1, ((DefaultTreeCellEditor) tree.getCellEditor()).getCellEditorListeners().length);
    
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:15,代碼來源:JXTreeUnitTest.java

示例9: getListenerCountAfterStartEditing

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
 * Starts editing on row 2 and returns the cell editor listener count after.
 * 
 * @param tree
 * @return
 */
private int getListenerCountAfterStartEditing(JTree tree) {
    tree.setEditable(true);
    // sanity
    assertTrue(tree.getRowCount() > 2);
    TreePath path = tree.getPathForRow(2);
    tree.startEditingAtPath(path);
    DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
    int listenerCount = cellEditor.getCellEditorListeners().length;
    return listenerCount;
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:17,代碼來源:JXTreeUnitTest.java

示例10: interactiveToggleEditProperties

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
 * visually check if invokesStopCellEditing jumps in on focusLost.
 *
 */
public void interactiveToggleEditProperties() {
    final JXTree table = new JXTree();
    table.setEditable(true);
    DefaultTreeCellEditor editor = new DefaultTreeCellEditor(null, null) {

        @Override
        public boolean stopCellEditing() {
            String value = String.valueOf(getCellEditorValue());
            if (value.startsWith("s")) {
                return false;
            }
            return super.stopCellEditing();
        }
        
    };
    table.setCellEditor(editor);
    JXFrame frame = wrapWithScrollingInFrame(table, new JButton("something to focus"), 
            "JXTree: toggle invokesStopEditing ");
    Action toggleTerminate = new AbstractAction("toggleInvokesStop") {

        public void actionPerformed(ActionEvent e) {
            table.setInvokesStopCellEditing(!table.getInvokesStopCellEditing());
            
        }
        
    };
    addAction(frame, toggleTerminate);
    frame.setVisible(true);
    
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:35,代碼來源:JXTreeVisualCheck.java

示例11: interactiveTreeEditingRToLDatePicker

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
 * visualize datepicker editing of the hierarchical column, both
 * in a tree and a xTree switching CO.
 *
 * standard editor
 */
public void interactiveTreeEditingRToLDatePicker() {
    TreeModel model = createTreeModelWithDates();
    JTree tree =  new JTree(model); 
    tree.setEditable(true);
    tree.setCellEditor(new DefaultTreeCellEditor(tree, null, new DatePickerCellEditor()));
    JXTree xTree = new JXTree(model);
    xTree.setEditable(true);
    xTree.setCellEditor(new DefaultTreeCellEditor(tree, null, new DatePickerCellEditor()));
    final JXFrame frame = wrapWithScrollingInFrame(tree, xTree, "standard Editing (DatePicker): compare tree and xtree");
    addComponentOrientationToggle(frame);
    show(frame);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:19,代碼來源:DatePickerCellEditorVisualCheck.java

示例12: ProjectTree

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
    * Constructor
    */
   public ProjectTree() {

ProjectTreeRenderer renderer = new ProjectTreeRenderer();
setCellRenderer(renderer);

DefaultTreeCellEditor editor = new DefaultTreeCellEditor(this,
	renderer, new ProjectTreeEditor(this));
setCellEditor(editor);
setEditable(true);
setInvokesStopCellEditing(true);

setRootVisible(true);
setShowsRootHandles(false);

setToggleClickCount(-1);

// Activate drag&drop
ProjectTreeDnDHandler dndHandler = new ProjectTreeDnDHandler();
setTransferHandler(dndHandler);
setDropMode(DropMode.INSERT);
setDragEnabled(true);

// Attach a handler for handling popup menus and double clicks
ProjectTreeMouseHandler popupHandler = new ProjectTreeMouseHandler(this);
addMouseListener(popupHandler);

   }
 
開發者ID:mzmine,項目名稱:mzmine2,代碼行數:31,代碼來源:ProjectTree.java

示例13: createDefaultCellEditor

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
 * @inheritDoc
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if (renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer) renderer);
    } else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
開發者ID:khuxtable,項目名稱:seaglass,代碼行數:16,代碼來源:SeaGlassTreeUI.java

示例14: createDefaultCellEditor

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
 * @inheritDoc
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
開發者ID:openjdk,項目名稱:jdk7-jdk,代碼行數:18,代碼來源:SynthTreeUI.java

示例15: createDefaultCellEditor

import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
protected TreeCellEditor createDefaultCellEditor() {
    DefaultTreeCellRenderer renderer = currentCellRenderer instanceof DefaultTreeCellRenderer
        ? (DefaultTreeCellRenderer)currentCellRenderer
        : null;

    return new DefaultTreeCellEditor(tree, renderer);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:8,代碼來源:BasicTreeUI.java


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