Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Test extends JFrame {
- private JButton btn;
- private JPanel painel;
- private JScrollPane scroll;
- private JTextArea tArea;
- public Test() {
- btn = new JButton("Sair");
- btn.setPreferredSize(new Dimension(72, 35));
- btn.addActionListener(e -> System.exit(0));
- painel = new JPanel();
- painel.add(btn, FlowLayout.LEFT); //nao funciona
- JScrollPane scroll = new JScrollPane(tArea = new JTextArea());
- scroll.setPreferredSize(new Dimension(400, 300));
- scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- Container cp = getContentPane();
- cp.add(painel, "North");
- cp.add(scroll, "Center");
- getRootPane().setDefaultButton(btn);
- setSize(400, 280);
- setLocationRelativeTo(null);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- }
- public static void main(String[] args) {
- new Test().setVisible(true);
- }
- }
- painel = new JPanel();
- FlowLayout layout = (FlowLayout) painel.getLayout();
- layout.setAlignment(FlowLayout.LEFT);
- painel.add(btn);
- ((FlowLayout)painel.getLayout()).setAlignment(FlowLayout.LEFT);
- painel = new JPanel(new FlowLayout(FlowLayout.LEFT));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement