Exemplo n.º 1
0
  public void init() {
    Output.web = true;

    String opts = getParameter("opts");
    if (opts != null) {
      almc lmc = new almc("-tdir=" + getCodeBase() + " " + opts);
      return;
    }

    setBackground(Color.black);
    setForeground(Color.lightGray);
    setLayout(new GridLayout(3, 1));

    panel1 = new Panel1(this);
    add(panel1);
    panel2 = new Panel2(this);
    add(panel2);
    err = new TextArea();
    err.setEditable(false);
    err.setBackground(Color.black);
    err.setForeground(Color.lightGray);
    add(err);
    stdReset();

    out.append(Output.version + "\n\n");
    err.append(Output.version + "\n");
    par.append(Output.version + "\n");
    Output.err.println("Running from " + getCodeBase());
  }
Exemplo n.º 2
0
  /**
   * IRC Constructor
   *
   * @param jo the JVN object representing the Chat
   */
  public Irc(JvnObject jo) {
    sentence = jo;
    frame = new JFrame();
    frame.setLayout(new GridLayout(1, 1));
    text = new TextArea(10, 60);
    text.setEditable(false);
    text.setForeground(Color.red);
    frame.add(text);
    data = new TextField(40);
    frame.add(data);
    Button read_button = new Button("read");
    read_button.addActionListener(new readListener(this));
    frame.add(read_button);
    Button write_button = new Button("write");
    write_button.addActionListener(new writeListener(this));
    frame.add(write_button);
    frame.setSize(545, 201);
    // frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            System.out.println("Closed");
            try {
              JvnServerImpl.jvnGetServer().jvnTerminate();
            } catch (Exception exc) {
              System.out.println("An exception: " + exc);
            }

            e.getWindow().dispose();
          }
        });
    text.setBackground(Color.black);
    frame.setVisible(true);
  }
Exemplo n.º 3
0
  public Irc(Sentence_itf s) {

    setLayout(new FlowLayout());

    text = new TextArea(10, 60);
    text.setEditable(false);
    text.setForeground(Color.red);
    add(text);

    data = new TextField(60);
    add(data);

    Button write_button = new Button("write");
    write_button.addActionListener(new writeListener(this));
    add(write_button);
    Button read_button = new Button("read");
    read_button.addActionListener(new readListener(this));
    add(read_button);

    setSize(470, 300);
    text.setBackground(Color.black);
    show();

    sentence = s;
  }
  void login() {
    try {
      logoutBtn.setEnabled(true);
      contactList.setEditable(false);
      loginBtn.setEnabled(false);
      loginId.setEnabled(false);
      password.setEnabled(false);

      //
      plugin.login(
          getMyLoginId(), password.getText(), getContactList(), MessagingNetwork.STATUS_ONLINE);
      logoutBtn.setEnabled(true);
    } catch (Throwable tr) {
      printException(tr);
      boolean loggedIn = false;
      try {
        loggedIn = plugin.getClientStatus(getMyLoginId()) != MessagingNetwork.STATUS_OFFLINE;
      } catch (Throwable tr2) {
        printException(tr2);
      }
      if (!loggedIn) {
        enableLoginUI();
      }
    }
  }
Exemplo n.º 5
0
  void jbInit() throws Exception {
    panel1.setLayout(borderLayout1);
    panel2.setBackground(Color.yellow);
    panel2.setLayout(borderLayout2);
    ButtonOK.setLabel("OK");
    ButtonOK.addMouseListener(
        new java.awt.event.MouseAdapter() {

          public void mouseClicked(MouseEvent e) {
            ButtonOK_mouseClicked(e);
          }
        });

    String s1 = CallingApp.MotherApplet.GetName();

    textArea1.setBackground(SystemColor.control);
    textArea1.setEditable(false);

    panel1.add(panel2, BorderLayout.CENTER);
    panel2.add(textArea1, BorderLayout.CENTER);
    panel1.add(panel3, BorderLayout.SOUTH);
    panel3.add(ButtonOK, null);
    String s =
        s1
            + " v:"
            + CallingApp.MotherApplet.GetVersionNum()
            + "\n"
            + CallingApp.MotherApplet.GetInfos();
    textArea1.setText(s);
  }
