예제 #1
0
	/**
	 * Returns the text area that fired the specified event.
	 * @param evt The event
	 */
	public static JEditTextArea getTextArea(EventObject evt)
	{
		if(evt != null)
		{
			Object o = evt.getSource();
			if(o instanceof Component)
			{
				// find the parent text area
				Component c = (Component)o;
				for(;;)
				{
					if(c instanceof JEditTextArea)
						return (JEditTextArea)c;
					else if(c == null)
						break;
					if(c instanceof JPopupMenu)
						c = ((JPopupMenu)c)
							.getInvoker();
					else
						c = c.getParent();
				}
			}
		}

		// this shouldn't happen
		System.err.println("BUG: getTextArea() returning null");
		System.err.println("Report this to Slava Pestov <*****@*****.**>");
		return null;
	}
 @Override
 public boolean isCellEditable(EventObject e) {
   if (e instanceof MouseEvent && e.getSource() instanceof JTree) {
     MouseEvent me = (MouseEvent) e;
     JTree tree = (JTree) e.getSource();
     TreePath path = tree.getPathForLocation(me.getX(), me.getY());
     Rectangle r = tree.getPathBounds(path);
     if (r == null) {
       return false;
     }
     Dimension d = getPreferredSize();
     r.setSize(new Dimension(d.width, r.height));
     if (r.contains(me.getX(), me.getY())) {
       if (str == null && System.getProperty("java.version").startsWith("1.7.0")) {
         setBounds(new Rectangle(0, 0, d.width, r.height));
       }
       // System.out.println(getBounds());
       return true;
     }
   }
   return false;
 }