本文整理汇总了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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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 );
}
示例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());
}
示例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();
}
示例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);
}
示例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);
}
示例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));
}
示例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());
}
示例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);
}
示例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();
}
示例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()));
}