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 .

thank you

import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.util.*;
import java.text.*;
import java.awt.event.*;

public class RC extends Applet implements ActionListener{
  TextField text,text1,text2,text3,text4,text5,text6,text7;
  Label label1,label2,label3,label4,label5,label6,label7,label8,label9;
  Label lab;
  Button b1,b2;
  JComboBox combo;
  DecimalFormat df = new DecimalFormat("$##.##");
  public void init(){
    setLayout(null);

    lab=new Label("Welcome to Rental Car System");
    lab.setBounds(100,20,200,20);
    add(lab);

    label1 = new Label("Select Type of Car: ");
    label1.setBounds(20,50,180,20);
    add(label1);
    combo=new JComboBox();
    combo.addItem("--Select--");
    combo.addItem("Honda City");
    combo.addItem("Toyota Vios");
    combo.addItem("Nissan Latio");
    combo.addItem("Proton Iswara");
    combo.addItem("Proton Waja");
    combo.addItem("Perodua Myvi");
    combo.addItem("Toyota Avenza");
    combo.addItem("Honda Stream");
    combo.addItem("Nissan Grand Livina");
    combo.addItem("Perodua Alza");
    combo.addItem("Proton Exora");
    combo.setBounds(200,50,120,20);
    add(combo);
    label2 = new Label("Enter number of days: ");
    label2.setBounds(20,80,180,20);
    add(label2);

    text = new TextField(5);
    text.setBounds(200,80,100,20);
    add(text);

    b1 = new Button("Submit");
    b1.setBounds(200,140,100,20);
    add(b1);
    b1.addActionListener(this);

    label3=new Label("Enter Customer Name: ");
    label3.setBounds(20,60,180,20);
    add(label3);

    text1=new TextField(10);
    text1.setBounds(230,60,150,20);
    add(text1);

    label4=new Label("Enter IC Number: ");
    label4.setBounds(20,90,180,20);
    add(label4);

    text2=new TextField(10);
    text2.setBounds(230,90,150,20);
    add(text2);

    label5=new Label("Enter Age: ");
    label5.setBounds(20,120,180,20);
    add(label5);

    text3=new TextField(10);
    text3.setBounds(230,120,150,20);
    add(text3);

    label6=new Label("Enter Mobile Number: ");
    label6.setBounds(20,150,180,20);
    add(label6);

    text4=new TextField(10);
    text4.setBounds(230,150,150,20);
    add(text4);
    label7=new Label("Enter  E-Mail Address: ");
    label7.setBounds(20,180,180,20);
    add(label7);

    text5=new TextField(10);
    text5.setBounds(230,180,150,20);
    add(text5);

    label8=new Label("Enter  16 Digit of Credit Card Number: ");
    label8.setBounds(20,210,210,20);
    add(label8);

    text6=new TextField(10);
    text6.setBounds(230,210,150,20);
    add(text6);

    label9=new Label("Enter Pin Code of Credit Card: ");
    label9.setBounds(20,240,180,20);
    add(label9);

    text7=new TextField(10);
    text7.setBounds(230,240,150,20);
    add(text7);

    b2=new Button("Submit");
    b2.setBounds(230,270,100,20);
    add(b2);
    label3.setVisible(false);
    label4.setVisible(false);
    label5.setVisible(false);
    label6.setVisible(false);
    label7.setVisible(false);
    label8.setVisible(false);
    label9.setVisible(false);
    text1.setVisible(false);
    text2.setVisible(false);
    text3.setVisible(false);
    text4.setVisible(false);
    text5.setVisible(false);
    text6.setVisible(false);
    text7.setVisible(false);
    b2.setVisible(false);
     }
         public void actionPerformed(ActionEvent ae){
    String value=combo.getSelectedItem().toString();
    int day=Integer.parseInt(text.getText());
    if(value.equals("Honda City")){
        if(day>0){
   final double amount=(day-0)*60.00 + 100.00;
    JOptionPane.showMessageDialog(null,"Vehicle type= Honda City \n" + " Deposit= Rm100 \n " + " Daily Rate= 60 \n" + "days= " + day+"\n\n"+"Rental Total Charges= "+df.format(amount));
    String st=JOptionPane.showInputDialog(null,"Do you want to continue next Process?( y/n ): ");
    if(st.equals("y")){
    label1.setVisible(false);
    label2.setVisible(false);
    text.setVisible(false);
    combo.setVisible(false);
    b1.setVisible(false);
    b2.setVisible(true);
    label3.setVisible(true);
    label4.setVisible(true);
    label5.setVisible(true);
    label6.setVisible(true);
    label7.setVisible(true);
    label8.setVisible(true);
    label9.setVisible(true);
    text1.setVisible(true);
    text2.setVisible(true);
    text3.setVisible(true);
    text4.setVisible(true);
    text5.setVisible(true);
    text6.setVisible(true);
    text7.setVisible(true);
    b2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
    JOptionPane.showMessageDialog(null," Customer Name: " +text1.getText()+ "\n IC Number: " +text2.getText()+ "\n Age: " +text3.getText()+ "\n Mobile Number: " +text4.getText()+ "\n Rental Charger:  "+ df.format(amount) );
        }
    });
    }

