Saturday, 7 September 2013

Swings example in java



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

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;


public class QuitButtonExample extends JFrame {

    public QuitButtonExample() {
       
        initUI();
    }

    private void initUI() {

       JPanel panel = new JPanel();
       getContentPane().add(panel);

       panel.setLayout(null);

       JButton quitButton = new JButton("Quit");
       quitButton.setBounds(50, 60, 80, 30);
      
       quitButton.addActionListener(new ActionListener() {
           @Override
           public void actionPerformed(ActionEvent event) {
               System.exit(0);
          }
       });

       panel.add(quitButton);

       setTitle("Quit button");
       setSize(300, 200);
       setLocationRelativeTo(null);
       setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
       
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                QuitButtonExample ex = new QuitButtonExample();
                ex.setVisible(true);
            }
        });
    }
}

Thursday, 29 August 2013

HOW TO USE STATIC KEYWORD AS METHOD AND VARIABLE

class student
{
      int rollno;
      String name;
     static String college="GROW MORE";
       student(int r,String n)
       {
        rollno=r;
        name=n;
        }
       static void change()
        {
         college="VN";
        }
       void display()
        {
       
           System.out.println(rollno+" "+name+" "+college);
         }
     public static void main(String Dx[])
     {    
            change();
           

             student s1=new student(111,"KARMA");
             student s2=new student(222,"NIRAV");
           
         
             s1.display();
             s2.display();    
    }

}

STATIC BLOCK PRINT INT JAVA

class static_check
{
      static
      {
                   System.out.println("Static block invoked");  
        } 
 

     public static void main(String Dx[])
     {
          
            System.out.println("Hello, Main method is invoked");

     }

}

HOW TO PRINT A TO Z CHAR BY FOR LOOP

class atoz
{
    public static void main(String Dx[])
     {
            char ch;
         for(ch='A';ch<='Z';ch++)
        {
            System.out.println("  "+ch);
         }
     }

}

Thursday, 8 August 2013

hello print in java

class tmp
{

public static void main(String dx[])
  {
    System.out.println("Hello");  
   }
}

Friday, 19 April 2013

SIMPLE DATE AND TIME FUNCTION IN C++

     /*
     THIS PROGRAMM DISPLAY DATE AND TIME
     */
     #include <iostream.h>
     #include <time.h>
     #include<conio.h>
     void main( )
     {
      int i=0;
      char dateStr [9];
      char timeStr [9];
      for(i=0;;i++)
      {
        clrscr();

        // FATCH DATE USING BELOW FUNCTION
         _strdate( dateStr);
        cout<<"\n\t\tDATE::"<<dateStr;

        // FATCH TIME USING BELOW FUNCTION

        _strtime( timeStr );
       cout<<"\n\t\tTIME::"<<timeStr;
       }
       getch();
      }

- OPERATOR LOADING IN C++

/*
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :::: THIS PROGRAMM EXPLAIN THE CONCEPT OF OPERATOR OVERLOADING  ::::
    :::: IN C++ PROGRAMM DEVLOPED BY DX PANCHAL AT MCA LAB          ::::
    :::: ON DATED 18/04/2013                                        ::::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

*/
//HEADER FILES DECLARATION
#include<iostream.h>
#include<conio.h>

//BEGIN CLASS DECLARATION
class temp
{
   int a,b,ans;

  public:
     void getdata(int x,int y)
     {
       a=x;b=y;

     };
     void display()
     {

      cout<<"\n\t\tVALUE OF A=>"<<a<<"B=>"<<b;

     };
     void operator-();



};
void temp::operator-()
{
  a=-a;b=-b;

};
//END OF TEMP CLASS

//MAIN FUNCTION MAIN
void main()
{
 clrscr();

 temp t;
 t.getdata(10,20);
 cout<<"\n\n\t\tDEACTIVE OPERATOR ::> ";
    t.display();
 cout<<"\n\n\t\tACTIVE OPERATOR ::> ";
    -t;

    t.display();



 getch();
}

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...