getLocationOnScreen public Point getLocationOnScreen()Gets the location of this component in the form of a point specifying the component's top-left corner in the screen's coordinate space. Returns: an instance of Point representing the top-left corner of the component's bounds in the coordinate space of the screen Throws: IllegalComponentStateException - if the component is not showing on the screen See Also: setLocation(int, int), getLocation()
public void mousePressed(MouseEvent e) { try{ JTree tree = (JTree)e.getSource(); int rowLocation = tree.getRowForLocation(e.getX(), e.getY()); TreePath treepath = tree.getPathForRow(rowLocation); TreeNode treenode = (TreeNode) treepath.getLastPathComponent(); }catch(NullPointerException ne){ } } }
public void mousePressed(MouseEvent e) { int rowLocation = tree.getRowForLocation(e.getX(), e.getY()); } }
public Point getLocationOnScreen()Gets the location of this component in the form of a point specifying the component's top-left corner in the screen's coordinate space. Returns:
an instance of Point representing the top-left corner of the component's bounds in the coordinate space of the screen
Throws:
IllegalComponentStateException - if the component is not showing on the screen
See Also:
setLocation(int, int), getLocation()
{
try{
JTree tree = (JTree)e.getSource();
int rowLocation = tree.getRowForLocation(e.getX(), e.getY());
TreePath treepath = tree.getPathForRow(rowLocation);
TreeNode treenode = (TreeNode) treepath.getLastPathComponent();
}catch(NullPointerException ne){
}
}
}
{
int rowLocation = tree.getRowForLocation(e.getX(), e.getY());
}
}