Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JFrame j = new JFrame("Janela");
- j.setSize(400,400);
- j.setLocationRelativeTo(j);
- j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- JPanel p = new JPanel();
- JLabel jLb1 = new JLabel("Digite algo: ");
- JLabel jLb2 = new JLabel("");
- JTextField jTx1 = new JTextField();
- jTx1.setPreferredSize(new Dimension( 200, 24 ));
- JButton jBt1=new JButton("Clique aqui");
- jBt1.setBounds(50,100,95,30);
- jBt1.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent ae)
- {
- String texto = jTx1.getText();
- jLb2.setText(texto);
- }
- });
- p.add(jLb1);
- p.add(jTx1);
- p.add(jBt1);
- p.add(jLb2);
- j.add(p);
- j.setVisible(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement