[4381] in java-interest

home help back first fref pref prev next nref lref last post

Beta 2 : Can't make Panels work

daemon@ATHENA.MIT.EDU (Kondratiev Dima)
Thu Dec 21 13:02:15 1995

From: Kondratiev Dima <DIMA@edge.paragraph.com>
To: Java Interest <java-interest@java.sun.com>
Date: Thu, 21 Dec 95 19:28:00 R



I am trying to make applet window change its GUI during runtime in Beta2.
I don't want to use any other Frames or Windows.
Below is a simple applet GUI which consists of two TextArea and one Button 
objects.
To chage GUI I use applet removeAll() function.
In case I don't use Panels , but just TextArea and Button objects, 
everything works fine.
As soon as I put these objects in Panels I see in my GUI only Button.
What am I doing wrong ? Thanks for you help.

import java.applet.Applet;
import java.awt.*;
import java.util.*;

public class GuiTest extends java.applet.Applet {

  String Welcome = "Hello !";

  TextArea  infoArea = new TextArea(Welcome, 5, 20);
  TextArea  inputArea = new TextArea(5,20);
  Button  connectButton = new Button("Connect");

  public void init() {

    addNotify();

    //makeConnectGui();
    makeConversationGui();
  }


  public boolean action(Event evt, Object arg) {
    System.out.println("Action !");

     if(evt.target == connectButton) {
     if(("Connect").equals(arg)) {
        makeConnectGui();
            connectButton.setLabel("Cancel");
        infoArea.setText("Connecting....");
     } else {
          connectButton.setLabel("Connect");
        infoArea.setText(Welcome);
        makeConversationGui();
     }
    }
    return true;
  }

  protected void makeConversationGui() {

  //make conversation GUI
    removeAll();
    Panel infoPanel = new Panel();
    Panel inputPanel = new Panel();
    Panel controlPanel = new Panel();
    controlPanel.add(connectButton);

    //setLayout(new GridLayout(0, 1));  //rows - any nymber, cols - 1
    setLayout(new BorderLayout());
/*
       add("North",infoArea);
    add("Center",inputArea);
    add("South", connectButton);
*/
       add("North",infoPanel);
    add("Center",inputPanel);
    add("South",controlPanel);

    layout();
  }

  protected void makeConnectGui() {

    removeAll();
    setLayout(new BorderLayout());
       add("North",connectButton);
    add("Center",inputArea);
    add("South",infoArea );

    layout();
  }

}
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post