Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- public class Test1 extends JFrame implements ActionListener
- {
- JLabel lblfirstName, lblsurName, lbloutPut;
- JPanel pnlDetail, pnlSubmit;
- JTextField txtName, txtLastname;
- JButton btnRego;
- public Test1()
- {
- pnlDetail = new JPanel();
- pnlSubmit = new JPanel();
- lblfirstName = new JLabel("First name");
- txtName = new JTextField(30);
- pnlDetail.add(lblfirstName);
- pnlDetail.add(txtName);
- lblsurName = new JLabel("Last Name");
- txtLastname = new JTextField(30);
- pnlDetail.add(lblsurName);
- pnlDetail.add(txtLastname);
- btnRego = new JButton("Register");
- btnRego.addActionListener(this);
- pnlSubmit.add(btnRego);
- lbloutPut = new JLabel("");
- pnlSubmit.add(lbloutPut);
- add(pnlDetail, BorderLayout.CENTER);
- add(pnlSubmit, BorderLayout.SOUTH);
- setBounds(300, 300, 300, 300);
- setVisible(true);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- }
- public void actionPerformed(ActionEvent e)
- {
- if(e.getSource()==btnRego);
- name = txtName.getText();
- {
- lbloutPut.getText(name);
- }
- }
- public static void main(String args[])
- {
- new Test1();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement