gufmn
09-04-2002, 04:51 PM
OK, I'm working on the same project as inkedmn. It basically uses JOptionPane prompting the user 3 times for input. It then does some simple calculation and displays it in another dialog box.
Btw, this is an applet.
Problem is: Every time run the applet, be it through the browser or through the appletviewer, it freeks out. The first box pops up asking for input. Then, as soon as you click on "ok" (or anything else for that matter) the box closes for a split second and re-opens again. Over and over and over. I can see the second input box behind it durring the split second the first one is closing and re-opening but can't get to it.
This is the strangest part:
I have found that when I execute it through the appletviewer, and, if and only if I minimize the ms-dos "APPLET" screen before I try to type in the input field, it works as it's supposed to. :wtf:
Anyway, here's my code:
import javax.swing.*;
import java.applet.*;
import java.awt.Graphics;
import java.util.*;
import java.text.NumberFormat;
public class MovieCashierApplet extends JApplet {
public void paint(Graphics g) {
Locale myLocale = new Locale("us", "US");
NumberFormat nf = NumberFormat.getCurrencyInstance(myLocale);
float PRICE1 = (float)8.75;
float PRICE2 = (float)5.50;
double TAX_RATE = .0775;
double STUDENT_DISCOUNT = .10;
String CHOICE = JOptionPane.showInputDialog("Hello! Welcome to the Movie Cashier\n\n1) Martin Lawerance Live: Runteldat (R)\n2) The Last Kiss (R)\n\nPlease select a movie:" , "Enter the number of the film:");
int MOVIE_CHOICE = Integer.parseInt(CHOICE);
String ADULTS = JOptionPane.showInputDialog(null,"Please enter the number of adult tickets", "Number of adults");
int NUM_ADULTS = Integer.parseInt(ADULTS);
String KIDS = JOptionPane.showInputDialog(null,"Please enter the number of child tickets", "Number of children");
int NUM_KIDS = Integer.parseInt(KIDS);
float SUBTOTAL = ((float)(NUM_ADULTS * PRICE1) + (float)(NUM_KIDS * PRICE2));
float TAXTOTAL = (float)(SUBTOTAL * TAX_RATE);
float TOTAL = (float)(SUBTOTAL + TAXTOTAL);
float DISCTOTAL =(float)(TOTAL * .9);
JOptionPane.showMessageDialog(null,"Subtotal is $" + nf.format(SUBTOTAL) + "\nSales tax is $" + nf.format(TAXTOTAL) + "\nTotal ammount due is $" + nf.format(TOTAL) + "\n\nStudent discounted price is $" + nf.format(DISCTOTAL));
}
}
why does the indentation get all screwed up?
Btw, this is an applet.
Problem is: Every time run the applet, be it through the browser or through the appletviewer, it freeks out. The first box pops up asking for input. Then, as soon as you click on "ok" (or anything else for that matter) the box closes for a split second and re-opens again. Over and over and over. I can see the second input box behind it durring the split second the first one is closing and re-opening but can't get to it.
This is the strangest part:
I have found that when I execute it through the appletviewer, and, if and only if I minimize the ms-dos "APPLET" screen before I try to type in the input field, it works as it's supposed to. :wtf:
Anyway, here's my code:
import javax.swing.*;
import java.applet.*;
import java.awt.Graphics;
import java.util.*;
import java.text.NumberFormat;
public class MovieCashierApplet extends JApplet {
public void paint(Graphics g) {
Locale myLocale = new Locale("us", "US");
NumberFormat nf = NumberFormat.getCurrencyInstance(myLocale);
float PRICE1 = (float)8.75;
float PRICE2 = (float)5.50;
double TAX_RATE = .0775;
double STUDENT_DISCOUNT = .10;
String CHOICE = JOptionPane.showInputDialog("Hello! Welcome to the Movie Cashier\n\n1) Martin Lawerance Live: Runteldat (R)\n2) The Last Kiss (R)\n\nPlease select a movie:" , "Enter the number of the film:");
int MOVIE_CHOICE = Integer.parseInt(CHOICE);
String ADULTS = JOptionPane.showInputDialog(null,"Please enter the number of adult tickets", "Number of adults");
int NUM_ADULTS = Integer.parseInt(ADULTS);
String KIDS = JOptionPane.showInputDialog(null,"Please enter the number of child tickets", "Number of children");
int NUM_KIDS = Integer.parseInt(KIDS);
float SUBTOTAL = ((float)(NUM_ADULTS * PRICE1) + (float)(NUM_KIDS * PRICE2));
float TAXTOTAL = (float)(SUBTOTAL * TAX_RATE);
float TOTAL = (float)(SUBTOTAL + TAXTOTAL);
float DISCTOTAL =(float)(TOTAL * .9);
JOptionPane.showMessageDialog(null,"Subtotal is $" + nf.format(SUBTOTAL) + "\nSales tax is $" + nf.format(TAXTOTAL) + "\nTotal ammount due is $" + nf.format(TOTAL) + "\n\nStudent discounted price is $" + nf.format(DISCTOTAL));
}
}
why does the indentation get all screwed up?