473,387 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to validate textfield for the following program?

Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import javax.swing.*;
  3. import java.applet.*;
  4. import java.awt.event.*;
  5. public class stud2 extends JFrame implements ActionListener
  6. {JRadioButton rb1,rb2,rb3,rb4;  
  7. JButton b1,b2;
  8.  
  9.   Label l1=new Label("Name :",Label.LEFT);
  10.   Label l2=new Label("Age :",Label.LEFT);
  11.   Label l3=new Label("Gender :",Label.LEFT);
  12.   Label l4=new Label("Address :",Label.LEFT);
  13.   Label l8=new Label("Network :",Label.LEFT);
  14.   Label l5=new Label("simcard amnt :",Label.LEFT);
  15.   Label l6=new Label("Pincode :",Label.LEFT);
  16.   Label l7=new Label("Alternate PH.No :",Label.LEFT);
  17.   TextField t1=new TextField();
  18. TextField t5=new TextField();
  19.   Choice c1=new Choice();
  20.   CheckboxGroup cbg=new CheckboxGroup();
  21.   Checkbox ck1=new Checkbox("Male",false,cbg);
  22.   Checkbox ck2=new Checkbox("Female",false,cbg);
  23.   ButtonGroup bg=new ButtonGroup(); 
  24.   TextArea t2=new TextArea("",180,90,TextArea.SCROLLBARS_VERTICAL_ONLY);
  25.   Choice serpro=new Choice();
  26.   TextField t3=new TextField();
  27.   TextField t4=new TextField();
  28. public stud2()
  29.  {
  30.   setBackground(Color.white);
  31.   setForeground(Color.black);
  32.   setLayout(null);
  33. rb1=new JRadioButton("AIRTEL");
  34. rb2=new JRadioButton("VODAFONE");
  35. rb3=new JRadioButton("DOCOMO");
  36. rb4=new JRadioButton("AIRCEL"); 
  37. b1=new JButton("Next"); 
  38. b2=new JButton("personl details");;
  39. add(rb1);
  40. add(rb2);
  41. add(rb3);
  42. add(rb4);
  43. add(b1); 
  44. add(b2);
  45. bg.add(rb1);
  46. bg.add(rb2); 
  47. bg.add(rb3);
  48. bg.add(rb4);
  49.  
  50.   add(l1);
  51.   add(l2);
  52.   add(l3);
  53.   add(l4);
  54.   add(l5);
  55.   add(l6);
  56.   add(l7);
  57.   add(l8);
  58.   add(t1);
  59.   add(t2);
  60.   add(ck1);
  61.   add(ck2);
  62.   add(serpro);
  63.   add(t3);
  64.   add(t4);
  65.   add(t5);
  66.   serpro.add("RS.50");
  67.   serpro.add("RS.75");
  68.   serpro.add("RS.100");
  69.  serpro.add("RS.125");
  70.  serpro.add("RS.150");
  71.  
  72.  
  73.   l1.setBounds(25,100,100,20);
  74.   l2.setBounds(25,150,100,20);
  75.   l3.setBounds(25,200,100,20);
  76.   l4.setBounds(25,250,100,20);
  77.   l6.setBounds(25,350,100,20);
  78.   l8.setBounds(25,400,100,20); 
  79.   l5.setBounds(25,450,100,20);
  80.   l7.setBounds(25,525,100,20);
  81.  
  82.   t1.setBounds(140,100,170,20);
  83.   t5.setBounds(140,150,30,20);
  84.   ck1.setBounds(140,200,50,20);
  85.   ck2.setBounds(190,200,80,20);
  86.   t2.setBounds(140,250,170,60);
  87.   t3.setBounds(140,350,90,20);
  88.   rb1.setBounds(140,400,70,30);  
  89.   rb2.setBounds(210,400,95,30);
  90.   rb3.setBounds(305,400,90,30);
  91.   rb4.setBounds(395,400,100,30);
  92.   serpro.setBounds(140,450,100,20);
  93.   t4.setBounds(140,525,90,20);
  94.   b1.setBounds(160,600,70,30);
  95. b2.setBounds(0,0,1500,30);
  96.   b1.addActionListener(this); 
  97.  setSize(new Dimension(500,700));
  98.  setTitle("Simcard application form");
  99.  setVisible(true);
  100. }
  101.  
  102. public void actionPerformed(ActionEvent e){  
  103. if(rb1.isSelected()){  
  104. JOptionPane.showMessageDialog(this,"Thanks for choosing Airtel.Your simcard will be dispatched within a week. Your ID proof and simcard amount will be collected on delivery of your simcard");  
  105. }  
  106. if(rb2.isSelected()){  
  107. JOptionPane.showMessageDialog(this,"Thanks for choosing Vodafone.Your simcard will be dispatched within a week. Your ID proof and simcard amount will be collected on delivery of your simcard");  
  108. }  
  109. if(rb3.isSelected()){  
  110. JOptionPane.showMessageDialog(this,"Thanks for choosing Docomo.Your simcard will be dispatched within a week. Your ID proof and simcard amount will be collected on delivery of your simcard");  
  111. }  
  112. if(rb4.isSelected()){  
  113. JOptionPane.showMessageDialog(this,"Thanks for choosing Aircel.Your simcard will be dispatched within a week. Your ID proof and simcard amount will be collected on delivery of your simcard");  
  114. }  
  115. }  
  116.  
  117. public static void main(String g[])
  118. {new stud2();
  119.  
  120. }
  121. }
Aug 2 '14 #1
0 1163

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: PengYu.UT | last post by:
Hi, I run into error with the following program. Would you please help me? Best wishes, Peng struct tag1{}; struct tag2{};
2
by: mikelinyoho | last post by:
Does the following program architecture make sense? #include <stdio.h> #include "test1.c" #include "sample.cpp" int main(void){ output();
6
by: AndyL | last post by:
Hi, What would by a python equivalent of following shell program: #!/bin/sh prog1 > file1 & prog2 > file2 &
10
by: sunny | last post by:
Does this following program implement the factory design.if not what are things that i have to change in order to make this following program to be designed to factory design pattern. ...
1
by: saurabhswati722 | last post by:
My Urgent question : How to validate textfield using Javascript in PHP?
5
by: jmurphy | last post by:
What do i add to this script to validate the entry? Thanks in advance for the help. <form name="continue" method="POST" action="shipping1.asp" onsubmit="return validate_form ();"> <input...
2
by: vibhakhushi | last post by:
How to validate textfield values in extjs? For example validating email, checking password entry and all. Please help me out with this. Thanks in advance.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.