JDialog没有指定父窗口,构造函数里有

解决方案 »

  1.   

    “不管怎么切换窗口,JDialog总是在最上面”?
    既然能切换其它窗口,JDialog干吗还要在上面
    如果JDialog总在最上面的话,用
    JDialog(Frame owner, boolean modal) 
    第二个参数设为true第二个问题,跟通常用法没有什么区别,你使用一个数据库总要知道ip地址吧
      

  2.   

    还有一个问题,怎么样才能访问internet上的数据库
      

  3.   

    在jdbc数据源中把数据库指到远程机器上的数据库
      

  4.   

    哦,看错了,以为是odbc驱动
    ms的sql server 2000的jdbc驱动的url是这样写的
    "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=haiguan"; 
    localhost换成远程机器ip
      

  5.   

    JDialog是否可以指定JInternetFrame为父窗口
      

  6.   

    如果你指定JDialog的父窗口为null的话,即便你把JDialog设为模态的也不行,即出现你说的问题!
    既然有JInternetFrame,那当然也有JDesktopPane了,你把JDesktopPane设为JDialog的父窗口就可以了!
      

  7.   

    JDialog的父窗口可以是JDesktopPane吗?
    如果构造函数可以写成FrameRootNode(JDesktopPane frame, String title,boolean modal)吗?
      

  8.   

    用这个
    JOptionPane.showInternalOptionDialog(Component parentComponent,Object message,String title,
    int optionType,int messageType,Icon icon,Object[] options,Object initialValue)
      

  9.   

    类似的还有:
    static int showInternalConfirmDialog(Component parentComponent, Object message)
    static int showInternalConfirmDialog(Component parentComponent, Object message, String title, int optionType)
    static int showInternalConfirmDialog(Component parentComponent, Object message, String title, int optionType, int messageType)
    static int showInternalConfirmDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon)
    static String showInternalInputDialog(Component parentComponent, Object message)
    static String showInternalInputDialog(Component parentComponent, Object message, String title, int messageType)
    static Object showInternalInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue)
    static void showInternalMessageDialog(Component parentComponent, Object message)
    static void showInternalMessageDialog(Component parentComponent, Object message, String title, int messageType)
    static void showInternalMessageDialog(Component parentComponent, Object message, String title, int messageType, Icon icon)
    static int showInternalOptionDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon, Object[] options, Object initialValue)
    具体使用方法参看文档
      

  10.   

    我的界面是这样的:JInternetFrame里面有一个按钮,点这个按钮探出一个JDialog,然后再JDialog里面输入信息保存后退出JDialog
      

  11.   

    那你就用
    showInternalInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue)
    用法自己查文档。
    你不是要我帮你查吧?哈哈
      

  12.   

    怎样取得JInternalFrame的父窗口
      

  13.   

    父窗口类是FrameMain,怎样取得父窗口
      

  14.   

    干吗要取父类窗口,用JInternalFrame做parentComponent
    JOptionPane.showInternalInputDialog(internalFrame,...);
      

  15.   

    我现在的程序是已经以继承了JDialog类,并且在里面添加了很多信息,保存信息后还有返回值
    用JOptionPane.showInternalInputDialog可以把internalFrame当作父窗口,但是能不能显示自定义的JDialog呢
      

  16.   

    在产生JDialog的那个类中持有父窗口的一个引用
      

  17.   

    问题已解决,我写得JDialog的构造函数中,父窗口是Frame,所以我在父窗口类中添加了一个方法public static FrameMain parent = null;
    public FrameMain() {
            enableEvents(AWTEvent.WINDOW_EVENT_MASK);
            try {
                jbInit();
            }
            catch(Exception e) {
                e.printStackTrace();
            }
        }    public static FrameMain getFrame(){
           return parent;
        }
    然后再JInternalFrame中调用FrameMain.getFrame(),得到父窗口的引用,这样JDialog的父窗口就可以设为FrameMain
      

  18.   

    问题已解决,我写得JDialog的构造函数中,父窗口是Frame,所以我在父窗口类中添加了一个方法public static FrameMain parent = null;
    public FrameMain() {
            enableEvents(AWTEvent.WINDOW_EVENT_MASK);
            try {
                jbInit();
                parent = this;
            }
            catch(Exception e) {
                e.printStackTrace();
            }
        }    public static FrameMain getFrame(){
           return parent;
        }
    然后再JInternalFrame中调用FrameMain.getFrame(),得到父窗口的引用,这样JDialog的父窗口就可以设为FrameMain