    else{
        JOptionPane.showMessageDialog(null,"Thank survey to Rental Car System and See you Again....!");
    }
    }
    }
    else if(value.equals("Toyota Vios")){
        if(day>0){
   final double amount=(day-0)*60.00 + 100.00;
    JOptionPane.showMessageDialog(null,"Vehicle type= Toyota Vios \n" + " Deposit= Rm100 \n " + " Daily Rate= 60 \n" + "days= " + day+"\n\n"+"Rental Total Charges= "+df.format(amount));
    String st=JOptionPane.showInputDialog(null,"Do you want to continue next Process?( y/n ): ");
    if(st.equals("y")){
    label1.setVisible(false);
    label2.setVisible(false);
    text.setVisible(false);
    combo.setVisible(false);
    b1.setVisible(false);
    b2.setVisible(true);
    label3.setVisible(true);
    label4.setVisible(true);
    label5.setVisible(true);
    label6.setVisible(true);

    text1.setVisible(true);
    text2.setVisible(true);
    text3.setVisible(true);
    text4.setVisible(true);
b2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
    JOptionPane.showMessageDialog(null," Customer Name: " +text1.getText()+ "\n IC Number: " +text2.getText()+ "\n Age: " +text3.getText()+ "\n Mobile Number: " +text4.getText()+ "\n Rental Charger:  "+ df.format(amount) );
        }
    }); }
    else{
        JOptionPane.showMessageDialog(null,"Thank survey to Rental Car System and See you Again....!");
    }
    }
    }
else if(value.equals("Nissan Latio")){
        if(day>0){
   final double amount=(day-0)*70.00 + 100.00;
    JOptionPane.showMessageDialog(null,"Vehicle type= Nissan Latio \n" + " Deposit= Rm100 \n " + " Daily Rate= 70 \n" + "days= " + day+"\n\n"+"Rental Total Charges= "+df.format(amount));
    String st=JOptionPane.showInputDialog(null,"Do you want to continue next Process?( y/n ): ");
    if(st.equals("y")){
    label1.setVisible(false);
    label2.setVisible(false);
    text.setVisible(false);
    combo.setVisible(false);
    b1.setVisible(false);
    b2.setVisible(true);
    label3.setVisible(true);
    label4.setVisible(true);
    label5.setVisible(true);
    label6.setVisible(true);

    text1.setVisible(true);
    text2.setVisible(true);
    text3.setVisible(true);
    text4.setVisible(true);
b2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
    JOptionPane.showMessageDialog(null," Customer Name: " +text1.getText()+ "\n IC Number: " +text2.getText()+ "\n Age: " +text3.getText()+ "\n Mobile Number: " +text4.getText()+ "\n Rental Charger:  "+ df.format(amount) );
        }
    }); }
    else{
        JOptionPane.showMessageDialog(null,"Thank survey to Rental Car System and See you Again....!");
    }
    }
    }
    }
}
View Answers

