怎样在点击一个按钮之后在它的下方并紧贴按钮下边界产生一个Jwindow

解决方案 »

  1.   


    JWindow window = new JWindow();
    window.setSize(new Dimension(button.getX(),button.getY()));
    window.setLocation(button.getX(), button.getY()+button.getWidth());
    window.setVisible(true);
      

  2.   


    但是这样产生的window不是刚好在button的下边 
    怎么样转换 窗体坐标跟屏幕绝对坐标 ?
    新产生的window可以直接用 窗体中的相对坐标而不是 setLocation()这样的屏幕绝对坐标...
    可能很容易解决  但是我没看到这方面的资料 ……
    谢谢……
      

  3.   

    建议不要用JWindow,采用Dialog/JDialog或者Popup都可以实现。
      

  4.   

    用Popup比较省事一点。
    1.Popup
    Popup popup = PopupFactory.getSharedInstance().getPopup(Component owner, Component contents,int x, int y);
    popup.show();
    2.Dialog/JDialog
    Dialog dialog = new Dialog(Frame parent);
    dialog.setUndecorated(true);
    dialog.setModal(false);......dialog.show();