Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.event.*;
- import javax.swing.*;
- public class ClassDesign {
- public static void main(String[] args) {
- JFrame janela = new JFrame("Exemplo de botão");
- final JTextField campo = new JTextField();
- campo.setBounds(50, 50, 150, 20);
- JButton botao = new JButton("Clique Aqui");
- botao.addActionListener(
- new
- ActionListener() {
- public void actionPerformed(ActionEvent e) {
- campo.setText("Alô");
- }
- }
- );
- botao.setBounds(50, 100, 135, 30);
- janela.getContentPane().add(botao);
- janela.getContentPane().add(campo);
- janela.setSize(400, 400);
- janela.getContentPane().setLayout(null);
- janela.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement