convert java Application to Java Applet

convert java Application to Java Applet

hi every Java Master or Java Professional , my Name Is Vincent i'm java beginner can i ask a question regarding for Java application convert to Java Applet. below her is my sample application hope every master or professional can teaching me thank you.

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(320,350);
    panel.setVisible(true);
    panel.setResizable(false);
    panel.setLocation(320,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(320,350);
        s1.setLocation(320,200);
        s1.setResizable(true);
        s1.setVisible(true);
    }

 }
View Answers









Related Tutorials/Questions & Answers:
convert java Application to Java Applet
convert java Application to Java Applet  hi every Java Master or Java Professional , my Name Is Vincent i'm java beginner can i ask a question regarding for Java application convert to Java Applet. below her is my sample
java Application Convert to java Applet
java Application Convert to java Applet  Hi every Java Masters i'm Java beginner ,and i want below this figures source code convert to Java Applet hope every Masters can helping thank . import java.util.*; import java.text.
Advertisements
convert java Application to Java Applet
convert java Application to Java Applet  hi every Java Master or Java Professional , my Name Is Vincent i'm java beginner can i ask a question regarding for Java application convert to Java Applet. below her is my sample
java Application to java Applet
java Application to java Applet  sorry Java master disturb again how can i modify below this Java application to applet because in swtich case i had put this countinue selection source code to make user choosing so hope can
java application - Applet
java application  codes in repetition and decision  codes in repition and decision
java application/applet - Java Beginners
java application/applet  In this project, the student has to develop and submit a program for a Java application / applet which contains a set of GUI components as detailed below. 1. The Java applet page/application models
Java Application change to java applet
Java Application change to java applet   Hi every Java Masters i'm Java beginner ,and i want below this figures source code convert to Java Applet... extends Applet implements ActionListener{ TextField text,output; Label
how to convert java Applet to Jave Frame
how 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
java applet - Applet
java applet  wants to creat address bar on my java applet.  Hi Applet don't provide a facility to create a address bar directly. You just create a text box. In this text box if you enter any http address
loading Java Applet - Applet
loading Java Applet  Hi, I use the archive tag to download my applet into the Browser It takes too long to load. Can I do it in several steps... control the loading within the applet? thanks
Java Applet
Java Applet   How to add Image in Java Applet? what is getDocumentBase
java applet - Applet
java applet  I want to close applet window which is open by another button of applet program. plz tell me!   Hi Friend, Try...://www.roseindia.net/java/example/java/applet/ Thanks
java - Applet
java  how to connect database table with scrollbar in java applet
java - Applet
java  how to connect database table with scrollbar in java applet
java - Applet
java  what is applet?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/applet/ Thanks
Convert - Applet
Convert   Hello dear colleques I would like to ask about some converting program currently i am doing converting program my graduation report. I came from mongolia and I live in korea now. therefore my supevisor gave
java applet
java applet  why java applet programs doesn't contain main method
java applet
java applet  why java applet programs doesn't contain main method
java applet problem - Applet
java applet problem  i was doing a program using java applet. I want... and to exit from the applet respectively.Now i want to display a message when...*; import java.awt.*; public class Calculator extends Applet implements
Java applet
Java applet  What tags are mandatory when creating HTML to display an applet
Java applet
Java applet   How do I go from my applet to another JSP or HTML page
java applet
java applet  If i insert in database from applet this work, but from applet.html don't
Java Applet
Java Applet  Hi, What is Java Applet and how it can be useful in development of Java programs? Can anyone tell me the url to learn Java Applet? Thanks   Hi, See the tutorial at: Applications and Applets Thanks
java - Applet
java  how to communicate to my servlet through applet.   ... this information to the servlet in the normal way. The applet pretends... is concerned, the applet is just another HTTP client. For more infomation
java applet
java applet   I want code to implement (1) user will enter how many nodes (2)it should allow that no. of clicks and circle should be displayed at that position
java - Applet
java  what is applet
Applet Application
Applet Application  import java.awt.*; import java.applet.*; class pawan extends Applet { public static void main(String args...(); } } <APPLET WIDTH=1000 HEIGTH=800 </APPLET>
java applet
java applet  Creation of Applet for Personal Details Form When a customer places his first order of garments, the Personal Details Form is displayed.... The applet must include the following validations: ï?® The FirstName, Address1
The Java Applet Viewer
The Java Applet Viewer       Applet viewer is a command line program to run Java applets...; the browser should be Java enabled.To create an applet, we need to define
java applet prog
java applet prog  applet to display scrolling text from right to left in an applet window using thread. text should be accepted by html parameter
java - Applet
java  i have button browse button in my applet form.when i click on browse button i have to go to file storage box(what ever files stored in my... in the mail).i have display that file path in my applet form.am learner please send me
java - Applet
java  1.An applet program to draw a line graph for y=2x+5.[for suitable values of x & y] 2. An applet program to draw following shapes (1)cone... java.applet.Applet; public class CubeExample extends Applet { Stroke
Java applet
Java applet  How do I determine the width and height of my application
java applet
java applet  create applets to accept the personal details and sales details in the database. create jdbc application to connect the applets with the database
java - Applet
java  Hi, I need very urgent code............ please help me......... How to convert text to wave conversion? I need java code............ Regards, Valarmathi
Java applet
Java applet  What is AppletStub Interface
Java applet
Java applet  what are types of applets
disable keyboard in java applet
disable keyboard in java applet  How to disable key board of my client in an java applet embedded in a website while the applet is running.? Plz help
Java applet
Java applet  How do you set security in applets
Java applet
Java applet   How are the differences between Applets and Applications
Java applet
Java applet  What is the sequence for calling the methods by AWT for applets
Java applet
Java applet  What is the relationship between the Canvas class and the Graphics class
Java applet
Java applet  What is the relationship between the Canvas class and the Graphics class
java - Applet
java  what is the use of java.utl  Hi Friend, The java...://www.roseindia.net/java/example/java/util/ http://www.roseindia.net/java/example/java/util/java-util-package.shtml Thanks
Java applet
Java applet  How can I arrange for different applets on a web page to communicate with each other
java - Applet
://www.roseindia.net/java/example/java/swing/graphics2D/index.shtml Thanks
Java applet
Java applet  I wanted as many clicks are there ,circles should be displayed there. I tried this code but it erases previous circles. plz help. public void mouseClicked(MouseEvent m) { x=m.getX(); y=m.getY
Java applet
Java applet  I wanted as many clicks are there ,circles should be displayed there. I tried this code but it erases previous circles. plz help. public void mouseClicked(MouseEvent m) { x=m.getX(); y=m.getY
Java Applet
Java Applet  Hi, I have a query, on every mouse click an oval should be drawn. But in my program I have used repaint() function, therefore previous oval gets erased.How to avoid this so that I get more than one oval. PFB
Java Applet
Java Applet  Hi, I have a query, on every mouse click an oval should be drawn. But in my program I have used repaint() function, therefore previous oval gets erased.How to avoid this so that I get more than one oval. PFB

Ads