Thursday, 4 May 2017

ActionListener Implementation in Swings

How to Implement ActionListener  in java:-

import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
public class action_lis extends Applet implements ActionListener
{
Button b=new Button("CHECKED IT OUT");
Button b1=new Button("PRINT");
public void init()
{
this.setLayout(null);
b.setBounds(300,300,120,70);
b1.setBounds(500,300,120,70);
add(b);
add(b1);
b.addActionListener(this);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ar)
{
if(ar.getSource()==b)
{
JOptionPane.showMessageDialog(null,"MY NAME IS BALWANT");
}
if(ar.getSource()==b1)
{
JOptionPane.showMessageDialog(null,"YOU HAVE BEEN PRINTING 100 PAGES");
}
}
}
Basically actionlistener is used  to trigger a particular event.
In this program i have created two buttons named as b and b1. Button b is named as CHECKED IT OUT and Button b1 named as PRINT . On clicking Button b it will open an dialog box which will show "MY NAME IS BALWANT".  On clicking Button b1 it will open an dialog box which will show  "YOU HAVE BEEN PRINTING 100 PAGES".

OUTPUT:

First it will show as given below:

How-to-implement-ActionListener-in-Swings-in-java

When You click CHECKED IT OUT it will show as given below:

How-to-implement-ActionListener-in-Swings-in-java


When you will click PRINT it will show as given below:

How-to-implement-ActionListener-in-Swings-in-java

You can check this link for how to do manipulation using swings.



Also you can check how to make Registration Form using Swings in java:


https://wingsofm.blogspot.in/2017/05/registration-form-using-swings-in-java.html

Oracle / PLSQL: FOR LOOP

set serveroutput on; declare a1 varchar2(100); begin select count(*) into a1 from employees; for i in 1..a1 loop dbms_output.put_line...