How to create a textbox,Drop down,Button in java...............Bhanu, Tarun, Dinesh.........
import java.awt.*;
import javax.swing.*;
public class Textbox extends JFrame
{
public Textbox()
{
super("Frame1");
getContentPane().setLayout(new FlowLayout());
JLabel var1= new JLabel("Field1");
getContentPane().add(var1);
JTextField var2= new JTextField(10);
getContentPane().add(var2);
System.out.println("\n");
JLabel var3= new JLabel("Dropdown");
getContentPane().add(var3);
String[] a= {"bhanu","tarun","dinesh","satish","Phani"};
JComboBox var4=new JComboBox(a);
getContentPane().add(var4);
var4.setToolTipText(a[0]);
//var4.setToolTipText(a[1]);
JButton b=new JButton("Submit");
getContentPane().add(b);
b.setToolTipText("Bhanu");
b.setCursor(new Cursor(Cursor.HAND_CURSOR));
setSize(1024,640);
setVisible(true);
}
public static void main(String argv[])
{
new Textbox();
}
}
import java.awt.*;
import javax.swing.*;
public class Textbox extends JFrame
{
public Textbox()
{
super("Frame1");
getContentPane().setLayout(new FlowLayout());
JLabel var1= new JLabel("Field1");
getContentPane().add(var1);
JTextField var2= new JTextField(10);
getContentPane().add(var2);
System.out.println("\n");
JLabel var3= new JLabel("Dropdown");
getContentPane().add(var3);
String[] a= {"bhanu","tarun","dinesh","satish","Phani"};
JComboBox var4=new JComboBox(a);
getContentPane().add(var4);
var4.setToolTipText(a[0]);
//var4.setToolTipText(a[1]);
JButton b=new JButton("Submit");
getContentPane().add(b);
b.setToolTipText("Bhanu");
b.setCursor(new Cursor(Cursor.HAND_CURSOR));
setSize(1024,640);
setVisible(true);
}
public static void main(String argv[])
{
new Textbox();
}
}
Good....
ReplyDeleteExcellent.............
ReplyDeletenice keep it up...
ReplyDeleteUnable to understand, that would be better if comments are written.
ReplyDelete