29
Mar
2019

How to implements Item Listener in java Frams

How to implements Item Listener in java Frams. Here you will learn that how can we implement implements Item Listener in java Frams using AWT classes. Here is a complete java program that will show you that how we can apply ItemListener in java.

You can say that this complied java program will teach you that how you can create a frame or window in java that is looking like you are are creating a paint window.
Its means that you are developing a program to create a paint programe after some changing.

How to implements Item Listener in java Frams

import java.awt.event.*;
import java.awt.*;
class myframe extends Frame implements ItemListener
{
    Checkbox redchk,greenchk;
     CheckboxGroup grp;
     TextField txt;
myframe()
{
   super(“Show the selected”);
   setBounds(100,100,500,500);
   setBackground(new Color(245,25,25));
   setLayout(null);
   addWindowListener(new WindowAdapter()
                              {
                 public void windowClosing(WindowEvent we)
                                {
                       System.exit(0);
                                 }
           });

grp=new CheckboxGroup();

redchk=new Checkbox(“red”,grp,true);
        redchk.setBounds(40,100,100,25);
         redchk.addItemListener(this);

        greenchk=new Checkbox(“green”,grp,false);
        greenchk.setBounds(40,150,100,25);
        greenchk.addItemListener(this);

          txt=new TextField(30);        
           txt.setBounds(40,190,200,30);

           setLayout(null);

         add(redchk);
          add(greenchk);
           add(txt);       
  setVisible(true);
}
   public void itemStateChanged(ItemEvent ie)
     {
         if (ie.getSource()==redchk)
          {
              txt.setText(“Red Selected (By Kaleem)”);
              }
          if(ie.getSource()==greenchk)
            {
                txt.setText(“Green Selected(By Kaleem)”);
               }
         }
 }

class sajjad
{
  public static void main(String str[])
{
   myframe f=new myframe();
  }
}

Here is also different java and asp.net programs like:

  1. How to connect java with database|Using JDBC-ODBC Connection string
  2. How to Create combo box in java|Complete Coding
  3. Java program to calculate Age from Date of birth
  4. How to create a Recruitment or job announcement page in asp.net | Complete front end designing and backend coding
  5. How to Add multiple textbox values and showing their sum
  6. Employee Registration form | Creation of Registration form in visual studio using c# and asp.net
  7. How add new webpage in a website using C#, asp.net in visual studio.
  8. How to create login page using asp.net and C#

You may also like...

2 Responses

  1. Manzoor Hussain says:

    You are doing a great job by sharing complied programs of java.
    thanks

Leave a Reply

Your email address will not be published. Required fields are marked *