Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Dialog Box  RSS feed

 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can I display Dialog without extending class as Frame or Window?
If yes, how? Would you please explain me by simple example?
Thanks in advance,
angela
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should really be in the Swing/JFC/AWT forum, so I'm transferring it...
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A java.awt.Dialog is already an extension of java.awt.Window, so you can't change that. I suppose it might be possible to create a Dialog-like component that des not extend Window, but why? What's wrong with using a Window?
 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank Jim,
Here is my code:
import java.applet.Applet;
import java.awt.*;
public class myDialog extends Frame
{
Dialog md ;
myDialog()
{
md = new Dialog(this, "Error Message Window");
Panel p = new Panel();
Label l = new Label("No Server Response");
p.add(l);
md.add("Center" ,p);
Panel p2 = new Panel();
p2.setLayout(new FlowLayout());
Button ok = new Button("Retry");
Button cancel = new Button("Cancel");
p2.add(ok);
p2.add(cancel);
md.add("South",p2);

}
public static void main(String args[])
{
myDialog theApp = new myDialog();
theApp.show();
}
}
I want to display dialog box without extending class to Frame?
Please let me know how can I do it?
THanks again
angela
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a dialog class I made as a practice exercise:

An application that would *use* this mcDialog class, would need to extend Frame. (typically, dialogs require a frame as a parent, however I've seen programs send null)
The comment about VB was for me, since I come from a VB Background. In fact, now that I take a second look, the comment is wrong. dispose() is like Me.hide, and not at all like Unload Me.
[This message has been edited by Mike Curwen (edited March 27, 2001).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!