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


Java DefaultTreeSelectionModel類代碼示例

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


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

示例1: buildTree

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
/**
 * 
 */
private void buildTree() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("user");
    tree = new JTree(root);
    tree.putClientProperty("JTree.lineStyle", "Angled");
    tree.setCellRenderer(new NavigationTreeCellRenderer());
    tree.setShowsRootHandles(true);
    
    DefaultTreeSelectionModel model = new DefaultTreeSelectionModel();
    model.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    
    graphsCategory = new DefaultMutableTreeNode("graphs");
    
    mouseAdapter = new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            itemSelected(e);
        }
    };
    tree.addMouseListener(mouseAdapter);
    
    root.add(graphsCategory);        
    loadGraphs();
}
 
開發者ID:guilhebl,項目名稱:routerapp,代碼行數:26,代碼來源:NavigationView.java

示例2: OntologyBrowser

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
public OntologyBrowser(OWLOntology ontology, Set<String> rootsToRemove) {
  super();
  this.ontology = ontology;
  this.rootConcept = "Thing";
  this.buildTreeModel();
  for (String concept : rootsToRemove) {
    DefaultMutableTreeNode node = getNodeFromName(concept);
    this.dtm.removeNodeFromParent(node);
  }

  this.setModel(this.dtm);
  // set the tree selection model
  DefaultTreeSelectionModel dtsm = new DefaultTreeSelectionModel();
  dtsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  this.setSelectionModel(dtsm);
  // set the tree renderer
  OntologyRenderer myRenderer = new OntologyRenderer();
  this.setCellRenderer(myRenderer);
  this.setRootVisible(false);
}
 
開發者ID:IGNF,項目名稱:geoxygene,代碼行數:21,代碼來源:OntologyBrowser.java

示例3: JTree

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
/**
 * Creates a new <code>JTree</code> object.
 * 
 * @param model the model to use
 */
public JTree(TreeModel model)
{
  setRootVisible(true);
  setSelectionModel( new DefaultTreeSelectionModel() );
  
  // The root node appears expanded by default.
  nodeStates = new Hashtable();

  // The cell renderer gets set by the UI.
  cellRenderer = null;

  // Install the UI before installing the model. This way we avoid double
  // initialization of lots of UI and model stuff inside the UI and related
  // classes. The necessary UI updates are performed via property change
  // events to the UI.
  updateUI();
  setModel(model);
}
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:24,代碼來源:JTree.java

示例4: JTree

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
/**
 * Creates a new <code>JTree</code> object.
 *
 * @param model the model to use
 */
public JTree(TreeModel model)
{
  setRootVisible(true);
  setSelectionModel( new DefaultTreeSelectionModel() );

  // The root node appears expanded by default.
  nodeStates = new Hashtable();

  // The cell renderer gets set by the UI.
  cellRenderer = null;

  // Install the UI before installing the model. This way we avoid double
  // initialization of lots of UI and model stuff inside the UI and related
  // classes. The necessary UI updates are performed via property change
  // events to the UI.
  updateUI();
  setModel(model);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:24,代碼來源:JTree.java

示例5: PullRequestsTreeModel

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
public PullRequestsTreeModel() {
    super(null);

    this.root = new PRTreeNode(TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_TITLE));
    setRoot(root);
    this.requestedByMeRoot = new PRTreeNode(TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_REQUESTED_BY_ME));
    root.insert(requestedByMeRoot, 0);
    this.assignedToMeRoot = new PRTreeNode(TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_ASSIGNED_TO_ME));
    root.insert(assignedToMeRoot, 1);

    allRequestedByMePullRequests = new ArrayList<GitPullRequest>();
    allAssignedToMePullRequests = new ArrayList<GitPullRequest>();

    selectionModel = new DefaultTreeSelectionModel();
    selectionModel.setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
}
 
開發者ID:Microsoft,項目名稱:vso-intellij,代碼行數:17,代碼來源:PullRequestsTreeModel.java

示例6: OlapBrowser

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
/** Creates new form OlapBrowser */
public OlapBrowser() {
    initComponents();
    
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    jTree1.setModel(new DefaultTreeModel(root));
    jTree1.setCellRenderer( new OlapTreeCellRenderer());
    
    jComboBoxType.addItem(new Tag("java.lang.String",I18n.getString("OlapBrowser.ComboBox.Text")));
    jComboBoxType.addItem(new Tag("java.lang.Number", I18n.getString("OlapBrowser.ComboBox.Numeric")));
    jComboBoxType.addItem(new Tag("java.util.Date", I18n.getString("Global.List.Date")));
    jComboBoxType.addItem(new Tag("java.util.Date", I18n.getString("OlapBrowser.ComboBox.Boolean")));
    
    jComboBoxType.setSelectedIndex(0);
    
    //applyI18n();
    
    ((DefaultTreeSelectionModel)jTree1.getSelectionModel()).setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION );
}
 
開發者ID:JockiHendry,項目名稱:ireport-fork,代碼行數:20,代碼來源:OlapBrowser.java

