Teachers Day card in java

"As each child grows older, he/she needs to learn in order to survive; teachers are the ones to instill knowledge (DeRoy)." Therefore i have made a simple java program using Swings to wish all the teachers a very happy teachers Day.

Code Explaination

In this code there are 3 classes:
1.teacher class
2.Registration
3.WiishCard classes
The teacher class contains the main method, Registration class contain codes that allows user to register and the wiish class contains the wish for the teacher

Teacher Class

public class teacher 
  {

	  public static void main(String[] args) 
	{
		Registration R1 = new Registration();
		R1.Details();
	}

  }
  

Registration class

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

public class Registration extends JFrame
{
	private static final long serialVersionUID = -7614034343348966109L;
	Registration()
	{
		setVisible(true);
		setTitle("Register");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 570, 430);
		
	}
	JPanel cP;
	JLabel l1,L2,L3,L4;
	public JRadioButton r1,r2;
	JTextField t1,t2;
	JButton jb1;
	public void Details()
	{
		cP = new JPanel();
		cP.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(cP);
		cP.setLayout(null);
		
		l1 = new JLabel("REGISTER");
		l1.setForeground(Color.BLUE);
		l1.setFont(new Font("Times New Roman", Font.PLAIN, 30));
		l1.setBounds(170, 11, 170, 44);
		cP.add(l1);
				
		L2 = new JLabel("Tutor Name:");
		L2.setForeground(Color.BLUE);
		L2.setFont(new Font("Times New Roman", Font.PLAIN, 20));
		L2.setBounds(10, 152, 163, 44);
		cP.add(L2);
		
		L3 = new JLabel("Tutor Gender:");
		L3.setForeground(Color.BLUE);
		L3.setFont(new Font("Times New Roman", Font.PLAIN, 20));
		L3.setBounds(10, 207, 163, 44);
		cP.add(L3);
		
		L4 = new JLabel("Student Name:");
		L4.setForeground(Color.BLUE);
		L4.setFont(new Font("Times New Roman", Font.PLAIN, 20));
		L4.setBounds(10, 262, 163, 44);
		cP.add(L4);
		
		 r1 = new JRadioButton("Male");
		 r1.setFont(new Font("Times New Roman", Font.PLAIN, 20));
		 r1.setBounds(153, 220, 109, 23);
		 cP.add(r1);
		 
		 r2 = new JRadioButton("Female");
		 r2.setFont(new Font("Times New Roman", Font.PLAIN, 20));
		 r2.setBounds(296, 218, 109, 23);
		 cP.add(r2);
		
		 t1 = new JTextField();
		 t1.setBounds(153, 166, 219, 20);
		 cP.add(t1);
		 t1.setColumns(10);
		 
		 ButtonGroup bg = new ButtonGroup();
		 bg.add(r1);
		 bg.add(r2);
		 
		 jb1 = new JButton("WISH");
		 jb1.setFont(new Font("Times New Roman", Font.PLAIN, 15));
		 jb1.setBounds(193, 336, 109, 31);
		 cP.add(jb1);
		 jb1.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					wish();
					WiishCards n1 = new WiishCards();
					String a,b;
					if(r1.isSelected())
					{	
						 a= t1.getText();
						 a =  "Sir " + a;
					}
					else
					{
						a=t1.getText();
						a = "Madam " + a;
					}
					b = t2.getText();
					n1.wish(a,b);
				}

				private void wish() 
				{
					setVisible(false);
					
				}
			});
		 
		 t2 = new JTextField();
		 t2.setColumns(10);
		 t2.setBounds(153, 276, 219, 20);
		 cP.add(t2);
		
	}
}

WiishCard class

 import java.awt.Color;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class WiishCards extends JFrame 
{
	public WiishCards()
	{
		setVisible(true);
		setTitle("Wishing Cards");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 570, 430);
		
		
	}
	public void wish(String a, String b )
	{
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 570, 430);
		getContentPane().setLayout(null);
		
		
		JLabel l2= new JLabel("HAPPY TEACHERS DAY  ");
		l2.setFont(new Font("MV Boli", Font.PLAIN, 35));
		l2.setForeground(Color.BLUE);
		l2.setBounds(39, 24, 478, 47);
		getContentPane().add(l2);

		JLabel l1 = new JLabel();
		l1.setText(a);
		l1.setFont(new Font("Tempus Sans ITC", Font.BOLD | Font.ITALIC, 30));
		l1.setForeground(Color.BLUE);
		l1.setBounds(39, 82, 478, 38);
		getContentPane().add(l1);
		
		JLabel L3 = new JLabel("THANKYOU ");
		L3.setForeground(Color.GREEN);
		L3.setFont(new Font("Viner Hand ITC", Font.PLAIN, 26));
		L3.setBounds(177, 131, 166, 55);
		getContentPane().add(L3);
		
		JLabel l4= new JLabel("For teaching us efficiently even during hard times)");
		l4.setForeground(Color.MAGENTA);
		l4.setFont(new Font("Viner Hand ITC", Font.PLAIN, 17));
		l4.setBounds(20, 189, 434, 70);
		getContentPane().add(l4);
		
		JLabel l5 = new JLabel("it has been an honor to get to learn so many things from you");
		l5.setForeground(Color.MAGENTA);
		l5.setFont(new Font("Viner Hand ITC", Font.PLAIN, 17));
		l5.setBounds(26, 231, 505, 75);
		getContentPane().add(l5);
		
		JLabel l6 = new JLabel();
		l6.setText("Wish From: " + b);
		l6.setForeground(Color.GREEN);
		l6.setFont(new Font("Times New Roman", Font.PLAIN, 15));
		l6.setBounds(53, 317, 434, 63);
		getContentPane().add(l6);
		
		
	}
	
}

output






















Why We Should Let Youths Use Social Media




Social media is a very vital thing in this 21st century for many people. Facebook, WhatsApp, Messenger, WeChat, and Instagram are just some of the common social networking sites used by many people. Although some people say that social media is a boon in this digital era, still few consider it as a curse.

It is said that using too much social media can lead to breakup in their family, social media can bring a good deal of fake news if we don’t check the sources from where the news are being shared. However, one cannot deny the fact that social media is very helpful in today’s scenario. It helps us get news faster, make new friends and also useful for learning new things. Indeed, social media is a boon rather than a curse.


Research show that people who use social media frequently are more intelligent than those who don’t use social media frequently because social media is the fastest way of getting any information. Studies have also proven that social media and fake news are related, and reports indicate that approximately 35% of the information in social media is fake. Due to this fake news it usually creates chaos among the people. Although, the information in social media spreads like wildfire, one cannot deny the fact that about 65% of the information in social media are true. People argue that the 35% of the fake news will not affect the people but instead the 65% true news will help people learn new things explore the whole world and its culture, history, geographic conditions, via social media and hence increase knowledge.

So why not we let the youths use social media, as social media is not a curse but a boon in this digital era.





Make Registration form using only AWT

Java AWT (Abstract Window Toolkit) is an API to develop GUI in java.

it has many components like button, label, checkbox, etc. used as objects inside a Java Program.Java AWT components are platform-dependent which implies that they are displayed according to the view of the operating system. It is also heavyweight . java. awt package provides classes for AWT api.

In this program i have made a simple registration form with Awt as its major components and also used Swings combo box to get year of study.

In this program there are two classes : 1. Registration class which contains the main method and the details class which does the rest of the work

Output







Registration class

public class Registration 
{
	public static void main(String[] args) 
	{
		Details d1 = new Details();
		d1.Register();

	}
}

detailsClass

import java.awt.*;
import java.awt.event.*;
import javax.swing.JComboBox;


public class Details extends Frame implements ActionListener
{
	TextField t1;
	static JComboBox jc1;
	String[] s = new String[9]; 
	static Checkbox cb1,cb2;
	CheckboxGroup cbg;
	Button b;
	
	Details()
	{
		setVisible(true);
		setBounds(100,50,700,500);
		setTitle("Registration Form");
		setLayout(null);
		
		addWindowListener(new WindowAdapter()
		{
			public void windowClosing(WindowEvent e)
			{
				dispose();
			}
		});
	}
	void Register()
	{
		setLayout(null);
		Font f = new Font("Arial",Font.BOLD,20);
		Label l1 = new Label("Registration Form");
		l1.setBounds(250, 50, 400, 40);
		l1.setForeground(Color.BLUE);
		l1.setFont(f);
		Label l2 = new Label("Student_Id:");
		l2.setBounds(50, 100, 60, 20);
		t1 = new TextField();
		t1.setBounds(150, 100, 120, 20);
		Label l3 = new Label("Semester:");
		l3.setBounds(50, 150, 60, 20);
		for(int i=1; i<=8;i++)
		{
			s[i] = i+" semester";
		}
		jc1 = new JComboBox(s);
		jc1.setBounds(150, 150, 120, 20);
		Label l4 = new Label("Type:");
		l4.setBounds(50, 200, 60, 20);
		
		
		Label l5 = new Label("Type of study:");
		l5.setBounds(50, 210, 80, 20);
		cbg = new CheckboxGroup();
		cb1 = new Checkbox("GOVERNMENT",cbg,false);
		cb2 = new Checkbox("SELF",cbg,false);
		cb1.setBounds(140, 210, 100, 20);
		cb2.setBounds(240, 210, 100, 20);
		b = new Button("Register");
		b.setBounds(150, 250, 50, 20);
		b.addActionListener(this);
		

		add(l1);
		add(l2);
		add(t1);
		add(l3);
		add(jc1);
		add(l5);
		add(cb1);
		add(cb2);
		add(b);
				
	}
	@Override
	public void actionPerformed(ActionEvent e)
	{
		Label l = new Label("PRINTING DETAILS");
		l.setBounds(250, 300, 100, 30);
		l.setForeground(Color.BLUE);
		Label l2 = new Label();
		l2.setBounds(50, 320, 150, 30);
		Label l3 = new Label();
		l3.setBounds(50, 340, 180, 30);
		Label l4 = new Label();
		l4.setBounds(50, 360, 180, 30);
		Label l5 = new Label();
		l5.setBounds(50, 380, 180, 30);
		int student =Integer.parseInt(t1.getText());
		int fees = 0;
		String Sem = (String) jc1.getSelectedItem();
		
		if(cb1.getState()==true)
			{
			if(Sem.contains("1") || Sem.contains("2"))
					fees=100*2;
			if(Sem.contains("3") || Sem.contains("4"))
					fees=100*4;
			if(Sem.contains("5") || Sem.contains("6"))
					fees=100*6;
			if(Sem.contains("7") || Sem.contains("8"))
					fees=100*8;						
			}
		else if(cb2.getState()==true)
			{
			if(Sem.contains("1") || Sem.contains("2"))
					fees=50000*2;
			if(Sem.contains("3") || Sem.contains("4"))
					fees=40000*4;
			if(Sem.contains("5") || Sem.contains("6"))
					fees=30000*6;
			if(Sem.contains("7") || Sem.contains("8"))
					fees=20000*8;	
			}
			l2.setText("Student Number:" + student+" ");
			l3.setText("Type : Government Scholarship");
			l4.setText("Semester: " + Sem);
			l5.setText("Total Amount to be paid:" + fees);
			
			
			add(l);
			add(l2);
			add(l3);
			add(l4);
			add(l5);
		
	}
 }