Created
August 31, 2012 17:49
-
-
Save ProgDan/3556444 to your computer and use it in GitHub Desktop.
Exemplo: FlowLayout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.awt.*; | |
| import javax.swing.*; | |
| public class MinhaJanela extends JPanel { | |
| public MinhaJanela(){ | |
| /* Conjunto de linhas (alinhamento à esquerda) */ | |
| //FlowLayout fluxo = new FlowLayout(); | |
| /* Conjunto de linhas (alinhamento à direita) */ | |
| //FlowLayout fluxo = new FlowLayout(FlowLayout.LEFT); | |
| /* Conjunto de linhas (alinhamento centralizado, | |
| com espaçamento entre os componentes */ | |
| FlowLayout fluxo = new FlowLayout(FlowLayout.CENTER, 5, 15); | |
| setLayout(fluxo); | |
| JButton btn; | |
| for(int i=0; i<20; i++){ | |
| btn = new JButton("Botao "+(i+1)); | |
| add(btn); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.awt.*; | |
| import javax.swing.*; | |
| public class Principal extends JFrame { | |
| public Principal() { | |
| super("Minha Janela"); | |
| setSize(400, 300); | |
| Container c = getContentPane(); | |
| MinhaJanela janela = new MinhaJanela(); | |
| c.add(janela); | |
| setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
| setVisible(true); | |
| } | |
| public static void main(String[] args) { | |
| new Principal(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment