Fiz um applet, este applet chama um frame. Atrav�s deste frame eu chamo uma caixa de dialogo. Esta caixa de dialogo possui um textfield para que o que fosse digitado um texto nela, e ap�s apertado o bot�o OK ou fechar a caixa de dialogo. o texto seja mostrado no frame anterior.
 
Aqui esta o programa, quem souber resolver por favor me ajude.
 
Obrigado
 
import java.awt.*;
import java.applet.*;
 
public class DialogApplet extends Applet
{
    DialogFrame frame;
    Button button;
 
    public void init()
    {
          frame = new DialogFrame("Dialog Window");
 
          button = new Button("Show Window");
          add(button);
    }
 
    public boolean action(Event evt, Object arg)
    {
        boolean visible = frame.isShowing();
        if (visible)
        {
            frame.hide();
            button.setLabel("Show Window");
        }
        else
        {
            frame.show();
            button.setLabel("Hide Window");
        }
 
        return true;
    }
}
 
class DialogFrame extends Frame
{
    MenuBar menuBar;
    Dialog dialog;
    TextField textField;
    String str;
 
    DialogFrame(String title)
    {
        super(title);
 
        menuBar = new MenuBar();
        setMenuBar(menuBar);
        Menu menu = new Menu("Test");
        menuBar.add(menu);
        MenuItem item = new MenuItem("Dialog box");
        menu.add(item);
 
        str = "";
    }
 
    public void paint(Graphics g)
    {
        resize(300, 250);
 
        g.drawString("THE TEXT YOU ENTERED IS:", 70, 50);
        g.drawString(str, 70, 70);
    }
 
    public boolean action(Event evt, Object arg)
    {
        if (evt.target instanceof MenuItem)
        {
            if (arg == "Dialog box")
                ShowDialogBox();
        }
        else if (evt.target instanceof Button)
        {
            if (arg == "OK")
            {
                dialog.hide();
                str = textField.getText();
                repaint();
            }
        }
 
        return true;
    }
 
    protected void ShowDialogBox()
    {
        dialog = new Dialog(this, "Test Dialog", true);
        FlowLayout layout = new FlowLayout();
        dialog.setLayout(layout);
 
        textField = new TextField("", 20);
        Button button = new Button("OK");
        dialog.add(button);
        dialog.add(textField);
 
        dialog.show();
        dialog.resize(200, 100);
    }
}
 
Atenciosamente
 
[]'s
==============================================
Kleber Rodrigo de Carvalho
Site Engineer
http://www.krc.cjb.net
UIN: 21311977
 
i4vision - Internet Solutions
(19) 422-0717
http://www.i4vision.com.br
==============================================

Responder a