google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.

Sunday, February 10, 2019

Java program for String operations in swing





JAVA PROGRAM FOR String Operations in swing:



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

/*<applet code="StrOp" width=400 height=400></applet>*/

public class StrOp extends JApplet implements ActionListener
{
        JTextField text5;
       JTextField text4;
        JTextField text3;
       JTextField text2;
        JTextField text1;
        public void init()
        {
                Container contentPane=getContentPane();
                contentPane.setLayout(new GridLayout(5,2,40,40));
                JLabel enter=new JLabel("Enter String:");
                contentPane.add(enter);
                text1=new JTextField();
                contentPane.add(text1);
                JButton lower=new JButton("LOWER");
                lower.addActionListener(this);
                contentPane.add(lower);
                text2=new JTextField();
                contentPane.add(text2);
                JButton upper=new JButton("UPPER");
                upper.addActionListener(this);
                contentPane.add(upper);
                text3=new JTextField();
                contentPane.add(text3);
                JButton italic=new JButton("ITALIC");
         
                 italic.addActionListener(this);
                contentPane.add(italic);
                text4=new JTextField();
                text4.setFont(new Font("TimesNewRoman",Font.ITALIC,12));
                contentPane.add(text4);
                JButton bold=new JButton("BOLD");
                bold.addActionListener(this);
                contentPane.add(bold);
                text5=new JTextField();
                text5.setFont(new Font("TimesNewRoman",Font.BOLD,12));
                contentPane.add(text5);
       }
       public void actionPerformed(ActionEvent e)
       {
                String str=text1.getText();
                if(e.getActionCommand()=="LOWER")
                        text2.setText(str.toLowerCase());
                else if(e.getActionCommand()=="UPPER")
                        text3.setText(str.toUpperCase());
                else if(e.getActionCommand()=="ITALIC")
                        text4.setText(str);
                else if(e.getActionCommand()=="BOLD")
                        text5.setText(str);
       }
}












*****************************************



OUTPUT
*****************************************

Enter String     :  vijay

Lower              :  vijay

Upper              :  VIJAY
Italic                :  vijay
Bold                :   vijay

Java Program for Inheritance




JAVA PROGRAM FOR INHERITANCE:




import java.io.*;
 class Base
 {
     int a,b;
     void get( )
     {
         InputStreamReader ip=new InputStreamReader(System.in);
         BufferedReader br=new BufferedReader(ip);
         String ap;
         try
         {
            System.out.println("Enter Value of A:");
            ap=br.readLine( );
            a=Integer.parseInt(ap);

            System.out.println("Enter Value of B:");
            ap=br.readLine( );
            b=Integer.parseInt(ap);
           }
          catch(Exception e)
          {
            System.out.println(e);
           }
        }
    }
 class Derived extends Base
 {
    void disMin( )
    {
       if(a<b)
        System.out.println("Minimum Value is A:"+a);
       else
        System.out.println("Minimum Value is B:"+b);
       }
    void disMax( )
    {
       if(a>b)
         System.out.println("Maximum Value is A:"+a);
       else
         System.out.println("Maximum Value is B:"+b);
       }
   }
 class Inheritance
 {
   public static void main(String args[])
   {
      Derived dd=new Derived( );
      dd.get( );
      dd.disMin( );
      dd.disMax( );
    }
 }


*****************************************


OUTPUT:

*****************************************      
C:\vijay\advjava\jdk1.4\bin>java Base

Enter Value of A:
232
Enter Value of B:
236

Minimum Value is A:232
Maximum Value is B:236

C:\vijay\advjava\jdk1.4\bin>








अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...