Design of java form

Ads
 

Design of java form

sir can u plz help me i want to design a interactive java form mins some thing diffrent in form is it possible in java if yes then help me

thank u

View Answers

December 22, 2010 at 5:30 PM

Hi Friend,

Yes, you can using java swing.

Try this:

import javax.swing.*;
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
class CreateAccount extends JFrame{
JTextField text1,text2,text3,text4,text5;
JPasswordField pass1;
JLabel label1,label2,label3,label4,label5,label6;
JButton button,button1;
CreateAccount() {
    setLayout(null);
text1=new JTextField(15);
text2=new JTextField(15);
text3=new JTextField(15);
pass1=new JPasswordField(15);
text4=new JTextField(15);
text5=new JTextField(15);
label1=new JLabel("First Name");
label2=new JLabel("Last Name");
label3=new JLabel("User Name");
label4=new JLabel("Password");
label5=new JLabel("Address");
label6=new JLabel("Phone No");
button=new JButton("Save");
button1=new JButton("Exit");

label1.setBounds(350,100,100,20);
text1.setBounds(450,100,200,20);
label2.setBounds(350,130,100,20);
text2.setBounds(450,130,200,20);
label3.setBounds(350,160,100,20);
text3.setBounds(450,160,200,20);
label4.setBounds(350,190,100,20);
pass1.setBounds(450,190,200,20);
label5.setBounds(350,220,100,20);
text4.setBounds(450,220,200,20);
label6.setBounds(350,250,100,20);
text5.setBounds(450,250,200,20);
button.setBounds(350,280,100,20);
button1.setBounds(450,280,100,20);

add(label1);
add(text1);
add(label2);
add(text2);
add(label3);
add(text3);
add(label4);
add(pass1);
add(label5);
add(text4);
add(label6);
add(text5);
add(button);
add(button1);
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String value1=text1.getText();
String value2=text2.getText();
String value3=text3.getText();
String value4=pass1.getText();
String value5=text4.getText();
String value6=text5.getText();

Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "root";
String user1="";
String pass1="";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db, user, pass);
Statement st = con.createStatement();
int i=st.executeUpdate("insert into login(firstname,lastname,username,password,address,contactno) values('"+value1+"','"+value2+"','"+value3+"','"+value4+"','"+value5+"','"+value6+"')");
JOptionPane.showMessageDialog(null,"Data is successfully saved.");
}
catch(Exception e){}
}
});
button1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
setVisible(false);
}
});
setSize(1024,768);
setVisible(true);
}
public static void main(String args[]){
    new CreateAccount();
}

}

Thanks

Ads









