Hi iam a beginner in Java i have written this code below but its doing what i want it to.
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package db; import java.awt.*; import java.awt.event.*; import javax.swing.*; public abstract class Example extends JFrame implements ActionListener{ public Example(){ Container con=getContentPane(); con.setLayout(new FlowLayout()); JLabel Myname=new JLabel ("Name"); JTextField TxtName=new JTextField(20); JLabel RegNumber=new JLabel ("Reg No."); JButton SaveButton= new JButton("Save"); con.add(Myname); con.add(TxtName); con.add(RegNumber); con.add(SaveButton); SaveButton.addActionListener(This); } public void actionPerformed(ActionEvent e, Object SaveButton) { Object Source=e.getSource(); if (Source==SaveButton) System.out.println("Thank You"); } public static void main(String[] args) { JFrame MyFrame=new JFrame ("Detela loves Java"); MyFrame.setVisible(true); } }
thank you