Tuesday, 14 February 2017

How to use text field in java jsp program




14 Text Field Demo In JAVA
Steps:
1.Copy program below in a text file.
2.Give File Name As "jtextfield.java"
3.Open This file Through Netbeans or JDK
4. Run File and check output.

//***************************Start*******************************

import javax.swing.*;
import java.awt.*;
public class jtextfield extends JFrame
{
 


  TextField t1,t2,t3,t4;

public jtextfield()
{
    Container c =getContentPane();
     c.setLayout(new FlowLayout());
   t1=new TextField();
   t2=new TextField("Enter here");
   t3=new TextField(20);
   t4=new TextField("Enter here",10);
  c.add(t1);
   c.add(t2);
   c.add(t3);
   c.add(t4);
   t3.setEchoChar('*');
   setSize(300,300);
    setVisible(true);
   
 
}
public static void main(String[] args)
{
       jtextfield jt=new jtextfield();
}
}

//*****************************End******************************





15. Toolbar Demo In JAVA
Steps:
1.Copy program below in a text file.
2.Give File Name As "jtoolbar.java"
3.Open This file Through Netbeans or JDK
4. Run File and check output.

//***************************Start*******************************
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class jtoolbar extends JFrame

{
JToolBar tb;
   public jtoolbar()
   {
    Container c = new Container();
        c.setLayout(new FlowLayout());
        tb=new JToolBar();
        tb.setFloatable(false);
        tb.add(new JButton("OK"));
        tb.add(new JButton("Cancel"));
        c.add(tb,"North");
        setSize(200,200);
        setVisible(true);
   }
    public static void main(String[] args) throws Exception
    {
        jtoolbar jt=new jtoolbar();
    }
 
}
//*****************************End******************************


16. List Demo In JAVA
Steps:
1.Copy program below in a text file.
2.Give File Name As "List.java"
3.Open This file Through Netbeans or JDK
4. Run File and check output.

//***************************Start*******************************
import javax.swing.*;
import java.awt.*;

public class list extends JFrame{
    JList l;
    public list()
    {
         Container c = getContentPane();
        c.setLayout(new FlowLayout());
        String n[] = {"linux", "java", "ns"};
        l=new JList(n);
        c.add(l);
             pack();
        setVisible(true);
    }
         
    public static void main(String arsg[]) {
        list obj = new list();
    }
}

//*****************************End******************************



17. Progress Bar Demo In JAVA
Steps:
1.Copy program below in a text file.
2.Give File Name As "progress_bar.java"
3.Open This file Through Netbeans or JDK
4. Run File and check output.

//***************************Start*******************************

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

public class progress_bar extends JFrame {

    JProgressBar pb;

    public progress_bar() {
        Container c = getContentPane();
        c.setLayout(new FlowLayout());
        pb = new JProgressBar(0, 100);
        //pb.setIndeterminate(true);
        pb.setStringPainted(true);
        pb.setBorderPainted(false);
        // pb.setString("Progress");
        c.add(pb);
        pack();
        setVisible(true);
        for (int i = 0; i <= 100; i = i + 5) {
            pb.setValue(i);
            try {
                Thread.sleep(1000);


            } catch (Exception e) {
                System.out.println(e);
            }
        }
    }

    public static void main(String arsg[]) throws Exception {
        new progress_bar();

    }
}

//*****************************End******************************

No comments:

Post a Comment

Welcome, happy learning

Charactor_At_Position

public class Char_At_Position { public static void main(String[] args) { String str = "Wankhede"; String rev=""...