private void init() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    setOpaque(false);

    JLabel label = new JLabel("Text");
    label.setAlignmentX(Component.CENTER_ALIGNMENT);
    label.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
    add(label);

    final JTextPane textPane = new JTextPane();
    JScrollPane scrollPane = new JScrollPane(textPane);
    scrollPane.setMaximumSize(new Dimension(250, 100));
    scrollPane.setPreferredSize(new Dimension(250, 100));
    scrollPane.setAlignmentX(Component.CENTER_ALIGNMENT);
    add(scrollPane);

    textPane.setText(customGraphics.getText());

    textPane.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent e) {
            customGraphics.setText(textPane.getText());
          }
        });
  }
Ejemplo n.º 2
0
  public static void main(String[] args) {

    BuildMainWindow();
    Initialize();

    tpConversation.addFocusListener(
        new FocusListener() {

          @Override
          public void focusLost(FocusEvent e) {
            tpConversation.setEditable(true);
          }

          @Override
          public void focusGained(FocusEvent e) {
            tpConversation.setEditable(false);
          }
        });
  }
Ejemplo n.º 3
0
  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);
          }
        });
  }