Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
2.1 kB
1
Indexable
Never
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;

import static java.awt.BorderLayout.*;

public class Main {

    public static void main(String[] args) {
        SwingUtilities.invokeLater(
                ()->{

                    JFrame jFrame = new JFrame();
                    JPanel guziki = new JPanel();

                    guziki.setLayout(new BorderLayout());
                    jFrame.setLayout(new BorderLayout(2,2));

                    JTextArea text1 = new JTextArea("Abc");

                    JTextArea text2 = new JTextArea("Abc");

                    JScrollPane lewyTekst= new JScrollPane(text1);
                    lewyTekst.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
                    lewyTekst.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
                    lewyTekst.setPreferredSize(new Dimension(200,200));

                    JScrollPane prawyTekst= new JScrollPane(text2);
                    prawyTekst.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
                    prawyTekst.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
                    prawyTekst.setPreferredSize(new Dimension(200,200));

                    lewyTekst.setSize(100,100);

                    JButton but1 = new JButton("Click");
                    but1.setPreferredSize(new Dimension(200,30));
                    guziki.add(but1,LINE_START);

                    JButton but2 = new JButton("Click");
                    but2.setPreferredSize(new Dimension(200,30));
                    guziki.add(but2,LINE_END);

                    jFrame.add(lewyTekst,LINE_START);
                    jFrame.add(prawyTekst,LINE_END);
                    jFrame.add(guziki,SOUTH);

                    text1.setText(text1.getText()+"\nabc");


                    jFrame.setTitle("Program");
                    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    jFrame.setVisible(true);

                    jFrame.pack();

                }
        );
    }

}