本文整理匯總了Java中javax.swing.JTree.addMouseListener方法的典型用法代碼示例。如果您正苦於以下問題:Java JTree.addMouseListener方法的具體用法?Java JTree.addMouseListener怎麽用?Java JTree.addMouseListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JTree
的用法示例。
在下文中一共展示了JTree.addMouseListener方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildTree
import javax.swing.JTree; //導入方法依賴的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: connect
import javax.swing.JTree; //導入方法依賴的package包/類
void connect( JTree errorTree, DefaultTreeModel errModel, JComboBox severityComboBox,
JCheckBox tasklistCheckBox, JPanel customizerPanel,
JEditorPane descriptionTextArea) {
this.errorTree = errorTree;
this.errModel = errModel;
this.severityComboBox = severityComboBox;
this.tasklistCheckBox = tasklistCheckBox;
this.customizerPanel = customizerPanel;
this.descriptionTextArea = descriptionTextArea;
valueChanged( null );
errorTree.addKeyListener(this);
errorTree.addMouseListener(this);
errorTree.getSelectionModel().addTreeSelectionListener(this);
severityComboBox.addActionListener(this);
tasklistCheckBox.addChangeListener(this);
}
示例3: connect
import javax.swing.JTree; //導入方法依賴的package包/類
void connect( JTree errorTree, JComboBox severityComboBox,
JCheckBox tasklistCheckBox, JPanel customizerPanel,
JEditorPane descriptionTextArea) {
this.errorTree = errorTree;
this.severityComboBox = severityComboBox;
this.tasklistCheckBox = tasklistCheckBox;
this.customizerPanel = customizerPanel;
this.descriptionTextArea = descriptionTextArea;
valueChanged( null );
errorTree.addKeyListener(this);
errorTree.addMouseListener(this);
errorTree.getSelectionModel().addTreeSelectionListener(this);
severityComboBox.addActionListener(this);
tasklistCheckBox.addChangeListener(this);
}
示例4: SimulationExplorer
import javax.swing.JTree; //導入方法依賴的package包/類
SimulationExplorer(Project proj, MenuListener menu) {
super(new BorderLayout());
this.project = proj;
SimulationToolbarModel toolbarModel = new SimulationToolbarModel(proj, menu);
Toolbar toolbar = new Toolbar(toolbarModel);
add(toolbar, BorderLayout.NORTH);
model = new SimulationTreeModel(proj.getSimulator().getCircuitState());
model.setCurrentView(project.getCircuitState());
tree = new JTree(model);
tree.setCellRenderer(new SimulationTreeRenderer());
tree.addMouseListener(this);
tree.setToggleClickCount(3);
add(new JScrollPane(tree), BorderLayout.CENTER);
proj.addProjectListener(this);
}
示例5: connect
import javax.swing.JTree; //導入方法依賴的package包/類
void connect( final JTree errorTree, DefaultTreeModel errorTreeModel, JLabel severityLabel, JComboBox severityComboBox,
JCheckBox tasklistCheckBox, JPanel customizerPanel,
JEditorPane descriptionTextArea, final JComboBox configCombo, JButton editScript,
HintsSettings settings, boolean direct) {
this.errorTree = errorTree;
this.errorTreeModel = errorTreeModel;
this.severityLabel = severityLabel;
this.severityComboBox = severityComboBox;
this.tasklistCheckBox = tasklistCheckBox;
this.customizerPanel = customizerPanel;
this.descriptionTextArea = descriptionTextArea;
this.configCombo = configCombo;
this.editScript = editScript;
this.direct = direct;
if (configCombo.getSelectedItem() !=null) {
originalSettings = ((Configuration) configCombo.getSelectedItem()).getSettings();
} else if (settings != null) {
originalSettings = settings;
} else {
originalSettings = HintsSettings.getGlobalSettings();
}
writableSettings = new WritableSettings(originalSettings, direct);
valueChanged( null );
errorTree.addKeyListener(this);
errorTree.addMouseListener(this);
errorTree.getSelectionModel().addTreeSelectionListener(this);
this.configCombo.addItemListener(this);
severityComboBox.addActionListener(this);
tasklistCheckBox.addChangeListener(this);
}
示例6: ExtendedCheckTreeMouseSelectionManager
import javax.swing.JTree; //導入方法依賴的package包/類
public ExtendedCheckTreeMouseSelectionManager(JTree tree, boolean selectAll) {
this.tree = tree;
selectionModel = new ExtendedCheckTreeSelectionModel(tree.getModel());
if (selectAll) {
selectionModel.addSelectionPath(tree.getPathForRow(0));
}
tree.setCellRenderer(new ExtendedCheckTreeCellRenderer(new DefaultTreeCellRenderer(), selectionModel));
tree.addMouseListener(this);
selectionModel.addTreeSelectionListener(this);
}
示例7: 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);
}
示例8: init
import javax.swing.JTree; //導入方法依賴的package包/類
private void init() {
treeModel.setRoot(createRoot());
tree = new JTree(treeModel) {
@Override
public TreeCellRenderer getCellRenderer() {
TreeCellRenderer renderer = super.getCellRenderer();
if (renderer == null)
return null;
((DefaultTreeCellRenderer) renderer).setLeafIcon(new ImageIcon(
getClass().getResource("/images/function.png")));
return renderer;
}
};
tree.setCellRenderer(new Renderer());
tree.setEditable(true);
tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if ((e.getButton() == MouseEvent.BUTTON1)
&& (e.getClickCount() == 2)) {
openDiagram();
}
}
});
tree.setRootVisible(true);
JScrollPane pane = new JScrollPane();
pane.setViewportView(tree);
this.add(pane, BorderLayout.CENTER);
}
示例9: createDocPane
import javax.swing.JTree; //導入方法依賴的package包/類
private JTree createDocPane() {
final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
for (Map.Entry<?,? extends List<?>> docEntry : getDoc().getItemTree()
.entrySet()) {
DefaultMutableTreeNode node = new DefaultMutableTreeNode(docEntry.getKey());
root.add(node);
for (Object rule : docEntry.getValue()) {
node.add(new DefaultMutableTreeNode(rule));
}
}
final JTree result = new JTree(root) {
@Override
public String getToolTipText(MouseEvent evt) {
if (getRowForLocation(evt.getX(), evt.getY()) == -1) {
return null;
}
TreePath curPath = getPathForLocation(evt.getX(), evt.getY());
Object userObject =
((DefaultMutableTreeNode) curPath.getLastPathComponent()).getUserObject();
return getToolTip(userObject);
}
};
result.setRootVisible(false);
result.setShowsRootHandles(true);
DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) result.getCellRenderer();
renderer.setBackgroundNonSelectionColor(null);
renderer.setBackgroundSelectionColor(null);
renderer.setTextSelectionColor(null);
renderer.setLeafIcon(null);
renderer.setClosedIcon(null);
renderer.setOpenIcon(null);
result.setCellRenderer(renderer);
ToolTipManager.sharedInstance()
.registerComponent(result);
result.addMouseListener(new DismissDelayer(result));
for (int i = 0; i < root.getChildCount(); i++) {
result
.expandPath(new TreePath(((DefaultMutableTreeNode) root.getChildAt(i)).getPath()));
}
result.setBackground(null);
return result;
}
示例10: initialise
import javax.swing.JTree; //導入方法依賴的package包/類
public void initialise(boolean allowReordering, int fixedEditorWidth)
{
additionalActions = getAdditionalActions();
if( additionalActions == null )
{
additionalActions = Collections.emptyList();
}
upDownActions = new ArrayList<TLEAction>();
if( allowReordering )
{
upDownActions.add(upAction);
upDownActions.add(downAction);
}
editorContainer = new JPanel(new GridLayout(1, 1));
editorContainer.setBorder(AppletGuiUtils.DEFAULT_BORDER);
editorContainer.add(getNoSelectionComponent());
tree = new JTree(model.getUnderlyingTreeModel());
tree.addMouseListener(new TreePopupListener(tree, new CombinedCollection<TLEAction>(additionalActions,
upDownActions)));
tree.addTreeSelectionListener(new TreeSelectionListener()
{
@Override
public void valueChanged(TreeSelectionEvent e)
{
NODE_TYPE newSelection = getCurrentTreeSelection();
if( !Objects.equals(currentSelection, newSelection) )
{
saveCurrentSelection();
loadCurrentSelection();
update();
}
}
});
JScrollPane treeScroller = new JScrollPane(tree);
JComponent buttonsPanel = getButtonsPanel();
JButton upButton = new JTextlessButton(upAction);
JButton downButton = new JTextlessButton(downAction);
final int height1 = upButton.getPreferredSize().height;
final int height2 = buttonsPanel.getPreferredSize().height;
final int width1 = upButton.getPreferredSize().width;
final int width2 = fixedEditorWidth >= 0 ? TableLayout.FILL : buttonsPanel.getPreferredSize().width;
final int width3 = fixedEditorWidth >= 0 ? fixedEditorWidth : TableLayout.FILL;
final int[] rows = {TableLayout.FILL, height1, height1, TableLayout.FILL, height2,};
final int[] cols = allowReordering ? new int[]{width1, width2, width3,} : new int[]{width2, width3,};
setLayout(new TableLayout(rows, cols));
int columnStart = 0;
if( allowReordering )
{
columnStart = 1;
add(upButton, new Rectangle(0, 1, 1, 1));
add(downButton, new Rectangle(0, 2, 1, 1));
}
add(treeScroller, new Rectangle(columnStart, 0, 1, 4));
add(buttonsPanel, new Rectangle(columnStart, 4, 1, 1));
add(editorContainer, new Rectangle(columnStart + 1, 0, 1, 4));
update();
}
示例11: createTreePane
import javax.swing.JTree; //導入方法依賴的package包/類
public JScrollPane createTreePane() {
// new tree
root = new DefaultMutableTreeNode("Root");
tree = new JTree(root);
tree.setEditable(false);
// click tree
tree.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
if (selPath != null) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent();
if (node.isLeaf()) {
String type = (String) node.getUserObject();
String strpar = node.getParent().toString();
String strcur = node.toString();
String selectedObjectParent = strpar;
selectedObject = strpar +"." + strcur;
if (console.wMode == HMLP_Console.windowMode.SELECT_DB){
console.insertTextOut("The database \"" + selectedObject +"\" was selected.");
} else if (console.wMode == HMLP_Console.windowMode.EDIT_DB){
} else if (console.wMode == HMLP_Console.windowMode.ADD_PARENTS){
console.insertTextOut("The node \"" + selectedObject +"\" was selected.");
} else if (console.wMode == windowMode.JOIN_RELATIONS) {
} else if (console.wMode == HMLP_Console.windowMode.ADD_CLD){
console.insertTextOut("The node \"" + selectedObject +"\" was selected.");
} else if (console.wMode == windowMode.LEARNING) {
} else if (console.wMode == windowMode.EVALUATION) {
}
}
}
}
});
// Expand all
for (int i = 0; i < tree.getRowCount(); i++)
tree.expandRow(i);
return new JScrollPane(tree);
}
示例12: createTreePane
import javax.swing.JTree; //導入方法依賴的package包/類
public JScrollPane createTreePane() {
// new tree
root = new DefaultMutableTreeNode("Root");
tree = new JTree(root);
tree.setEditable(false);
// click tree
tree.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
if (selPath != null) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent();
if (node.isLeaf()) {
TreePath[] threePaths = tree.getSelectionPaths();
selectedObjects.clear();
for (TreePath tp: threePaths){
DefaultMutableTreeNode eachNode = (DefaultMutableTreeNode) tp.getLastPathComponent();
String strpar = eachNode.getParent().toString();
String str = strpar + "." + eachNode.toString();
selectedObjects.add(str);
}
// String type = (String) node.getUserObject();
// String str2 = node.toString();
// String strpar = node.getParent().toString();
// selectedObject = str2;
if (console.wMode == HMLP_Console.windowMode.SELECT_DB){
console.insertTextOut("The database \"" + selectedObjects +"\" was selected.");
} else if (console.wMode == HMLP_Console.windowMode.EDIT_DB){
} else if (console.wMode == HMLP_Console.windowMode.ADD_PARENTS){
console.insertTextOut("The node \"" + selectedObjects +"\" was selected.");
} else if (console.wMode == windowMode.JOIN_RELATIONS) {
} else if (console.wMode == HMLP_Console.windowMode.ADD_CLD){
console.insertTextOut("The CLD \"" + selectedObjects +"\" was selected.");
} else if (console.wMode == windowMode.LEARNING) {
} else if (console.wMode == windowMode.EVALUATION) {
}
}
}
}
});
// Expand all
for (int i = 0; i < tree.getRowCount(); i++)
tree.expandRow(i);
return new JScrollPane(tree);
}