Advertisement
fabioceep

JAVA: Layout de Fluxo 03 (PG 291)

Feb 22nd, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. package gerenciadoreslayout;
  2. import javax.swing.*;
  3. import java.awt.*;
  4.  
  5. public class GerenciadoresLayout {
  6.     public static void main(String[] args) {
  7.         GerenciadoresLayout sistema = new GerenciadoresLayout();
  8.         sistema.iniciar();
  9.     }
  10.     public void iniciar() {
  11.         JFrame janela = new JFrame();
  12.         JPanel painel = new JPanel();
  13.        
  14.         painel.setBackground(Color.darkGray);
  15.        
  16.         JButton east = new JButton("east");
  17.         JButton west = new JButton("west");
  18.         JButton north = new JButton("Nort");
  19.         JButton south = new JButton("South");
  20.         JButton center = new JButton("Center");
  21.         JButton center1 = new JButton("center1");
  22.        
  23.         janela.getContentPane().add(BorderLayout.CENTER, painel);
  24.         painel.add(center);
  25.         painel.add(center1);
  26.        
  27.         janela.getContentPane().add(BorderLayout.WEST, west);
  28.         janela.getContentPane().add(BorderLayout.NORTH, north);
  29.         janela.getContentPane().add(BorderLayout.SOUTH, south);
  30.         janela.getContentPane().add(BorderLayout.EAST, east);
  31.        
  32.         janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  33.         janela.setSize(200,200);
  34.         janela.setVisible(true);
  35.     }
  36.    
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement