import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class SwingIO extends JFrame {
    private final JTextArea output = new JTextArea(10, 30);
    private final JTextField input = new JTextField(30);
    private final JButton send = new JButton("Send");

    public SwingIO() {
        super("IO Interface");
        output.setEditable(false);
        JScrollPane scroll = new JScrollPane(output);

        send.addActionListener(e -> {
            String text = input.getText();
            if (!text.isBlank()) {
                output.append(text + "\n");
                input.setText("");
            }
        });

        JPanel panel = new JPanel(new BorderLayout());
        panel.add(input, BorderLayout.CENTER);
        panel.add(send, BorderLayout.EAST);

        setLayout(new BorderLayout());
        add(scroll, BorderLayout.CENTER);
        add(panel, BorderLayout.SOUTH);
        pack();
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
        setVisible(true);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(SwingIO::new);
    }
}
