JDialog issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Seanus
    New Member
    • Feb 2007
    • 6

    #1

    JDialog issue

    Hi all,

    I've got a little problem with the JDialogs.

    Housekeeping: I'm on windows xp, with the latest JRE, I'm getting no error as such.

    Basically, I've got some JDialogs in my program (are you sure you wanna close? etc) but they get 'buried' under the main window if you deselect the window (either alt+tab to another prog, or even just clicking in the gray of the start bar). The following code is lifted straight from the main gui window's listeners. It prints out the line when I reselect the program after selecting another. So thoeretically some sort of "optionDialog.s how()" where this prinln is should bring it back on top but it doesnt.

    Code:
    public void windowActivated(WindowEvent winEvent)
    {			
    	if(winEvent.getSource() == this && optionDialog != null)
    	{
    		System.out.println("YAY it worked");
    	}
    }
    I have tried: optionDialog...
    .show()
    .setEnabled(tru e)
    .setVisible(tru e)
    .grabFocus()
    .requestFocus()
    .doLayout()
    .validate()
    .revalidate()

    none of them bring the JDialog to focus back on top of the main window. It seems like the kind of problem that is fairly obvious with experience in the JDialogs but this is my first real usage of them.

    Any ideas?

    Thanks all

    P.S. I can upload all the code for the program if it would help but would rather not being that it's for my final year project at uni and the plagarism checks they do will google the code right up thus causing me headaches and board meetings!
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by Seanus
    Hi all,

    I've got a little problem with the JDialogs.

    Housekeeping: I'm on windows xp, with the latest JRE, I'm getting no error as such.

    Basically, I've got some JDialogs in my program (are you sure you wanna close? etc) but they get 'buried' under the main window if you deselect the window (either alt+tab to another prog, or even just clicking in the gray of the start bar). The following code is lifted straight from the main gui window's listeners. It prints out the line when I reselect the program after selecting another. So thoeretically some sort of "optionDialog.s how()" where this prinln is should bring it back on top but it doesnt.

    Code:
    public void windowActivated(WindowEvent winEvent)
    {			
    	if(winEvent.getSource() == this && optionDialog != null)
    	{
    		System.out.println("YAY it worked");
    	}
    }
    I have tried: optionDialog...
    .show()
    .setEnabled(tru e)
    .setVisible(tru e)
    .grabFocus()
    .requestFocus()
    .doLayout()
    .validate()
    .revalidate()

    none of them bring the JDialog to focus back on top of the main window. It seems like the kind of problem that is fairly obvious with experience in the JDialogs but this is my first real usage of them.

    Any ideas?

    Thanks all

    P.S. I can upload all the code for the program if it would help but would rather not being that it's for my final year project at uni and the plagarism checks they do will google the code right up thus causing me headaches and board meetings!
    Go through this again and rewrite your dialogs after that and tell us how it goes.

    Comment

    • Seanus
      New Member
      • Feb 2007
      • 6

      #3
      Originally posted by r035198x
      Go through this again and rewrite your dialogs after that and tell us how it goes.
      I always try the the java sun pages first, hence where I got the grabFocus() from looking at the inherited classes. Please do point out something specific if I've missed it but I cannot see anything on that page that helps. No doubt there will be something but I've read over the page 3 or 4 times and still cannot see anything. Clearly a gap in my knowledge of GUI coding.

      Comment

      Working...