how to convert java fram to java servlets
hi every java master or java professional can you teach me how to convert JFram to Java Servlets program hope yours can reply me Thank you. below this is my own coding
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class AddressBook extends JFrame implements ActionListener{
public void frame(){
AddressBook panel = new AddressBook();
panel.setSize(330,350);
panel.setVisible(true);
panel.setResizable(false);
panel.setLocation(330,200);
}
JLabel lblId = new JLabel("ID Number : ",JLabel.RIGHT);
JLabel lblFName = new JLabel("First Name : ",JLabel.RIGHT);
JLabel lblAddress = new JLabel("Address : ",JLabel.RIGHT);
JLabel lblLName = new JLabel("Last Name : ",JLabel.RIGHT);
JLabel lblPNumber = new JLabel("Phone : ",JLabel.RIGHT);
JTextField txtId = new JTextField(20);
JTextField txtFName= new JTextField(20);
JTextField txtAddress= new JTextField(20);
JTextField txtLName = new JTextField(20);
JTextField txtPNumber = new JTextField(20);
JButton btnNew = new JButton(new ImageIcon("news.jpg"));
JButton btnUpdate = new JButton(new ImageIcon("update.jpg"));
JButton btnDelete = new JButton(new ImageIcon("delete.jpg"));
JButton btnSearch = new JButton(new ImageIcon("search.jpg"));
Connection cn;
Statement st;
PreparedStatement ps;
public void clear(){
txtId.setText("");
txtFName.setText("");
txtAddress.setText("");
txtLName.setText("");
txtPNumber.setText("");
}
public AddressBook() {
super("MY Electronic Address Book Application ");
JPanel pane = new JPanel();
pane.setLayout(null);
pane.setBackground(Color.pink);
lblId.setBounds(5,50,80,25);
pane.add(lblId);
txtId.setBounds(90,50,150,25);
pane.add(txtId);
lblFName.setBounds(5,85,80,25);
pane.add(lblFName);
txtFName.setBounds(90,85,150,25);
pane.add(txtFName);
lblLName.setBounds(5,120,80,25);
pane.add(lblLName);
txtLName.setBounds(90,120,150,25);
pane.add(txtLName);
lblPNumber.setBounds(5,155,80,25);
pane.add(lblPNumber);
txtPNumber.setBounds(90,155,150,25);
pane.add(txtPNumber);
lblAddress.setBounds(5,190,80,25);
pane.add(lblAddress);
txtAddress.setBounds(90,190,150,25);
pane.add(txtAddress);
btnNew.addActionListener(this);
btnNew.setBounds(5,255,75,35);
btnNew.setBackground(Color.white);
pane.add(btnNew);
btnNew.addActionListener(this);
btnUpdate.setBounds(80,255,75,35);
btnUpdate.setBackground(Color.white);
pane.add(btnUpdate);
btnUpdate.addActionListener(this);
btnDelete.setBounds(155,255,75,35);
btnDelete.setBackground(Color.white);
pane.add(btnDelete);
btnDelete.addActionListener(this);
btnSearch.setBounds(230,255,75,35);
btnSearch.setBackground(Color.white);
pane.add(btnSearch);
btnSearch.addActionListener(this);
setContentPane(pane);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pane.setBorder(BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), " Personal Information"));
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn = DriverManager.getConnection("jdbc:odbc:AddressBook ");
}catch(ClassNotFoundException e) {
System.err.println("Failed to load driver");
e.printStackTrace();
}catch(SQLException e){
System.err.println("Unable to connect");
e.printStackTrace();}
}
public void actionPerformed(ActionEvent e){
Object source = e.getSource();
if(source == btnNew){
try{
st= cn.createStatement();
ps=cn.prepareStatement("INSERT INTO PInfo " + " (IDN,FName,LName,PNumber,Address) " + " VALUES(?,?,?,?,?)");
ps.setString(1,txtId.getText());
ps.setString(2,txtFName.getText());
ps.setString(3,txtLName.getText());
ps.setString(4,txtPNumber.getText());
ps.setString(5,txtAddress.getText());
ps.executeUpdate();
JOptionPane.showMessageDialog(null,"New record has been successfully added.","Suspect sample program",JOptionPane.INFORMATION_MESSAGE);
txtId.requestFocus(true);
st.close();
clear();
}catch(SQLException sqlEx){
System.out.println(sqlEx.getMessage());}}
if(source == btnSearch){
try{
st= cn.createStatement();
int id=0;
String search;
clear();
search=JOptionPane.showInputDialog(null,"Search Id Number","Find What?",JOptionPane.PLAIN_MESSAGE);
ResultSet rs=st.executeQuery("SELECT * FROM PInfo WHERE IDN = '" + search + "'");
while(rs.next()){
txtId.setText(rs.getString(1));
txtFName.setText(rs.getString(2));
txtLName.setText(rs.getString(3));
txtPNumber.setText(rs.getString(4));
txtAddress.setText(rs.getString(5));
id=Integer.parseInt(rs.getString(1));
}
if(id==0){
JOptionPane.showMessageDialog(null,"No record found!.","Suspect sample program",JOptionPane.ERROR_MESSAGE);
clear();
txtId.requestFocus(true);
}st.close();
}catch(SQLException s){}}
if(source == btnUpdate){
try{
st= cn.createStatement();
ps = cn.prepareStatement("UPDATE PInfo SET IDN = '" + txtId.getText() + "',FName = '" + txtFName.getText() + "',LName = '" + txtLName.getText() + "',PNumber = '" + txtPNumber.getText() + "',Address = '"+ txtAddress.getText() + "'WHERE IDN = '" + txtId.getText() + "'");
ps.executeUpdate();
JOptionPane.showMessageDialog(null,"record has been successfully updated.","Suspect sample program",JOptionPane.INFORMATION_MESSAGE);
txtId.requestFocus(true);
clear();
st.close();
}catch (Exception y){
y.printStackTrace();}}
if(source==btnDelete){
try{
ps = cn.prepareStatement("DELETE FROM PInfo WHERE IDN ='"+ txtId.getText() + "'");
ps.executeUpdate();
JOptionPane.showMessageDialog(null,"record has been successfully deleted.","Suspect sample program",JOptionPane.INFORMATION_MESSAGE);
txtId.requestFocus(true);
clear();
st.close();
}catch(SQLException s){
System.out.print("SQL statement is not executed!");}
catch(Exception j){
j.printStackTrace();
}
}
}
public static void main(String[] args) {
AddressBook s1=new AddressBook();
s1.setSize(330,350);
s1.setLocation(330,200);
s1.setResizable(true);
s1.setVisible(true);
}
}
View Answers
Related Tutorials/Questions & Answers:
how to convert java fram to java servlets how to
convert java fram to
java servlets hi every
java master or
java professional can you teach me
how to
convert JFram to
Java Servlets program hope yours can reply me Thank you. below this is my own coding
import
java servletsjava servlets please help...
how to connect
java servlets with mysql
i am using apache tomcat 5.5
Advertisements
how to convert string to image in javahow to
convert string to image in java
how to
convert string to image in
java? I know we need to
convert image to a byte array at some point in my application but do not know
how to
convert a image into byte string. Please
How to convert Collection to Array in Java?How to
convert Collection to Array in
Java? Hello,
I have a collection object in data with data in it.
How to
convert Collection to Array in
Java...("This ");
Above code create a collection and then add an item to it.
Now to
convert how to convert string to double in javahow to
convert string to double in java Hi,
I have String variable with double value in it.
how to
convert string to double in
java?
Thanks
... to
convert a String into double.
Here is full example code:
package net.roseindia
how to convert string to double in javahow to
convert string to double in java Hi,
I have String variable with double value in it.
how to
convert string to double in
java?
Thanks
... to
convert a String into double.
Here is full example code:
package net.roseindia
how to convert string to double in javahow to
convert string to double in java Hi,
I have String variable with double value in it.
how to
convert string to double in
java?
Thanks
... to
convert a String into double.
Here is full example code:
package net.roseindia
how to convert string to double in javahow to
convert string to double in java Hi,
I have String variable with double value in it.
how to
convert string to double in
java?
Thanks
... to
convert a String into double.
Here is full example code:
package net.roseindia
How to Convert array to list in JavaHow to
Convert array to list in Java Hi,
I have object of array in
Java and I want to
convert it to list.
How to
Convert array to list in
Java... ArrayList to list in
Java.
(adsbygoogle = window.adsbygoogle || []).push
How to convert String to int in Java into the int variable.
How to
convert String to int in
Java?
Thanks
Hi,
In
Java you can
convert String to in with the help of following two functions...
How to
convert String to int in Java Hi,
I have String with int
How to convert String to int in Java into the int variable.
How to
convert String to int in
Java?
Thanks
Hi,
In
Java you can
convert String to in with the help of following two functions...
How to
convert String to int in Java Hi,
I have String with int
How to convert String to int in Java into the int variable.
How to
convert String to int in
Java?
Thanks
Hi,
In
Java you can
convert String to in with the help of following two functions...
How to
convert String to int in Java Hi,
I have String with int
How to convert String to int in Java into the int variable.
How to
convert String to int in
Java?
Thanks
Hi,
In
Java you can
convert String to in with the help of following two functions...
How to
convert String to int in Java Hi,
I have String with int
How to convert date to string in Java?How to
convert date to string in
Java? Hello developers,
I have java.util.Date object and it has to be converted to date format.
How to
convert date to string in
Java?
Thanks
Hi,
To
convert java.util.Date object
How to convert map to json in JavaHow to
convert map to json in Java Hi,
I my program I have an object of HashMap and I have to output this into json string.
How to
convert map to json in
Java?
Thanks
Hi,
You have to use the Google Gson library
How to convert map to json in JavaHow to
convert map to json in Java Hi,
I my program I have an object of HashMap and I have to output this into json string.
How to
convert map to json in
Java?
Thanks
Hi,
You have to use the Google Gson library
How to convert this Java code into GUI?How to
convert this
Java code into GUI? import java.util.Scanner;
public class StudentMarks {
double totalMarks;
String grade;
public void setTotalMarks(double totalMarks) {
this.totalMarks = totalMarks
Java ServletsJava Servlets If the binary data is posted by both doGet and doPost then which one is efficient?Please give me some example by using both doGet and doPost.
Thanks in Advance
The doPost method is more efficient
servlets - Java Beginners to respond to HTTP requests.
A JSP layered on top of
Java Servlets. Whereas...servlets what is the difference b/w
servlets and JSP,
what
servlets engine DO?
why we
convert jsp to servlet engine code in web server?
servlets - Java Beginnersservlets I am doing small project in
java on
servlets. I want to generate reports on webpage ,
how is it possible and what is the difference between dynamic pages & reports ? tell me very urgent pls,pls
java servlets - Java Beginnersjava servlets hai my question is on xml documentation in creation of a
java servlets.
whether we have to create for each and every servelet we have to create each xml documentation? Hi friends
Exactly what you
Servlets - Java BeginnersServlets Hi,
How can i run the servlet programon my system?
I wrote the code in
java.(I've taken the Helloworld program as example program... for this web.xml file?
How to run this program? Hi friend
How to convert Arraylist into String Array JavaHow to
convert Arraylist into String Array Java Hi,
I am beginners of
Java programming. Can somebody Suggest me
how to
convert arraylist to string... information with example. You can find the online example of
how to
convert arraylist
How to Convert PDF into rtf File JavaHow to
Convert PDF into rtf File Java Hi,
How could in covert the PDF file to rtf file in
Java Programming. Please suggest any online example... the online example of
Java Convert PDF into rtf File.
Thanks
how to convert string to char array in Javahow to
convert string to char array in Java Hi,
I have a string in
Java which has to be converted to char array. What are the options to
convert String object to char Array in
Java?
how to
convert string to char array
How to convert date to UTC format in Java?How to
convert date to UTC format in
Java? Hi,
What is UTC Date format and
How to
convert date to UTC format in
Java?
I need simple to learn... of world.
You can use
Java program to
convert the date in UTC String
how to convert java Applet to Jave Framehow to
convert java Applet to Jave Frame hi every
java master or
Java Professional my name is vincent i'm
java beginners hope u all can ,tech me
how to
convert Java Applet to Jave Frame below this code is my applet source code
GUI and how to convert a distance - Java BeginnersGUI and
how to
convert a distance i need help..
how to create a GUI application that can be is used to
convert a distance unit in miles into its... JLabel("In Inches");
l5=new JLabel("In CM");
b=new JButton("
Convert Use Java Bean In ServletsUse
Java Bean In
Servlets
In this you will learn
how to use
Java Bean in
Servlets. For this purpose, we have created a Bean named 'Person' and defined three variables with their setters and getters. Then we have created an object
How to convert binary to decimal in Java?
How to
convert binary to decimal in
Java program?
In this section we are going to
convert a binary
number to it decimal representation... the
function
to
convert the integer data into the binary to decimal.
Here is the code
java servlets jdbc - JDBCjava servlets jdbc i am running the servlet program with jdbc connections
in this porgram i used two 'esultset' objects.. in this wat ever coding is available in the first resultset is executed like updating and retrieiving
java Servlets - JSP-Servletjava Servlets Hi
i am having a doubt regarding
servlets as i am in learning stage give me any clew
how to retrive data from mysql database after... not getting any idea
how to add that data which came from mysql data to text box
servlets deploying - Java Beginnersservlets deploying
how to deploy the
servlets using tomcat?can you...);
}
}
------------------------------------------------------- This is
servlets....
http://www.roseindia.net/
servlets
Thanks
Amardeep
servlets - Java Interview Questions html and processing in
servlets and store in DB like ORACLE. And next i want to retrieve this image into web page using
servlets.
please try to send the answer to me
servlets. i was not strong otherthan this. so please send me answer using
servlets bulk - Java Beginnersservlets bulk Hi,
My problem is " i want to send a one mail to many persons(i.e.,same mail to many persons) using
servlets".
Pls help me. Hi Friend,
Please visit the following links:
http
servlets mails - Java Beginnersservlets mails Hi,
My problem is " i want to send a one mail to many persons(i.e.,same mail to many persons) using
servlets".
Pls help me. Hi Friend,
Please visit the following links:
http
java servlets with database interactionjava servlets with database interaction hai friends i am doing a web application in that i have a registration page, after successfully registered... "not enough values" can you please assist
how to get rid of this problem what problem
servlets - Java Beginnersservlets
Q:
i write program to upload image into perticular folder.but i want to store that path into database but not image and display that image in page from the db.pls any one send me code for that in
servlets asap.pls
servlets - Java Beginnersservlets Hello! am doin my servlet course at niit,
i want know in detail methods of
servlets,and where can we implement it i.e. i want to know the examples of the methods used in it.
what is getInParameter(); does.please
Servlets - Java Interview Questions and
are available to all the
servlets within that application.
It represents your web... are specified for a particular servlet and are unknown to other
servlets... information visit to :
http://www.roseindia.net/
servlets/ServletContext.shtml