示例#1
0
  public JFrame buildFrame() {

    f = new JFrame("AMSA World");
    f.setSize(800, 600);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLayout(new GridBagLayout());

    textArea.setFocusable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            checkInput();
          }
        };
    inputText.addActionListener(listener);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1.0;
    c.gridwidth = 3;
    c.weighty = 0.025;
    c.gridx = 0;
    c.gridy = 0;
    f.add(topPanel, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = 2;
    c.gridx = 0;
    c.gridy = 1;
    f.add(scrollPane, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = 1;
    c.gridx = 2;
    c.gridy = 1;
    f.add(sidePanel, c);
    sidePanel.setVisible(false);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weighty = 0.025;
    c.gridwidth = 3;
    c.gridx = 0;
    c.gridy = 2;
    f.add(inputText, c);

    f.setVisible(true);

    return f;
  }