示例7: MappingPanel

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
public MappingPanel(GraphPanel<?, ?> graphpanel) {
    super(graphpanel);

    // Allow multiple roots, the virtual networks.
    getTree().setRootVisible(false);
    getTree().setShowsRootHandles(true);

    listener = new MappingTreeChangeListener(this);

    // Add context menu.
    getTree().addMouseListener(new MappingPanelMouseAdapter());
    setToolTipText("Right click to open context menu");

    // Selection.
    getTree().getSelectionModel().setSelectionMode(
            DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
    getTree().addTreeSelectionListener(
            new MappingTreeSelectionListener(this));

    // Color highlighting of current selection.
    getTree().setCellRenderer(new MappingTreeCellRenderer());
}
 
開發者ID:liruixpc11,項目名稱:crucian,代碼行數:23,代碼來源:MappingPanel.java

示例8: WorkbenchFetchModelDialog

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
/** Creates new form WorkbenchFetchModelDialog */
public WorkbenchFetchModelDialog(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();
    resetModelList();
    resetVersions();
    // Set single selection for tree
    TreeSelectionModel selModel = new DefaultTreeSelectionModel();
    selModel.setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
    modelTree.setSelectionModel(selModel);
    // Set default server ip
    Configuration conf = Configuration.getInstance();
    serverUriTextField.setText(conf.getProperty(WorkbenchConnectToServerDialog.CONF_SERVER_URI, "http://localhost:1205"));
    userName.setText(conf.getProperty(WorkbenchConnectToServerDialog.CONF_SERVER_USER,"root"));
    userPassword.setText(conf.getProperty(WorkbenchConnectToServerDialog.CONF_SERVER_PASSWORD,"inubit"));
    connectToServerAction();
}
 
開發者ID:frapu78,項目名稱:processeditor,代碼行數:18,代碼來源:WorkbenchFetchModelDialog.java

示例9: init

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
private void init() {
    editor = new ProcessEditor();
    editor.setModel(form);
    editor.setAnimationEnabled(true);
    editorPane.setLayout(new GridLayout(1,1));
    editorPane.add(editor);
    transferHandler = new XFormsWizardTransferHandler(editor);
    editor.setTransferHandler(transferHandler);
    XFormsWizardTreeCellRenderer cr = new XFormsWizardTreeCellRenderer();
    boTree.setCellRenderer(cr);
    boTree.setDragEnabled(true);
    boTree.setTransferHandler(transferHandler);
    DefaultTreeSelectionModel selModel = new DefaultTreeSelectionModel();
    selModel.setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
    boTree.setSelectionModel(selModel);
    actionTree.setCellRenderer(cr);
    actionTree.setDragEnabled(true);
    actionTree.setTransferHandler(transferHandler);
    actionTree.setRootVisible(false);
}
 
開發者ID:frapu78,項目名稱:processeditor,代碼行數:21,代碼來源:XFormsWizard.java

示例10: initTreeSelection

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
private static void initTreeSelection(JTree tree, NamedElement tableElement, DefaultTreeModel treeModel)
{
    TreeSelectionModel treeSelectionModel = new DefaultTreeSelectionModel();

    List<Element> nodes = IfmlModelingHelper.getNodeElements(tableElement, new ArrayList<Element>(), true);

    for (Element node : nodes)
    {
        if (IfmlModelingHelper.isSelected(node))
        {
            IfmlTreeNode treeNode = getTreeNode(node, treeModel);

            if (treeNode != null)
            {
                treeSelectionModel.addSelectionPath(new TreePath(treeNode.getPath()));
            }
        }
    }

    tree.setSelectionModel(treeSelectionModel);
}
 
開發者ID:lonniev,項目名稱:com.nomagic.magicdraw.plugins.ifml,代碼行數:22,代碼來源:TreeHelper.java

示例11: setModel

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
public void setModel(TreeTableModel treeTableModel){
    // Create the tree. It will be used as a renderer and editor.
    tree = new TreeTableCellRenderer(treeTableModel);

    setModel(new TreeTableModelAdapter(treeTableModel, tree));
    
 // Force the JTable and JTree to share their row selection models.
    tree.setSelectionModel(new DefaultTreeSelectionModel() {
        // Extend the implementation of the constructor, as if:
        /* public this() */{
            setSelectionModel(listSelectionModel);
        }
    });
    // Make the tree and table row heights the same.
    tree.setRowHeight(getRowHeight());

    // Install the tree editor renderer and editor.
    setDefaultRenderer(TreeTableModel.class, tree);
    setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor());

    setShowGrid(false);
    setIntercellSpacing(new Dimension(0, 0));
}
 
開發者ID:datagr4m,項目名稱:org.datagr4m,代碼行數:24,代碼來源:JTreeTable.java

