🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.java.programmer
Article #435

Re: Pop up a message box in applet

#435
From: Nicholas J Anderson
Date: Tue, 30 Jun 1998 00:00
59 lines
2480 bytes
Hi, 

I just make a frame object in my applet, then pass this to the
constructor for my dialog box.
This works fine for me in appletviewer, IE4, Netscape 4.03+patch and
HotJava1.1.4 on Win95 and X-win.
by the way I am using sunJDK1.1.4.

e.g.  somewhere in my applet class (i.e where ever  you want to create
the dialog:

Frame f = new Frame();          
helpDialog d = new helpDialog(f, "Sorry, no help available");
d.setVisible(true);

Then the dialog class.....

class helpDialog extends Dialog implements ActionListener, ItemListener
{

Button ok = new Button("O.K");

//---  constructor      
helpDialog(Frame parent, String title){
                
super(parent, title, true);  //sets parent, frame title, and modality
setSize(300,210);            // set the size
setLayout(null);             //null layout
add(ok);                     //add the OK button
ok.setBounds(145,160,50,23); //set the position and size of the button
ok.addActionListener(this);  //register to recieve events from button
}

public void paint(Graphics g)
{

g.drawString("Sorry, no help topic for this area",10,40);

}


        
public void actionPerformed(ActionEvent ae)
        {
        String command = ae.getActionCommand();
        if (command.equals("O.K")) 
                        {
                        dispose();
                        }
                        
        }
        

}


Hope that helps////////
Nikk Anderson
Technical Details
Message-ID: <xaJjFSALPCm1Ewb7@aegerine.demon.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6n6nh9$bd1$1@nnrp1.dejanews.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fa3e3,afddcc2748cf26d8
X-Google-Attributes: gidfa3e3,public
X-Google-Thread: 10fd6d,afddcc2748cf26d8
X-Google-Attributes: gid10fd6d,public
X-Google-Thread: 10a146,afddcc2748cf26d8
X-Google-Attributes: gid10a146,public
X-Google-Thread: f74b3,afddcc2748cf26d8
X-Google-Attributes: gidf74b3,public
From: Nicholas J Anderson <Nikk@nospam.aegerine.demon.co.uk>
Subject: Re: Pop up a message box in applet
Date: 1998/06/30
Message-ID: <xaJjFSALPCm1Ewb7@aegerine.demon.co.uk>
X-Deja-AN: 367498220
X-NNTP-Posting-Host: aegerine.demon.co.uk:193.237.15.220
Sender: Nicholas J Anderson <Nikk@aegerine.demon.co.uk>
References: <6n6nh9$bd1$1@nnrp1.dejanews.com>
X-Complaints-To: abuse@demon.net
X-Trace: news.demon.co.uk 899232043 nnrp-06:29720 NO-IDENT aegerine.demon.co.uk:193.237.15.220
MIME-Version: 1.0
Newsgroups: comp.lang.java.programmer,borland.public.jbuilder.java.language,comp.lang.java.gui,borland.public.jbuilder.ide