Related Tutorials/Questions & Answers:
How to design a form using java?
How to design a form using java?  Please help in designing of form using java for my project
Design of java form
Design of java form  sir can u plz help me i want to design a interactive java form mins some thing diffrent in form is it possible in java if yes then help me thank u   Hi Friend, Yes, you can using java swing
Advertisements
Java - Design concepts & design patterns
Java  Sir , please let me know the exact usage of DAO design pattern  Hi Friend, Please visit the following link: http://www.roseindia.net/javatutorials/J2EE_singleton_pattern.shtml Thanks
form to java script conversion
form to java script conversion  I am using a form one more form cotain a piece of code . how to convert it to java script to function it properly? code is shown below <form action="http://www.google.com" id="cse-search
Without Using Form in Java Script
Without Using Form in Java Script  HOw to Reset the data in javascript without using form tag
java login form using netbeans
java login form using netbeans  how to connect an access database to a login form using netbeans
why we use design patterns in java?Example?
why we use design patterns in java?Example?  Hi..... Why we use design patterns?,why they are needed in programming languages?,advantages?  ... for you http://www.roseindia.net/designpattern/design-patterns.shtml http
java code along wid graphics design
java code along wid graphics design  actually i want to design nd make an apllication to solve a rubics cube of 3*3.. i have an algos wid me bt jus need ur guidance..plzz hlp out or if u have ny other ideas do suggest
standart login form for messenger in java
standart login form for messenger in java  hi i need login from for chating messenger in java. but its structure would like this Home Register Login User ID Password   Hi Friend
standart login form for messenger in java
standart login form for messenger in java  hi i need login from for chating messenger in java. but its structure would like this Home Register Login User ID Password   Hi Friend
how to save a gui form in core java
how to save a gui form in core java  please help me i am java beginner how to save a jframe containing jtable and panels in java thank you
Java Model View Controller (MVC) Design Pattern
; margin-left: 400px; } .style4 { margin-left: 160px; } Java MVC ( Model View Controller ) Design Pattern Model View controller is a classical design... logic and view who represents data. MVC design pattern isolates
login form using java bean in eclipse
login form using java bean in eclipse  I have made a college community website but i need to implement beans to my login and contact us page. how can i do
form field mapping with pdf file using java
form field mapping with pdf file using java   Hai all, I have one requirement that i have one html form.i have to map the form fields with pdf file. means, if click on text field according that perticular field .the data
JSF security design problem - Java Server Faces Questions
JSF security design problem  Hi! I have to manage security (the quantity of roles and groups is rather huge) in java ee 5 + jsf (1.x) project without using mapping application roles to appserver roles in realms but using my own
How to create the program in Java for getting the forgotten Password Form?
How to create the program in Java for getting the forgotten Password Form?  Hi, Our enterprise application requires the development of a form... to the user on email address. How to create the program in Java for getting
Displatying java script form submitted elements in another page
Displatying java script form submitted elements in another page   hi I want java script and html code for displaying the values in other pager after submitting the registration form. I want to get the values after submitting
Display tow dimensional array by matrix form using one for loop in java
Display tow dimensional array by matrix form using one for loop in java  Display tow dimensional array by matrix form using one for loop in java
Login Form with Java GUI using Netbeans
Login Form with Java GUI using Netbeans  Hi there! I'm a beginner in Java. I've created 2 class files: 1) TestAssign.java 2) NewFrame.java How can I have different user to login? Now that I've only administrator who is able
how to update values of a html form into an excel table using java servlets?
how to update values of a html form into an excel table using java servlets?  i have written a java servlet program, which has a html form to be filled. after filling the form the servlet generates a receipt and the values should
how to load values of html form into an excel table using java servlet?
how to load values of html form into an excel table using java servlet?   i have written a java servlet program, which has a html form to be filled. after filling the form the servlet generates a receipt and the values should
how to prepare railway reservation form using core java concepts
how to prepare railway reservation form using core java concepts  write code for online railway reservation form: The following constraints are: a) Fix the no.of Tickets alloted for online reservation b) on each ticket booking
Using java script do login form having fields with condition.
Using java script do login form having fields with condition.  Need a login form with username, password, phone no, email id, date fields. We should specify the conditions for each field and if we press the submit button
Pass values from form to form
Pass values from form to form       Java program to pass values from one form to another form... used in to the different applications. Here in the JSP (Java Server Pages) we
How to Get currently running processes in a tabular form in java
How to Get currently running processes in a tabular form in java  I need to create a frame that shows all the current running processes in the system in a tabular form. i used Process proc = runtime.exec(cmds); but it only gives
Design pattern
Design pattern  explain factory pattern
Registration Form in HTML
Registration Form in HTML  User Registration Form in HTML - i wanted to design a user registration form in HTML. So, Can anyone please guide me or give me a peace of code to design a user registration form in HTML. Thanks
Design Patterns
Design Patterns  Explain the Factory Pattern, VO Pattern, DAO Pattern, and Singleton Pattern
DESIGN PATTERNS
DESIGN PATTERNS  How many instances will be created for single ton pattern in Cluster Environment
putting words to line number form a java file/test file and show occurrence
putting words to line number form a java file/test file and show occurrence  hi all i want putting words to line number form a java file and show... and BinarySearchTree and please help me in java coding
Form Validation
Form Validation  Java script validation for checking special characters and white spaces and give an alert.Please help me urgent Thanks in advance

Ads