Ejemplo n.º 1
0
  // Define method to return commands.
  private void buildFrame(int width, int height) {
    // Set JFrame title.
    setTitle("Communicator");

    // Initialize and set policies for JScrollPane(s).
    receiverScrollPane =
        setScrollPaneProperties(new JScrollPane(receiver = new JTextAreaPanel(COL, ROW)));
    senderScrollPane =
        setScrollPaneProperties(new JScrollPane(sender = new JTextAreaPanel(COL, ROW)));

    // Disable editability of receiver JTextAreaPanel.
    receiver.setEditable(false);

    // Initialize JButtonPanel.
    button = new JButtonPanel();

    // Define and initialize JButton(s).
    buildButtons();

    // Set panel size.
    setSize(width, height);

    // Set JPanel Layout.
    getContentPane().setLayout(new BorderLayout());

    // Add a JTextAreaPanel(s).
    getContentPane().add(receiverScrollPane, BorderLayout.NORTH);
    getContentPane().add(button, BorderLayout.CENTER);
    getContentPane().add(senderScrollPane, BorderLayout.SOUTH);

    // Build JMenuBar.
    buildMenu();

    // Build JButton action listeners.
    buildButtonActionListeners();

    // Set the screen and display dialog window in relation to screen size.
    dim = tk.getScreenSize();
    setLocation((dim.width / 100), (dim.height / 100));

    // --------------------- Begin Window ActionListener ---------------------/

    // Add window listener to the frame.
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent closingEvent) {
            // Exit on window frame close.
            System.exit(0);
          } // End of windowClosing() method.
        }); // End of addWindowListener() method for JFrame.

    // Set resizeable window off.
    setResizable(false);

    // Display the JFrame to the platform window manager.
    show();
  } // End of buildFrame() method.