Hi all,

I have a problem with comboBox.

The comboBox popsup whenever the popup list goes out of the screen.
But i found that if the comboBox is inside a Jtable it doesn't seem to
follow this rule.

It occured to me that the method computePopupBounds
in the BasicComboPopup was responsible in placing the menu's location.

The method says ...

    protected Rectangle computePopupBounds(int px,int py,int pw,int ph) {
        Rectangle absBounds = new Rectangle();
        Rectangle r = new Rectangle(px,py,pw,ph);
        Point p = new Point(0,0);
        Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();

        SwingUtilities.convertPointFromScreen(p,comboBox);
        absBounds.x = p.x;
        absBounds.y = p.y;
        absBounds.width = scrSize.width;
        absBounds.height= scrSize.height;

        if ( SwingUtilities.isRectangleContainingRectangle(absBounds,r) ) {
         System.out.println("abhay: returning r");
            return r;
        }
        else {
         System.out.println("abhay: returning new Rectangle");
            return new Rectangle(0,-r.height,r.width,r.height);
        }
    }

(it uses the screen size 'scrSize' for its calculation)

If i could replace the scrSize with something like
Dimesion containerSize =
    /* somehow get the container in which the comboBox is placed
     * like for example .. in my case the reference of the Jtable
     */
    container.getSize();

then i think that comboBox editor of the Jtable will start calculating
on the basis of container (or rather the JTable's) size instead of the
screen size and will start poping up the menu in upward direction.

My problem is getting the reference of the container which contains
the comboBox.

Can anyone suggest me how to get the reference ?
I tried getParent() but it returned me 'NULL'.

All the suggestions are welcomed are appreciated.

kind regards
abhay
 

 
  ---
You are currently subscribed to jdjlist as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
http://www.sys-con.com/fusetalk

Reply via email to