0

this is a newbie question. I am experimenting a little with Java, and I stumbled across a method which is supposed to call an empty dialog.

The method, however, has a Dialog parameter in the signature which I have no idea how to use. It looks like this:

public TestDialog(GraphicsConfiguration gc,
                     int x, int y,
                     Dialog dialog)
{
    super(dialog, getMsg("dialog.title"), true, gc);
    initDialog(x, y);
}

I see from the javadocs that it's supposed to represent the parent window, but how would I call this method exactly and what do I need to pass as the Dialog parameter? I have googled, but couldn't find much; please be patient, i'm just starting out with this language :)

Edit

I should point out that I understand what the Dialog parameter does, it allows the method to retrieve information from the calling dialog (in this example, it's supposed to retrieve a text string); I just have no idea how to call this.

Unique_Key
  • 69
  • 6

1 Answers1

1

A dialog must have either a frame or another dialog defined as its owner when it's constructed. So at some point, you'll have a dialog with a frame as it's parent.

The Dialog class has both constructors, with Dialog or Frame as parents.

Alix Martin
  • 332
  • 1
  • 5
  • Alright, I think I understand this point: basically, once the dialog has been declared, I should be able to use this information to use in whatever method requires it. Problem is, how would I go to pass it to the method? I tried creating a new Dialog object manually, passing Dialog as an argument and using the this keyword, but of course nothing worked; do you have any examples I can look at? – Unique_Key Oct 02 '12 at 09:25
  • Here your TestDialog class should be extending another class so super means something, and inheriting the getMsg and initDialog methods. – Alix Martin Oct 02 '12 at 09:38
  • Ah, alright; it says it's extending JDialog. Does this mean I can't call the class directly? – Unique_Key Oct 02 '12 at 10:00
  • You don't call a class, you instantiate it or you call it's methods. If you want an empty Dialog, you can get one with new JDialog() or new Dialog(new Frame()) – Alix Martin Oct 02 '12 at 11:10
  • I got it, thanks. In the end, I had to instantiate the class first: TestClass tc = New TestClass(int x, int y, new Dialog(new Frame())); and then it worked, after importing java.awt.Frame. I'm still trying to get the actual dialog to show up, though, but this helped a lot. – Unique_Key Oct 02 '12 at 12:40