Exemplo n.º 6
0
  public void initComponents() {
    /** ******************** The main container *************************** */
    Container container = this.getContentPane();
    container.setLayout(new BorderLayout());
    container.setBackground(Color.black);
    this.setSize(650, 600);
    this.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {}
        });

    /** ************************* MAIN PANEL ******************************* */
    mainPanel = new JPanel();
    // If put to False: we see the container's background
    mainPanel.setOpaque(false);
    mainPanel.setLayout(new BorderLayout());
    container.add(mainPanel, BorderLayout.CENTER);

    allmessagesTextArea = new TextArea();
    allmessagesTextArea.setEditable(false);
    allmessagesTextArea.setFont(new Font("Dialog", 1, 12));
    allmessagesTextArea.setForeground(Color.black);
    allmessagesTextArea.append("Select a session in the list to view its messages");
    mainPanel.add(allmessagesTextArea, BorderLayout.CENTER);

    sessionsList = new List();
    sessionsList.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            showMessages(e);
          }
        });
    sessionsList.setForeground(Color.black);
    sessionsList.setFont(new Font("Dialog", 1, 14));
    mainPanel.add(sessionsList, BorderLayout.WEST);

    okButton = new JButton("  OK  ");
    okButton.setToolTipText("Returns to the main frame");
    okButton.setFont(new Font("Dialog", 1, 16));
    okButton.setFocusPainted(false);
    okButton.setBackground(Color.lightGray);
    okButton.setBorder(new BevelBorder(BevelBorder.RAISED));
    okButton.setVerticalAlignment(SwingConstants.CENTER);
    okButton.setHorizontalAlignment(SwingConstants.CENTER);
    container.add(okButton, BorderLayout.SOUTH);
    okButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            setVisible(false);
          }
        });
  }
 void enableLoginUI() {
   try {
     logoutBtn.setEnabled(false);
     contactList.setEditable(true);
     loginBtn.setEnabled(true);
     loginId.setEnabled(true);
     password.setEnabled(true);
   } catch (Throwable tr) {
     CAT.error("exception", tr);
   }
 }
Exemplo n.º 8
0
  public AppExport() {
    JLabel label = new JLabel("Choose Dashboard's Web directory:               ");
    add(label);

    JButton go = new JButton("Browse...");
    go.addActionListener(this);
    add(go);

    textArea = new TextArea("", 20, 100, TextArea.SCROLLBARS_NONE);
    textArea.setEditable(false);
    add(textArea);
  }
Exemplo n.º 9
0
 public VertexInfoDialog(Vertex vertex) {
   v = vertex;
   setTitle("Vertex: " + v.getName());
   Container cp = getContentPane();
   JPanel p = new JPanel();
   p.setLayout(new GridLayout(1, 1));
   opis = new TextArea(v.getInfo());
   opis.setEditable(false);
   p.add(opis, new FlowLayout());
   cp.add(p);
   setSize(200, 300);
   setDefaultCloseOperation(DISPOSE_ON_CLOSE);
 }
Exemplo n.º 10
0
  public NewFractionCalc() {

    super("Fraction Calculator");
    setLayout(new FlowLayout());
    add(msg);
    msg.setEditable(false);
    for (int i = 0; i < sa.length; i++) {
      buta[i] = new Button(sa[i]);
      buta[i].addActionListener(this);
      add(buta[i]);
    }
    setSize(110, 230);
    show();
  }
Exemplo n.º 11
0
  public void addComponentsToPane() {

    testfield = new JTextField("", 33);
    testfield.addKeyListener(this);

    testtextarea = new TextArea(buffer, 15, 33, TextArea.SCROLLBARS_VERTICAL_ONLY);
    testtextarea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(testtextarea);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(600, 200));

    getContentPane().add(testfield, BorderLayout.PAGE_END);
    getContentPane().add(testtextarea, BorderLayout.CENTER);
  }
