Escolar Documentos
Profissional Documentos
Cultura Documentos
Final
Final
import java.awt.*;
import javax.swing.*;
public Tela(){
this.setSize(500, 250);
this.setTitle("Janela");
this.setLocation(400, 400);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
como usar o GridLayout, que organiza os dados em forma de grelha um ao lado e embaixo
tL = new JPanel();
tL.setLayout(new GridLayout(2,2));
tL.add(btn2);
Em seguida temos o border layout, organiza os componetes as bordas da janela
ctn.setLayout(new BorderLayout());
ctn.add(lbl3, BorderLayout.WEST);
ctn.add(lbl4, BorderLayout.EAST);
Temos o Flow layout que e responsavel por colocar lado a lado os componentes , muito usado para criar
menus superiores
bL.setLayout(new FlowLayout());
bL.add(ttf1);
bL.add(ttf2);
btn1.addActionListener(this);
btn2.addActionListener(this);
janela.setVisible(true);
if(e.getSource()==btn1){
JOptionPane.showMessageDialog(null, msg);
btn1.setBackground(new java.awt.Color(0,0,255));
btn2.setBackground(new java.awt.Color(0,191,255));
if(e.getSource()==btn2){
tL.setBackground(Color.yellow);
txtResultado.setText(string.valueOf(soma));