March 14, 2012 at 10:44 AM

import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.util.*;
import java.text.*;
import java.awt.event.*;

public class RC extends JFrame implements ActionListener{
    JTextField text,text1,text2,text3,text4,text5,text6,text7; 
    JLabel label1,label2,label3,label4,label5,label6,label7,label8,label9;
    JLabel lab;
    JButton b1,b2; 
    JComboBox combo;
    DecimalFormat df = new DecimalFormat("$##.##");
    public RC(){
        setLayout(null);
        lab=new JLabel("Welcome to Rental Car System");
lab.setBounds(100,20,200,20);
add(lab);

label1 = new JLabel("Select Type of Car: ");
label1.setBounds(20,50,180,20);
add(label1);
combo=new JComboBox();
combo.addItem("--Select--");
combo.addItem("Honda City");
combo.addItem("Toyota Vios");
combo.addItem("Nissan Latio");
combo.addItem("Proton Iswara");
combo.addItem("Proton Waja");
combo.addItem("Perodua Myvi");
combo.addItem("Toyota Avenza");
combo.addItem("Honda Stream");
combo.addItem("Nissan Grand Livina");
combo.addItem("Perodua Alza");
combo.addItem("Proton Exora");
combo.setBounds(200,50,120,20);
add(combo);
label2 = new JLabel("Enter number of days: ");
label2.setBounds(20,80,180,20);
add(label2);

text = new JTextField(5);
text.setBounds(200,80,100,20);
add(text);

b1 = new JButton("Submit");
b1.setBounds(200,140,100,20);
add(b1);
b1.addActionListener(this);

label3=new JLabel("Enter Customer Name: ");
label3.setBounds(20,60,180,20);
add(label3);

text1=new JTextField(10);
text1.setBounds(230,60,150,20);
add(text1);

label4=new JLabel("Enter IC Number: ");
label4.setBounds(20,90,180,20);
add(label4);

text2=new JTextField(10);
text2.setBounds(230,90,150,20);
add(text2);

label5=new JLabel("Enter Age: ");
label5.setBounds(20,120,180,20);
add(label5);

text3=new JTextField(10);
text3.setBounds(230,120,150,20);
add(text3);

label6=new JLabel("Enter Mobile Number: ");
label6.setBounds(20,150,180,20);
add(label6);

text4=new JTextField(10);
text4.setBounds(230,150,150,20);
add(text4);
label7=new JLabel("Enter  E-Mail Address: ");
label7.setBounds(20,180,180,20);
add(label7);

text5=new JTextField(10);
text5.setBounds(230,180,150,20);
add(text5);

label8=new JLabel("Enter  16 Digit of Credit Card Number: ");
label8.setBounds(20,210,210,20);
add(label8);

text6=new JTextField(10);
text6.setBounds(230,210,150,20);
add(text6);

label9=new JLabel("Enter Pin Code of Credit Card: ");
label9.setBounds(20,240,180,20);
add(label9);

text7=new JTextField(10);
text7.setBounds(230,240,150,20);
add(text7);

March 14, 2012 at 10:45 AM

continue..

    b2=new JButton("Submit");
b2.setBounds(230,270,100,20);
add(b2);
label3.setVisible(false);
label4.setVisible(false);
label5.setVisible(false);
label6.setVisible(false);
label7.setVisible(false);
label8.setVisible(false);
label9.setVisible(false);
text1.setVisible(false);
text2.setVisible(false);
text3.setVisible(false);
text4.setVisible(false);
text5.setVisible(false);
text6.setVisible(false);
text7.setVisible(false);
b2.setVisible(false);
setVisible(true);
setSize(1024,760);
 }
     public void actionPerformed(ActionEvent ae){
String value=combo.getSelectedItem().toString();
int day=Integer.parseInt(text.getText());
if(value.equals("Honda City")){
    if(day>0){

final double amount=(day-0)*60.00 + 100.00;
JOptionPane.showMessageDialog(null,"Vehicle type= Honda City \n" + " Deposit= Rm100 \n " + " Daily Rate= 60 \n" + "days= " + day+"\n\n"+"Rental Total Charges= "+df.format(amount));
String st=JOptionPane.showInputDialog(null,"Do you want to continue next Process?( y/n ): ");
if(st.equals("y")){
    label1.setVisible(false);
    label2.setVisible(false);
    text.setVisible(false);
    combo.setVisible(false);
    b1.setVisible(false);
    b2.setVisible(true);
    label3.setVisible(true);
    label4.setVisible(true);
    label5.setVisible(true); 
    label6.setVisible(true); 
    label7.setVisible(true);
    label8.setVisible(true);
    label9.setVisible(true);
    text1.setVisible(true);
    text2.setVisible(true); 
    text3.setVisible(true); 
    text4.setVisible(true);
    text5.setVisible(true);
    text6.setVisible(true);
    text7.setVisible(true);
    b2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){ 
            JOptionPane.showMessageDialog(null," Customer Name: " +text1.getText()+ "\n IC Number: " +text2.getText()+ "\n Age: " +text3.getText()+ "\n Mobile Number: " +text4.getText()+ "\n Rental Charger: "+ df.format(amount) );
            } 
            });
            }
else{
    JOptionPane.showMessageDialog(null,"Thank survey to Rental Car System and See you Again....!");
}
}
}
else if(value.equals("Toyota Vios")){
    if(day>0){

final double amount=(day-0)*60.00 + 100.00;
JOptionPane.showMessageDialog(null,"Vehicle type= Toyota Vios \n" + " Deposit= Rm100 \n " + " Daily Rate= 60 \n" + "days= " + day+"\n\n"+"Rental Total Charges= "+df.format(amount)); 
String st=JOptionPane.showInputDialog(null,"Do you want to continue next Process?( y/n ): "); 
if(st.equals("y")){
    label1.setVisible(false);
    label2.setVisible(false); 
    text.setVisible(false);
    combo.setVisible(false);
    b1.setVisible(false);
    b2.setVisible(true); 
    label3.setVisible(true); 
    label4.setVisible(true);
    label5.setVisible(true); 
    label6.setVisible(true);

text1.setVisible(true);
text2.setVisible(true);
text3.setVisible(true);
text4.setVisible(true);

March 14, 2012 at 10:46 AM

continue..

b2.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){ 
        JOptionPane.showMessageDialog(null," Customer Name: " +text1.getText()+ "\n IC Number: " +text2.getText()+ "\n Age: " +text3.getText()+ "\n Mobile Number: " +text4.getText()+ "\n Rental Charger: "+ df.format(amount) );
        }
        });
        } 
        else{ 
            JOptionPane.showMessageDialog(null,"Thank survey to Rental Car System and See you Again....!"); 
            } 
            }
            }
            else if(value.equals("Nissan Latio")){
                if(day>0){
                    final double amount=(day-0)*70.00 + 100.00;
                    JOptionPane.showMessageDialog(null,"Vehicle type= Nissan Latio \n" + " Deposit= Rm100 \n " + " Daily Rate= 70 \n" + "days= " + day+"\n\n"+"Rental Total Charges= "+df.format(amount));
                    String st=JOptionPane.showInputDialog(null,"Do you want to continue next Process?( y/n ): ");
                    if(st.equals("y")){
                        label1.setVisible(false);
                        label2.setVisible(false);
                        text.setVisible(false);
                        combo.setVisible(false);
                        b1.setVisible(false); 
                        b2.setVisible(true);
                        label3.setVisible(true);
                        label4.setVisible(true);
                        label5.setVisible(true); 
                        label6.setVisible(true);

                        text1.setVisible(true);
                        text2.setVisible(true);
                        text3.setVisible(true);
                        text4.setVisible(true);

b2.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
        JOptionPane.showMessageDialog(null," Customer Name: " +text1.getText()+ "\n IC Number: " +text2.getText()+ "\n Age: " +text3.getText()+ "\n Mobile Number: " +text4.getText()+ "\n Rental Charger: "+ df.format(amount) );
        }
        });
        }
        else{
            JOptionPane.showMessageDialog(null,"Thank survey to Rental Car System and See you Again....!");
            } 
            } 
            } 
            } 
            public static void main(String[]args){
                new RC();
            }
            }

