本文整理汇总了Java中javax.swing.JTree.addTreeSelectionListener方法的典型用法代码示例。如果您正苦于以下问题:Java JTree.addTreeSelectionListener方法的具体用法?Java JTree.addTreeSelectionListener怎么用?Java JTree.addTreeSelectionListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTree
的用法示例。
在下文中一共展示了JTree.addTreeSelectionListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FileTree
import javax.swing.JTree; //导入方法依赖的package包/类
/** Construct a FileTree */
public FileTree(File dir) {
setLayout(new BorderLayout());
applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
setBorder(null);
// Make a tree list with all the nodes, and make it a JTree
JTree tree = new JTree(addNodes(null, dir));
tree.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
// Add a listener
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) e
.getPath().getLastPathComponent();
}
});
add(BorderLayout.CENTER, tree);
JScrollPane scrollBarExplorer = new JScrollPane();
scrollBarExplorer.getViewport().add(tree);
scrollBarExplorer.setBorder(null);
add(scrollBarExplorer, BorderLayout.CENTER);
}
示例2: createLeftPanel
import javax.swing.JTree; //导入方法依赖的package包/类
private synchronized Component createLeftPanel() {
SampleResult rootSampleResult = new SampleResult();
rootSampleResult.setSampleLabel("Root");
rootSampleResult.setSuccessful(true);
root = new SearchableTreeNode(rootSampleResult, null);
treeModel = new DefaultTreeModel(root);
jTree = new JTree(treeModel);
jTree.setCellRenderer(new ResultsNodeRenderer());
jTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
jTree.addTreeSelectionListener(this);
jTree.setRootVisible(false);
jTree.setShowsRootHandles(true);
JScrollPane treePane = new JScrollPane(jTree);
treePane.setPreferredSize(new Dimension(200, 300));
VerticalPanel leftPane = new VerticalPanel();
leftPane.add(treePane, BorderLayout.CENTER);
leftPane.add(createComboRender(), BorderLayout.NORTH);
autoScrollCB = new JCheckBox(JMeterUtils.getResString("view_results_autoscroll")); // $NON-NLS-1$
autoScrollCB.setSelected(false);
autoScrollCB.addItemListener(this);
leftPane.add(autoScrollCB, BorderLayout.SOUTH);
return leftPane;
}
示例3: ViewTreeGroups
import javax.swing.JTree; //导入方法依赖的package包/类
public ViewTreeGroups(String directory) {
//super("JTree FileSystem Viewer - JavaProgrammingForums.com");
setTitle("GroupsTree Structure");
fileDetailsTextArea.setEditable(false);
fileSystemModel = new FileSystemModel(new File(directory));
fileTree = new JTree(fileSystemModel);
fileTree.setEditable(true);
fileTree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent event) {
File file = (File) fileTree.getLastSelectedPathComponent();
fileDetailsTextArea.setText(getFileDetails(file));
}
});
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
true, new JScrollPane(fileTree), new JScrollPane(
fileDetailsTextArea));
getContentPane().add(splitPane);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(640, 480);
setVisible(true);
}
开发者ID:cyberheartmi9,项目名称:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代码行数:22,代码来源:ViewTreeGroups.java
示例4: initializeTree
import javax.swing.JTree; //导入方法依赖的package包/类
private void initializeTree() {
tree = new JTree();
tree.setCellRenderer(new CustomTreeRenderer());
tree.setVisibleRowCount(8);
tree.setBackground(background);
tree.addTreeSelectionListener(this);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.setShowsRootHandles(true);
}
示例5: createUnderPane
import javax.swing.JTree; //导入方法依赖的package包/类
private JSplitPane createUnderPane(JTree tree) {
JTextArea toStringArea = new JTextArea();
toStringArea.setLineWrap(true);
toStringArea.setEditable(false);
tree.addTreeSelectionListener(new ToStringListener(toStringArea));
JSplitPane result = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
new JScrollPane(tree),
new JScrollPane(toStringArea));
result.setOneTouchExpandable(true);
result.setDividerSize(8);
result.setDividerLocation(0.8);
return result;
}
示例6: addReflectionTab
import javax.swing.JTree; //导入方法依赖的package包/类
private void addReflectionTab() {
methodTree = new JTree(compNode.getMethodsModel());
methodTree.setCellRenderer(renderer);
methodTree.setEditable(false);
methodTree.addTreeSelectionListener(selManager);
tbd.add(REFLECTION_TAB, new JScrollPane(methodTree));
}
示例7: buildMainPanel
import javax.swing.JTree; //导入方法依赖的package包/类
protected Component buildMainPanel() {
JPanel keyPanel = buildKeyTablePanel();
/*
* Tree of all components from target component down
*/
JPanel treePanel = new JPanel(new BorderLayout());
MyTreeNode top = new MyTreeNode(target);
createNodes(top);
tree = new JTree(top);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addTreeSelectionListener(this);
tree.setSelectionRow(0);
tree.setCellRenderer(new MyTreeCellRenderer());
JScrollPane treeScroll = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
treePanel.add(treeScroll, BorderLayout.CENTER);
treePanel.setMinimumSize(new Dimension(400, 100));
treePanel.setPreferredSize(new Dimension(800, 300));
/*
* First split between Tree display and Keys
*/
JSplitPane split1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, treePanel, keyPanel);
split1.setResizeWeight(0.5);
return split1;
}
示例8: addComponentTab
import javax.swing.JTree; //导入方法依赖的package包/类
private void addComponentTab() {
if (compNode instanceof ContainerNode
&& ((ContainerNode) compNode).getComponents().length > 0) {
componentTree = new JTree(((ContainerNode) compNode).getComponentModel());
componentTree.setCellRenderer(renderer);
componentTree.setEditable(false);
componentTree.addTreeSelectionListener(selManager);
componentSplit = createUnderPane(componentTree);
tbd.add(COMPONENTS_TAB, componentSplit);
}
}
示例9: setupGui
import javax.swing.JTree; //导入方法依赖的package包/类
private void setupGui(ClientService clientService, PluginService pluginService)
{
model = new SecurityTreeModel(clientService, pluginService);
tree = new JTree(model);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.setCellRenderer(new MyTreeCellRenderer());
tree.addTreeSelectionListener(this);
tabManager = new TabManager(clientService, allowEditing);
JScrollPane scroller = new JScrollPane(tree);
scroller.setMinimumSize(new Dimension(200, Integer.MAX_VALUE));
JSplitPane split = AppletGuiUtils.createSplitPane();
split.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
split.setContinuousLayout(true);
split.add(scroller, JSplitPane.LEFT);
split.add(tabManager, JSplitPane.RIGHT);
JButton closeButton = new JButton(closeAction);
final int[] rows = {TableLayout.FILL, closeButton.getPreferredSize().height,};
final int[] cols = {TableLayout.FILL, closeButton.getPreferredSize().width,};
content = new JPanel(new TableLayout(rows, cols));
content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
content.add(split, new Rectangle(0, 0, 2, 1));
content.add(closeButton, new Rectangle(1, 1, 1, 1));
updateEditor();
}
示例10: TreePanel
import javax.swing.JTree; //导入方法依赖的package包/类
public TreePanel()
{
query = new JTextField();
query.addActionListener(this);
search = new JButton(CurrentLocale.get("searching.userGroupRole.executeQuery"));
search.addActionListener(this);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout(5, 5));
panel
.add(new JLabel(CurrentLocale.get("com.tle.admin.recipients.browserfinder.groups")), BorderLayout.WEST);
panel.add(query, BorderLayout.CENTER);
panel.add(search, BorderLayout.EAST);
model = new DefaultTreeModel(null);
tree = new JTree(model);
setLayout(new BorderLayout(5, 5));
add(panel, BorderLayout.NORTH);
add(new JScrollPane(tree), BorderLayout.CENTER);
tree.addMouseListener(mouse);
tree.setShowsRootHandles(true);
tree.setRootVisible(false);
tree.addTreeSelectionListener(this);
}
示例11: openDataWindow
import javax.swing.JTree; //导入方法依赖的package包/类
public void openDataWindow() {
contentPane = new JPanel( new BorderLayout( 10, 10 ) );
Border emptyBorder = BorderFactory.createEmptyBorder(10, 10, 10, 10);
contentPane.setBorder( emptyBorder );
searchPane = new JPanel( new BorderLayout( 5, 5 ) );
top = new DefaultMutableTreeNode();
okButton = new JButton("OK");
okButton.addActionListener(this);
searchBar = new JTextField(20);
searchBar.setText(defaultSearchBarText);
searchBar.selectAll();
searchBar.addActionListener(this);
createNodes(top);
tree = new JTree(top);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
tree.addTreeSelectionListener(this);
JScrollPane treeView = new JScrollPane(tree);
contentPane.add(treeView, "Center");
contentPane.add(okButton, "South");
searchPane.add(searchLabel, "West");
searchPane.add(searchBar, "Center");
contentPane.add(searchPane, "North");
contentPane.setOpaque(true);
frame.setContentPane(contentPane);
frame.pack();
frame.setVisible(true);
}
示例12: addWindowTab
import javax.swing.JTree; //导入方法依赖的package包/类
private void addWindowTab() {
if (compNode instanceof WindowNode
&& ((WindowNode) compNode).getWindows().length > 0) {
winTree = new JTree(((WindowNode) compNode).getWindowModel());
winTree.setCellRenderer(renderer);
winTree.setEditable(false);
winTree.addTreeSelectionListener(selManager);
winSplit = createUnderPane(winTree);
tbd.add(WINDOWS_TAB, winSplit);
}
}
示例13: DataTableColumnDropTextFieldTransferHandler
import javax.swing.JTree; //导入方法依赖的package包/类
public DataTableColumnDropTextFieldTransferHandler(JTree plotConfigTree, SeriesUsageType seriesUsage,
AttributeDropTextField aDTF) {
seriesUsageType = seriesUsage;
plotConfigTree.addTreeSelectionListener(this);
this.aDTF = aDTF;
}
示例14: RangeAxisConfigPanel
import javax.swing.JTree; //导入方法依赖的package包/类
public RangeAxisConfigPanel(JTree plotConfigTree, PlotInstance plotInstance) {
super(plotInstance);
createComponents();
registerAsPlotConfigurationListener();
plotConfigTree.addTreeSelectionListener(this);
}
示例15: AbstractTreeSelectionDependentPanel
import javax.swing.JTree; //导入方法依赖的package包/类
public AbstractTreeSelectionDependentPanel(JTree plotConfigurationTree, PlotInstance plotInstance) {
super(plotInstance);
plotConfigurationTree.addTreeSelectionListener(this);
}