本文整理了Java中javax.swing.JTree.addMouseListener()
方法的一些代码示例,展示了JTree.addMouseListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.addMouseListener()
方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:addMouseListener
暂无
代码示例来源:origin: stackoverflow.com
// If you are interested in detecting either double-click events or when a user clicks on a node, regardless of whether or not it was selected, we recommend you do the following:
final JTree tree = ...;
MouseListener ml = new MouseAdapter() {
public void mousePressed(MouseEvent e) {
int selRow = tree.getRowForLocation(e.getX(), e.getY());
TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
if(selRow != -1) {
if(e.getClickCount() == 1) {
mySingleClick(selRow, selPath);
}
else if(e.getClickCount() == 2) {
myDoubleClick(selRow, selPath);
}
}
}
};
tree.addMouseListener(ml);
代码示例来源:origin: skylot/jadx
tree = new JTree(treeModel);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
代码示例来源:origin: pmd/pmd
private void init() {
model.addViewerModelListener(this);
setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("AST.PANEL.TITLE")));
setLayout(new BorderLayout());
tree = new JTree((TreeNode) null);
tree.addTreeSelectionListener(this);
tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY());
tree.setSelectionPath(path);
JPopupMenu menu = new ASTNodePopupMenu(model, (Node) path.getLastPathComponent());
menu.show(tree, e.getX(), e.getY());
}
}
});
add(new JScrollPane(tree), BorderLayout.CENTER);
}
代码示例来源:origin: stanfordnlp/CoreNLP
private FilePanel() {
//data stuff
FileTreeNode root = new FileTreeNode();
treeModel = new FileTreeModel(root);
tree = new JTree(treeModel);
tree.setCellRenderer(new FileTreeCellRenderer());
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
TreePath path = tree.getPathForLocation(e.getX(), e.getY());
int nActiveTreebanks = getActiveTreebanks().size();
//Tdiff
boolean canActivate = (! TregexGUI.getInstance().isTdiffEnabled() || nActiveTreebanks < TregexGUI.MAX_TDIFF_TREEBANKS);
if(path != null) {
FileTreeNode node = (FileTreeNode) path.getLastPathComponent();
if(canActivate || node.isActive())
node.setActive(!node.isActive());
}
}
});
//layout/panel stuff
this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(),"Tree files: "));
JScrollPane scroller = new JScrollPane(tree);
this.add(scroller, BorderLayout.CENTER);
}
代码示例来源:origin: deathmarine/Luyten
tree.setCellRenderer(new CellRenderer());
TreeListener tl = new TreeListener();
tree.addMouseListener(tl);
tree.addTreeExpansionListener(new FurtherExpandingTreeExpansionListener());
tree.addKeyListener(new KeyAdapter() {
代码示例来源:origin: INRIA/spoon
/**
* This method initializes jTree
*
* @return javax.swing.JTree
*/
private JTree getJTree() {
if (jTree == null) {
jTree = new JTree(root);
jTree.addKeyListener(this);
jTree.addMouseListener(this);
}
return jTree;
}
代码示例来源:origin: stackoverflow.com
final JTree tree = ...;
MouseListener ml = new MouseAdapter() {
public void mousePressed(MouseEvent e) {
int selRow = tree.getRowForLocation(e.getX(), e.getY());
TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
if(selRow != -1) {
if(e.getClickCount() == 1) {
mySingleClick(selRow, selPath);
}
else if(e.getClickCount() == 2) {
myDoubleClick(selRow, selPath);
}
}
}
};
tree.addMouseListener(ml);
代码示例来源:origin: stackoverflow.com
public static void main ( String[] args )
{
JFrame frame = new JFrame ();
final JTree tree = new JTree ();
tree.addMouseListener ( new MouseAdapter ()
{
public void mousePressed ( MouseEvent e )
{
if ( SwingUtilities.isRightMouseButton ( e ) )
{
TreePath path = tree.getPathForLocation ( e.getX (), e.getY () );
Rectangle pathBounds = tree.getUI ().getPathBounds ( tree, path );
if ( pathBounds != null && pathBounds.contains ( e.getX (), e.getY () ) )
{
JPopupMenu menu = new JPopupMenu ();
menu.add ( new JMenuItem ( "Test" ) );
menu.show ( tree, pathBounds.x, pathBounds.y + pathBounds.height );
}
}
}
} );
frame.add ( tree );
frame.pack ();
frame.setLocationRelativeTo ( null );
frame.setVisible ( true );
}
代码示例来源:origin: ron190/jsql-injection
/**
* Build editor, add tree and mouse listener.
*/
public CellEditorNode() {
this.defaultTreeRenderer = new CellRendererNode();
MediatorGui.treeDatabase().addTreeSelectionListener(this);
MediatorGui.treeDatabase().addMouseListener(this);
}
代码示例来源:origin: jshiell/checkstyle-idea
resultsTree.addTreeSelectionListener(treeSelectionListener);
final MouseListener treeMouseListener = new ToolWindowMouseListener();
resultsTree.addMouseListener(treeMouseListener);
resultsTree.addKeyListener(new ToolWindowKeyboardListener());
resultsTree.setCellRenderer(new ResultTreeRenderer());
代码示例来源:origin: ron190/jsql-injection
this.tree.addMouseListener(new MouseAdapter() {
代码示例来源:origin: pentaho/mondrian
tree.addMouseListener(new PopupTrigger());
tree.addKeyListener(
new KeyAdapter() {
代码示例来源:origin: tinyMediaManager/tinyMediaManager
@Override
protected void installListeners() {
super.installListeners();
tree.addMouseListener(sf);
}
代码示例来源:origin: info.aduna.commons/aduna-commons-swing
public TreeOverlay(JTree tree) {
this.tree = tree;
tree.addMouseListener(this);
tree.addMouseMotionListener(this);
}
代码示例来源:origin: com.google.code.findbugs/findbugs
void setupTreeListeners() {
// noinspection ConstantIfStatement
if (false) {
tree.addTreeExpansionListener(new MyTreeExpansionListener());
}
tree.addTreeSelectionListener(new MyTreeSelectionListener());
tree.addMouseListener(new TreeMouseListener());
}
代码示例来源:origin: org.nuiton/nuiton-widgets
/**
* Enable data tips for a tree component.
* @param tree the tree which should be enhanced with data tips.
*/
public synchronized void register(JTree tree) {
tree.addMouseListener(treeMouseListener);
tree.addMouseMotionListener(treeMouseListener);
tree.addComponentListener(treeMouseListener);
}
代码示例来源:origin: org.apache.river.examples/browser
public AttributePanel(ServiceItem item, ServiceRegistrar registrar) {
super(false); // Entries are not editable.
this.item = item;
this.registrar = registrar;
tree.addMouseListener(browser.wrap(new ServiceBrowser.MouseReceiver(item,
uiDescriptorPopup())));
refreshPanel();
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-vmd-game
private void init() {
this.model = new GlobalRepositoryTreeAdapter(gameDesign);
this.tree = new JTree(model);
this.tree.setRootVisible(true);
this.tree.setShowsRootHandles(true);
this.tree.setCellRenderer(new GameDesignTreeNodeRenderer());
this.tree.addMouseListener(new TreeMousListener());
}
代码示例来源:origin: org.languagetool/languagetool-gui-commons
static void install(JTree tree) {
TreeListener listener = new TreeListener(tree);
tree.addMouseListener(listener);
tree.addKeyListener(listener);
tree.addTreeWillExpandListener(listener);
}
代码示例来源:origin: Jamling/SmartIM
protected void initTree(JTree tree) {
// tree.setCellRenderer(new ContactTreeCellRenderer());
tree.setShowsRootHandles(false);
tree.setRootVisible(false);
tree.addMouseListener(new IMContactDoubleClicker(getImPanel()));
}
内容来源于网络,如有侵权,请联系作者删除!