March 14, 2012 at 11:43 AM

sorry can i ask one more question if i use this application to modify connection with database is it can ?









Related Tutorials/Questions & Answers:
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 Frame/ Applet /swing/awt
Java Frame/ Applet /swing/awt  I have produced a .exe file with the help of .jar file................... Now How can I Protect my software( .exe ) file bulid in Java from being Copy and Paste....????????? please reply
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
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.
link to other frame - Applet
link to other frame  how a button to open to another frame? and the frame can keyin the data and it can show at the previous frame
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
how to create a jave version excel in jsp
how to create a jave version excel in jsp  I would like to create a java version excel in JSP. so the excel like document can be published in the internet. the user will be able to enter the information and click the save button
Jave writing method - Java Beginners
Jave writing method   HI! i'll really apprecite if anyone can help me...! Implement a method named posNeg that accepts 3 integer parameters..., 19 then the method will return 1. Implement a method named order
how to go from one frame to another frame in swings - Java Beginners
how to go from one frame to another frame in swings  Hi, My task is to go from one frame to another.......... let us think that iam having two buttons on a frame........button names are ok and next........ when iam clicking
how to run applet - Applet
://www.roseindia.net/java/example/java/applet/ http://www.roseindia.net/java/example/java/applet/FirstApplet.shtml Hope that it will be helpful for you.Even...how to run applet   Hi everybody i am using connecting jdbc
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 Applet   How to add Image in Java Applet? what is getDocumentBase
how can i close a frame. - Java Beginners
how can i close a frame.  Hi, My question is how can we close a frame when an action is taken......For example let us think that we have a frame and in that table is displayed and one button is added to that frame
How to write a simple java applet
How to write a simple java applet   Hi, how can i write a simple java applet, displaying text in specific colors and font style. For example... ShowsTextExample extends Applet{ public void paint(Graphics g){ g.setColor
Java Frame
Java Frame  What is the difference between a Window and a Frame
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
How to make frame in java
How to make frame in java We are going to discus about frame in java. In this example We have make frame in java Swing. We have created JFrame class... of the window or frame. We have used setVisible(true) function. The setVisible
How to convert into to String in Java?
How to convert into to String in Java?  Hi, How to convert into to String in Java? Thanks
how to add database in Java Applet
how to add database in Java Applet  hi every java master or Java Professional my name is vincent i'm java beginners hope u all can ,tech me how to add database in Java Applet below this code is my applet source code . thank
how to create frame in swings
how to create frame in swings  how to create frame in swings
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
How to set the Gradient Color as a background color for Java Frame?
How to set the Gradient Color as a background color for Java Frame?  How to set the Gradient Color as a background color for Java Frame
Java applet
Java applet   How do I go from my applet to another JSP or HTML page
how display jsp frame - Java Beginners
how display jsp frame  Hi all, I am creating two jsp in frame like this page content in left side.i am... in another frame,you have to use target attribute of tag in your footer.jsp.
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 Hello World
Java - Applet Hello World       This example introduces you with the Applet in Java. You will learn how to develop applet code and run in the browser. Applet
java - Applet
java  what is applet?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/applet/ Thanks
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 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  why java applet programs doesn't contain main method
java applet
java applet  why java applet programs doesn't contain main method
Java applet
Java applet  What tags are mandatory when creating HTML to display an applet
java applet
java applet  If i insert in database from applet this work, but from applet.html don't
java - Applet
java  what is applet
How to convert string to byte in Java
How to convert string to byte in Java  How to convert string to byte in Java
how to convert string to image in java
how 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 java
how 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 java
how 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 java
how 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 java
how 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 Java
How 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 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 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

Ads