示例12: MappingPanel

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
public MappingPanel(GraphPanel<?, ?> graphpanel, Scenario scenario) {
	super(graphpanel);

	// createTreeModel requires this.scenario,
	// therefore it cannot be called from super constructor.
	this.scenario = scenario;
	_createTreeModel();

	// Allow multiple roots, the virtual networks.
	getTree().setRootVisible(false);
	getTree().setShowsRootHandles(true);

	listener = new MappingTreeChangeListener(this);

	// Add context menu.
	getTree().addMouseListener(new MappingPanelMouseAdapter());
	setToolTipText("Right click to open context menu");

	// Selection.
	getTree().getSelectionModel().setSelectionMode(
			DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
	getTree().addTreeSelectionListener(
			new MappingTreeSelectionListener(this));

	// Color highlighting of current selection.
	getTree().setCellRenderer(new MappingTreeCellRenderer());
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:28,代碼來源:MappingPanel.java

示例13: JTreeTable

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
public JTreeTable(TreeTableModel treeTableModel) {
	super();

	// Create the tree. It will be used as a renderer and editor.
	tree = new TreeTableCellRenderer(treeTableModel, this);

	// Install a tableModel representing the visible rows in the tree.
	super.setModel(new TreeTableModelAdapter(treeTableModel, tree));

	// Force the JTable and JTree to share their row selection models.
	tree.setSelectionModel(new DefaultTreeSelectionModel() {
		// Extend the implementation of the constructor, as if:
		/* public this() */{
			setSelectionModel(listSelectionModel);
		}
	});
	// Make the tree and table row heights the same.
	tree.setRowHeight(getRowHeight());

	// Install the tree editor renderer and editor.
	setDefaultRenderer(TreeTableModel.class, tree);
	setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor());

	setShowGrid(false);
	setIntercellSpacing(new Dimension(0, 0));

	cellRendererRedLeft = new CellRenderer(java.awt.Color.RED, false, null);
	cellRendererGreenLeft = new CellRenderer(java.awt.Color.GREEN, false, null);
	cellRendererRedRight = new CellRenderer(java.awt.Color.RED, true, null);
	cellRendererGreenRight = new CellRenderer(java.awt.Color.GREEN, true, null);
	cellRendererYellowLeft = new CellRenderer(java.awt.Color.YELLOW, false, null);
	cellRendererYellowRight = new CellRenderer(java.awt.Color.YELLOW, true, null);

	setPreferredScrollableViewportSize(new Dimension(1000, 500));
	setFillsViewportHeight(true);
	setAutoCreateRowSorter(true);
}
 
開發者ID:skarna1,項目名稱:javaportfolio,代碼行數:38,代碼來源:JTreeTable.java

示例14: JTree

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
public JTree(TreeModel newModel) {
		super();
		visibleRowCount = 15;
		rootVisible = true;
		selectionModel = new DefaultTreeSelectionModel();
		cellRenderer = null;
//		{
//			LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
//			defaultLinearLayout.addView(rootScrollView, lp);
//		}
//		setPeerAdAPI(defaultLinearLayout);
		setModel(newModel);
		updateUI();
	}
 
開發者ID:javalovercn,項目名稱:j2se_for_android,代碼行數:15,代碼來源:JTree.java

示例15: CTagsTree

import javax.swing.tree.DefaultTreeSelectionModel; //導入依賴的package包/類
/**
 * Creates a new tree object.
 *
 * @param parent Parent window used for dialogs.
 * @param graph Graph shown in the window.
 * @param manager Provides tag information.
 */
public CTagsTree(final JFrame parent, final ZyGraph graph, final ITagManager manager) {
  m_parent = Preconditions.checkNotNull(parent, "IE02308: Perent argument can not be null");
  m_graph = Preconditions.checkNotNull(graph, "IE01776: Graph can not be null");
  m_tagManager = Preconditions.checkNotNull(manager, "IE01777: Manager argument can not be null");

  m_model = new CTagsTreeModel(this);
  setModel(m_model);
  getModel().addTreeModelListener(new InternalModelListener());
  addMouseListener(m_mouseListener);
  m_graph.addListener(m_graphSelectionListener);
  m_graph.addListener(m_graphVisibilityListener);

  setRootVisible(false);

  m_rootNode = new CRootTagTreeNode(parent, this, graph, m_tagManager);
  m_model.setRoot(m_rootNode);

  setCellRenderer(new CTagTreeCellRenderer()); // ATTENTION: UNDER NO CIRCUMSTANCES MOVE THIS LINE
                                               // ABOVE THE SETROOT LINE

  m_model.nodeStructureChanged(m_rootNode);

  final List<IDropHandler> handlers = new ArrayList<IDropHandler>();

  handlers.add(new CTagSortingHandler());

  new CDefaultTransferHandler(this, DnDConstants.ACTION_COPY_OR_MOVE, handlers);

  final DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
  selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  setSelectionModel(selectionModel);

  final InputMap windowImap = getInputMap(JComponent.WHEN_FOCUSED);

  windowImap.put(HotKeys.DELETE_HK.getKeyStroke(), "DELETE");
  getActionMap().put("DELETE", CActionProxy.proxy(new DeleteAction()));
}
 
開發者ID:google,項目名稱:binnavi,代碼行數:45,代碼來源:CTagsTree.java


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