Exemplo n.º 12
0
 /** Creates new HelpBox */
 public HelpBox() {
   super(new Frame(), " Help ", false);
   this.setBackground(Color.white);
   this.setLayout(new BorderLayout());
   helpTextArea = new TextArea();
   helpTextArea.setEditable(false);
   // fill the help box
   helpTextArea.append(
       "National Institute of Standards and Technology\n"
           + "========================================\n"
           + "\n"
           + "NIST-SIP Trace viewer 1.1\n"
           + "========================================\n"
           + "\n"
           + "\n"
           + " Hit refresh  to get new trace data from the proxy. \n"
           + "If no traces appear at all, you should check if the proxy is started.\n"
           + "Once some SIP sessions are available, you can click directly on \n"
           + "an arrow representing a SIP message of your \n"
           + "choice, and see the text of the chosen SIP message. \n"
           + "If any small yellow bubbles appear on the top right of the SIP message, \n"
           + "you can click on it and see some extra informations logged by the proxy.\n"
           + "\n"
           + "\n"
           + "If you experience any problems please contact:\n"
           + "[email protected]\n"
           + "\n");
   ok = new Button(" Ok ");
   ok.setBackground(Color.lightGray);
   ok.setForeground(Color.black);
   this.add(helpTextArea, BorderLayout.CENTER);
   this.add(ok, BorderLayout.SOUTH);
   ok.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mouseClicked(MouseEvent e) {
           setVisible(false);
         }
       });
   this.addWindowListener(
       new WindowAdapter() {
         @Override
         public void windowClosing(WindowEvent e) {
           setVisible(false);
         }
       });
   // width, height
   this.setSize(400, 400);
 }
Exemplo n.º 13
0
  public ReciveFile() {
    super("파일전송");
    setLayout(null);
    lbl = new Label("파일 전송을 기다립니다.");
    lbl.setBounds(10, 30, 230, 20);
    lbl.setBackground(Color.gray);
    lbl.setForeground(Color.white);
    add(lbl);
    txt = new TextArea("", 0, 0, TextArea.SCROLLBARS_BOTH);
    txt.setBounds(10, 60, 230, 100);
    txt.setEditable(false);
    add(txt);
    btn = new Button("닫기");
    btn.setBounds(105, 170, 40, 20);
    btn.setVisible(false);
    btn.addActionListener(this);
    add(btn);
    addWindowListener(new WinListener());
    setSize(250, 200);
    show();

    try {
      ServerSocket socket = new ServerSocket(port);
      Socket sock = null;
      FileThread client = null;
      try {
        sock = socket.accept();
        client = new FileThread(this, sock);
        client.start();
      } catch (IOException e) {
        System.out.println(e);
        try {
          if (sock != null) sock.close();
        } catch (IOException e1) {
          System.out.println(e1);
        } finally {
          sock = null;
        }
      }
    } catch (IOException e) {
    }
  }
