コード例 #1
0
ファイル: ChatPanelImpl.java プロジェクト: andrelrs/sneer
  private void initGui() {
    _listScrollPane.getViewport().add(_shoutsList);
    JScrollPane inputScrollPane = new JScrollPane();
    JPanel horizontalLimit =
        new JPanel() {
          @Override
          public Dimension getPreferredSize() {
            Dimension preferredSize = super.getPreferredSize();
            preferredSize.setSize(getWidth() - 30, preferredSize.getHeight());
            return preferredSize;
          }
        };
    horizontalLimit.setLayout(new BorderLayout());
    horizontalLimit.add(_messageInputPane.getComponent());
    inputScrollPane.getViewport().add(horizontalLimit);

    JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, _listScrollPane, inputScrollPane);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));

    split.setOpaque(false);
    split.setDividerLocation((int) (getHeight() * 0.68));
    split.setDividerSize(3);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    _shoutsList.setBorder(new EmptyBorder(0, 0, 0, 0));
    _messageInputPane.getComponent().setBorder(new EmptyBorder(0, 0, 0, 0));

    _shoutsList.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            _shoutsList.setEditable(false);
          }

          @Override
          public void focusLost(FocusEvent e) {
            _shoutsList.setEditable(true);
          }
        });
  }
コード例 #2
0
  private void setGridBagLayout() {
    Container contentPane = getContentPane();
    contentPane.setLayout(new GridBagLayout());

    contentPane.add(
        _nicknameLb,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 5),
            0,
            0));

    contentPane.add(
        _nicknameTF.getComponent(),
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 0, 0, 5),
            0,
            0));

    contentPane.add(
        _sealLb,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 5),
            0,
            0));

    contentPane.add(
        _sealScroll,
        new GridBagConstraints(
            0,
            2,
            5,
            1,
            0.5,
            0.5,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));

    contentPane.add(
        _inetAddressesPanel,
        new GridBagConstraints(
            0,
            3,
            2,
            1,
            1.0,
            0.2,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));

    contentPane.add(
        _friendsLb,
        new GridBagConstraints(
            0,
            3,
            2,
            1,
            1.0,
            0.2,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));

    contentPane.add(
        _friendsCb,
        new GridBagConstraints(
            0,
            3,
            2,
            1,
            1.0,
            0.2,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));

    contentPane.add(
        _acceptFriendBt,
        new GridBagConstraints(
            0,
            3,
            2,
            1,
            1.0,
            0.2,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));

    _inetAddressesPanel.setLayout(new GridBagLayout());
    _inetAddressesPanel.add(
        _inetAddressesScroll,
        new GridBagConstraints(
            0,
            1,
            12,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));

    _inetAddressesPanel.add(
        _hostLb,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 5),
            0,
            0));

    _inetAddressesPanel.add(
        _hostTF,
        new GridBagConstraints(
            1,
            2,
            7,
            1,
            2.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    _inetAddressesPanel.add(
        _portLb,
        new GridBagConstraints(
            9,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 5, 5),
            0,
            0));

    _inetAddressesPanel.add(
        _portTF,
        new GridBagConstraints(
            10,
            2,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 5),
            0,
            0));

    _inetAddressesPanel.add(
        _newBt,
        new GridBagConstraints(
            7,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));

    _inetAddressesPanel.add(
        _saveBt,
        new GridBagConstraints(
            8,
            4,
            3,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));

    _inetAddressesPanel.add(
        _deleteBt,
        new GridBagConstraints(
            11,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
  }