Exemplo n.º 14
0
  public babylonTextDialog(
      Frame parent,
      String myLabel,
      String contents,
      int columns,
      int rows,
      int scrollbars,
      boolean IsModal,
      String dismissString) {
    super(parent, myLabel, IsModal);

    parentFrame = parent;

    myLayout = new GridBagLayout();
    setLayout(myLayout);

    p = new Panel();
    p.setLayout(myLayout);

    textArea = new TextArea(contents, rows, columns, scrollbars);
    textArea.addKeyListener(this);
    textArea.setEditable(false);
    textArea.setFont(babylonPanel.smallFont);
    p.add(
        textArea,
        new babylonConstraints(
            0,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 0),
            0,
            0));

    dismissButton = new Button(dismissString);
    dismissButton.setFont(babylonPanel.smallFont);
    dismissButton.addActionListener(this);
    dismissButton.addKeyListener(this);
    p.add(
        dismissButton,
        new babylonConstraints(
            0,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    add(
        p,
        new babylonConstraints(
            0,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));

    pack();

    if ((parentFrame instanceof babylonWindow) || (parentFrame instanceof babylonServerWindow))
      babylonPanel.centerDialog(parentFrame, this);
    else babylonPanel.centerDialogOnScreen(this);

    addKeyListener(this);
    addWindowListener(this);
    setResizable(false);
    setVisible(true);
    dismissButton.requestFocus();
  }
Exemplo n.º 15
0
  public babylonServerWindow(babylonServer parent, String Name) {
    super(Name);
    server = parent;

    myLayout = new GridBagLayout();
    setLayout(myLayout);

    p = new Panel();
    p.setLayout(myLayout);

    listening = new Label(server.strings.get(thisClass, "listenport") + " " + server.port);
    p.add(
        listening,
        new babylonConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    logChat = new Checkbox(server.strings.get(thisClass, "logchats"), server.logChats);
    logChat.addItemListener(this);
    p.add(
        logChat,
        new babylonConstraints(
            1,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    userList = new List(4, false);
    userList.addItemListener(this);
    p.add(
        userList,
        new babylonConstraints(
            0,
            1,
            1,
            5,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 0),
            0,
            0));

    userAdmin = new Button(server.strings.get(thisClass, "usermanagement"));
    userAdmin.addActionListener(this);
    p.add(
        userAdmin,
        new babylonConstraints(
            1,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    console = new Button(server.strings.get(thisClass, "adminclient"));
    console.addActionListener(this);
    p.add(
        console,
        new babylonConstraints(
            1,
            2,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    disconnect = new Button(server.strings.get(thisClass, "disconnectuser"));
    disconnect.setEnabled(false);
    disconnect.addActionListener(this);
    p.add(
        disconnect,
        new babylonConstraints(
            1,
            3,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    disconnectAll = new Button(server.strings.get(thisClass, "disconnectall"));
    disconnectAll.setEnabled(false);
    disconnectAll.addActionListener(this);
    p.add(
        disconnectAll,
        new babylonConstraints(
            1,
            4,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    shutdown = new Button(server.strings.get(thisClass, "shutdown"));
    shutdown.addActionListener(this);
    p.add(
        shutdown,
        new babylonConstraints(
            1,
            5,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    stats =
        new TextField(
            server.strings.get(thisClass, "connectionscurrent")
                + " 0  "
                + server.strings.get(thisClass, "connectionspeak")
                + " 0  "
                + server.strings.get(thisClass, "connectionstotal")
                + " 0",
            40);
    stats.setEditable(false);
    p.add(
        stats,
        new babylonConstraints(
            0,
            7,
            2,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    logWindow =
        new TextArea(
            server.strings.get(thisClass, "activitylog") + "\n",
            10,
            40,
            TextArea.SCROLLBARS_VERTICAL_ONLY);
    logWindow.setEditable(false);
    p.add(
        logWindow,
        new babylonConstraints(
            0,
            8,
            2,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 0),
            0,
            0));

    canvas = new babylonPictureCanvas(this);
    p.add(
        canvas,
        new babylonConstraints(
            0,
            9,
            2,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    add(
        p,
        new babylonConstraints(
            0,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));

    try {
      URL url = new URL("file", "localhost", "babylonPic.jpg");
      Image image = getToolkit().getImage(url);

      canvas.setimage(image);
    } catch (Exception e) {
      System.out.println(e);
    }

    try {
      URL iconUrl = new URL("file", "localhost", "babylonIcon.jpg");
      ImageIcon icon = new ImageIcon(iconUrl);
      this.setIconImage(icon.getImage());
    } catch (Exception e) {
      /* Not important */
    }

    addWindowListener(this);

    setSize(600, 600);
    pack();
  }
Exemplo n.º 16
0
  /** Create the whole GUI, and set up event listeners */
  public AllComponents(String title) {
    super(title); // set frame title.

    // Arrange to detect window close events
    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    // Set a default font
    this.setFont(new Font("SansSerif", Font.PLAIN, 12));

    // Create the menubar.  Tell the frame about it.
    MenuBar menubar = new MenuBar();
    this.setMenuBar(menubar);

    // Create the file menu.  Add to menubar.
    Menu file = new Menu("File");
    menubar.add(file);

    // Create two items for the file menu, setting their label, shortcut,
    // action command and listener.  Add them to File menu.
    // Note that we use the frame itself as the action listener
    MenuItem open = new MenuItem("Open", new MenuShortcut(KeyEvent.VK_O));
    open.setActionCommand("open");
    open.addActionListener(this);
    file.add(open);
    MenuItem quit = new MenuItem("Quit", new MenuShortcut(KeyEvent.VK_Q));
    quit.setActionCommand("quit");
    quit.addActionListener(this);
    file.add(quit);

    // Create Help menu; add an item; add to menubar
    // Display the help menu in a special reserved place.
    Menu help = new Menu("Help");
    menubar.add(help);
    menubar.setHelpMenu(help);

    // Create and add an item to the Help menu
    MenuItem about = new MenuItem("About", new MenuShortcut(KeyEvent.VK_A));
    about.setActionCommand("about");
    about.addActionListener(this);
    help.add(about);

    // Now that we've done the menu, we can begin work on the contents of
    // the frame.  Assign a BorderLayout manager with margins for this frame.
    this.setLayout(new BorderLayout(10, 10));

    // Create two panels to contain two columns of components.  Use our custom
    // ColumnLayout layout manager for each.  Add them on the west and
    // center of the frame's border layout
    Panel column1 = new Panel();
    column1.setLayout(new ColumnLayout(5, 10, 2, ColumnLayout.LEFT));
    this.add(column1, "West");
    Panel column2 = new Panel();
    column2.setLayout(new ColumnLayout(5, 10, 2, ColumnLayout.LEFT));
    this.add(column2, "Center");

    // Create a panel to contain the buttons at the bottom of the window
    // Give it a FlowLayout layout manager, and add it along the south border
    Panel buttonbox = new Panel();
    buttonbox.setLayout(new FlowLayout(FlowLayout.CENTER, 100, 10));
    this.add(buttonbox, "South");

    // Create pushbuttons and add them to the buttonbox
    Button okay = new Button("Okay");
    Button cancel = new Button("Cancel");
    buttonbox.add(okay);
    buttonbox.add(cancel);

    // Handle events on the buttons
    ActionListener buttonlistener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            textarea.append("You clicked: " + ((Button) e.getSource()).getLabel() + "\n");
          }
        };
    okay.addActionListener(buttonlistener);
    cancel.addActionListener(buttonlistener);

    // Now start filling the left column.
    // Create a 1-line text field and add to left column, with a label
    TextField textfield = new TextField(15);
    column1.add(new Label("Name:"));
    column1.add(textfield);

    // Handle events on the TextField
    textfield.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            textarea.append("Your name is: " + ((TextField) e.getSource()).getText() + "\n");
          }
        });
    textfield.addTextListener(
        new TextListener() {
          public void textValueChanged(TextEvent e) {
            textarea.append("You have typed: " + ((TextField) e.getSource()).getText() + "\n");
          }
        });

    // Create a dropdown list or option menu of choices
    Choice choice = new Choice();
    choice.addItem("red");
    choice.addItem("green");
    choice.addItem("blue");
    column1.add(new Label("Favorite color:"));
    column1.add(choice);

    // Handle events on this choice
    choice.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            textarea.append("Your favorite color is: " + e.getItem() + "\n");
          }
        });

    // Create checkboxes, and group them in a CheckboxGroup to give them
    // "radio button" behavior.
    CheckboxGroup checkbox_group = new CheckboxGroup();
    Checkbox[] checkboxes = new Checkbox[3];
    checkboxes[0] = new Checkbox("vanilla", checkbox_group, false);
    checkboxes[1] = new Checkbox("chocolate", checkbox_group, true);
    checkboxes[2] = new Checkbox("strawberry", checkbox_group, false);
    column1.add(new Label("Favorite flavor:"));
    for (int i = 0; i < checkboxes.length; i++) column1.add(checkboxes[i]);

    // Handle events on the checkboxes
    ItemListener checkbox_listener =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            textarea.append(
                "Your favorite flavor is: " + ((Checkbox) e.getItemSelectable()).getLabel() + "\n");
          }
        };
    for (int i = 0; i < checkboxes.length; i++) checkboxes[i].addItemListener(checkbox_listener);

    // Create a list of choices.
    List list = new List(4, true);
    list.addItem("Java");
    list.addItem("C");
    list.addItem("C++");
    list.addItem("Smalltalk");
    list.addItem("Lisp");
    list.addItem("Modula-3");
    list.addItem("Forth");
    column1.add(new Label("Favorite languages:"));
    column1.add(list);
    // Handle events on this list
    list.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            textarea.append("Your favorite languages are: ");
            String[] languages = ((List) e.getItemSelectable()).getSelectedItems();
            for (int i = 0; i < languages.length; i++) {
              if (i > 0) textarea.append(",");
              textarea.append(languages[i]);
            }
            textarea.append("\n");
          }
        });

    // Create a multi-line text area in column 2
    textarea = new TextArea(6, 40);
    textarea.setEditable(false);
    column2.add(new Label("Messages"));
    column2.add(textarea);

    // Create a scrollpane that displays portions of a larger component
    ScrollPane scrollpane = new ScrollPane();
    scrollpane.setSize(300, 150);
    column2.add(new Label("Scrolling Window"));
    column2.add(scrollpane);

    // Create a custom MultiLineLabel with a really big font and make it
    // a child of the ScrollPane container
    String message =
        "/*************************************************\n"
            + " * AllComponents.java                            *\n"
            + " * Written by David Flanagan                     *\n"
            + " * Copyright (c) 1997 by O'Reilly & Associates   *\n"
            + " *                                               *\n"
            + " *************************************************/\n";
    MultiLineLabel biglabel = new MultiLineLabel(message);
    biglabel.setFont(new Font("Monospaced", Font.BOLD + Font.ITALIC, 24));
    scrollpane.add(biglabel);
  }
Exemplo n.º 17
0
  /** Creates and adds the necessary GUI components. */
  private void addGUIComponents() {
    setBackground(Color.white);

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridbag);

    // Expression
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.0;
    Label exprFieldp = new Label("Expression: ", Label.RIGHT);
    gridbag.setConstraints(exprFieldp, c);
    add(exprFieldp);

    c.weightx = 0.8;
    exprField = new TextField(27);
    gridbag.setConstraints(exprField, c);
    add(exprField);

    // x
    c.weightx = 0.0;
    Label xFieldp = new Label("x: ", Label.RIGHT);
    gridbag.setConstraints(xFieldp, c);
    add(xFieldp);

    c.weightx = 0.2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    xField = new TextField("" + xValue, 4);
    gridbag.setConstraints(xField, c);
    add(xField);

    // Result
    c.weightx = 0.0;
    c.gridwidth = 1;
    Label resultLabelText = new Label("Result: ", Label.RIGHT);
    gridbag.setConstraints(resultLabelText, c);
    add(resultLabelText);

    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    resultLabel = new Label("", Label.LEFT);
    gridbag.setConstraints(resultLabel, c);
    add(resultLabel);

    // Options
    c.weightx = 0.0;
    c.gridwidth = 1;
    Label optionsLabelText = new Label("Options: ", Label.RIGHT);
    gridbag.setConstraints(optionsLabelText, c);
    add(optionsLabelText);

    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    implicitCheckbox = new Checkbox("Implicit multiplication", true);
    gridbag.setConstraints(implicitCheckbox, c);
    add(implicitCheckbox);

    c.weightx = 0.0;
    c.gridwidth = 1;
    Label spaceLabelText = new Label(" ", Label.RIGHT);
    gridbag.setConstraints(spaceLabelText, c);
    add(spaceLabelText);

    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    undeclaredCheckbox = new Checkbox("Allow undeclared identifiers");
    gridbag.setConstraints(undeclaredCheckbox, c);
    add(undeclaredCheckbox);

    // Errors
    c.weightx = 0.0;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTH;
    Label errorLabel = new Label("Errors: ", Label.RIGHT);
    gridbag.setConstraints(errorLabel, c);
    add(errorLabel);

    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    errorTextArea = new TextArea("");
    errorTextArea.setEditable(false);
    errorTextArea.setBackground(Color.white);
    gridbag.setConstraints(errorTextArea, c);
    add(errorTextArea);

    // Set up listeners
    exprField.addTextListener(
        new TextListener() {
          public void textValueChanged(TextEvent evt) {
            exprFieldTextValueChanged();
          }
        });

    xField.addTextListener(
        new TextListener() {
          public void textValueChanged(TextEvent evt) {
            xFieldTextValueChanged();
          }
        });

    implicitCheckbox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent evt) {
            optionsChanged();
          }
        });

    undeclaredCheckbox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent evt) {
            optionsChanged();
          }
        });
  }
Exemplo n.º 18
0
import java.applet.*;
 {
   eventLog.setEditable(false);
 }