Запуск Java-апплета
Я написал код для Java-апплета, и он скомпилирован и работает на Eclipse. Однако после того, как я отправил свои файлы на веб-сервер и попытался запустить апплет с использованием файла html, я получил исключение.
java.lang.reflect.InvocationTargetException
Ранее у меня были проблемы с запуском приложения Java с моим Firefox, и я думаю, что исправил это, потому что я без проблем запускал некоторые онлайн-приложения Java.
Кто-нибудь считает, что с моим кодом что-то не так?
Я думаю, что проблема связана с обработкой событий для списков и полей со списком.
//LIST BOXES variables
//Create 3 arrays of Strings and 3 list boxes
private String[] sandwiches = {"Bacon and Turkey", "Cheese steak Melt",
"Veggie Lite", "The Works"};
private String[] kids = {"Stay Fit", "Breakfast Sub", "Roast Beef", "Little Sub"};
private String[] drinks = {"Fountain Sodas", "Vitamin Water", "Iced Tea", "Orange Juice"};
private JList jlstsandwiches = new JList(sandwiches);
private JList jlstkids = new JList(kids);
private JList jlstdrinks = new JList(drinks);
//Create 3 arrays of prices and 3 arrays of image icons
private double[] sandwichPrices = {5.75, 6.25, 5.95};
private double[] kidsPrices = {3.50, 2.99, 3.29};
private double[] drinksPrices = {2.05, 1.25, 1.50};
//COMBO BOXES variables
//Create 3 arrays of Strings and 3 combo boxes
private String[] feelings = {"Today I am...", "Feeling Happy",
"Feeling Strong", "Feeling Energetic"};
private String[] specials = {"Special Sandwiches", "Big Lance", "Pepe"};
private String[] specialDrinks = {"Special Drinks", "Lance's Shake", "Smooth It"};
private JComboBox jcbofeelings = new JComboBox(feelings);
private JComboBox jcbospecials = new JComboBox(specials);
private JComboBox jcbodrinks = new JComboBox(specialDrinks);
//Create 2 arrays of prices and 2 arrays of image icons
private double[] specialSandwichPrices = {0.0, 6.75, 7.25};
private double[] specialDrinksPrices = {0.0, 2.50, 2.99};
//Additional Variables
private ImageIcon usIcon = new ImageIcon("images/sub_sandwiches2.jpg");
private JTextArea jtaNutritionNotes = new JTextArea(1, 20);
public LanceSubs() {
Font largeFont = new Font("Serif", Font.BOLD, 20);
Font mediumFont = new Font("Serif", Font.BOLD, 16);
Font smallFont = new Font("Serif", Font.PLAIN, 12);
Border lineborder = new LineBorder(Color.BLACK, 1);
// ---------------------------------------------------------------------------------------
//REGISTER LISTENERS
//EAST PANEL
//Register listeners for radio buttons
jrbcarryout.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e){
double carryout = 0.00;
jlblDelivery2.setText(String.format("%4.2f", carryout));
}
});
jrbdelivery.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e){
double delivery = 4.00;
jlblDelivery2.setText(String.format("%4.2f", delivery));
}
});
//Register listeners for clear and finalize buttons
jbtClear.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e){
double itemPriceClear = Double.parseDouble(jlblItemPrice2.getText());
itemSubtotal = Double.parseDouble(jlblSubtotal2.getText());
double deliveryChargeClear = Double.parseDouble(jlblDelivery2.getText());
itemPriceClear = 0.00;
itemSubtotal = 0.00;
deliveryChargeClear = 0.00;
jlblItemPrice2.setText(String.format("%4.2f", itemPriceClear));
jlblSubtotal2.setText(String.format("%4.2f", itemSubtotal));
jlblDelivery2.setText(String.format("%4.2f", deliveryChargeClear));
/***double itemPriceField = Double.parseDouble(jtfItemPrice.getText());
itemPriceField = 0.00;
jtfItemPrice.setText(String.format("%4.2f", itemPriceField));*/
}
});
jbtFinalize.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e){
double subtotal = Double.parseDouble(jlblSubtotal2.getText());
double deliveryCharge = Double.parseDouble(jlblDelivery2.getText());
final double TAX = 0.01 * Double.parseDouble(jlblTax2.getText());
double finalPrice = subtotal + deliveryCharge + (TAX * (subtotal + deliveryCharge));
jtfResult.setText(String.format("%4.2f", finalPrice));
}
});
//WEST PANEL
//Register listeners for list boxes' menus
jlstsandwiches.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e){
/***int[] indices = jlstsandwiches.getSelectedIndices();
int i;
for(i = 0; i < indices.length; i++){
jtfItemPrice.setText(sandwichPrices[indices[i]].toString());
}*/
int index = 0;
if (index < sandwiches.length){
index = jlstsandwiches.getSelectedIndex();
jtfItemPrice.setText(String.format("%4.2f", sandwichPrices[index]));
}
}
});
jlstkids.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e){
/***int[] indices = jlstsandwiches.getSelectedIndices();
int i;
for(i = 0; i < indices.length; i++){
jtfItemPrice.setText(sandwichPrices[indices[i]].toString());
}*/
int index = 0;
if (index < kids.length){
index = jlstkids.getSelectedIndex();
jtfItemPrice.setText(String.format("%4.2f", kidsPrices[index]));
}
}
});
jlstdrinks.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e){
int index = 0;
if (index < drinks.length){
index = jlstdrinks.getSelectedIndex();
jtfItemPrice.setText(String.format("%4.2f", drinksPrices[index]));
}
}
});
//NORTH PANEL
//Register listeners for combo boxes
jcbospecials.addItemListener(new ItemListener(){
@Override
public void itemStateChanged(ItemEvent e){
int index = 0;
if (index < specials.length){
index = jcbospecials.getSelectedIndex();
jtfItemPrice.setText(String.format("%4.2f", specialSandwichPrices[index]));
}
}
});
jcbodrinks.addItemListener(new ItemListener(){
@Override
public void itemStateChanged(ItemEvent e){
int index = 0;
if (index < specialDrinks.length){
index = jcbodrinks.getSelectedIndex();
jtfItemPrice.setText(String.format("%4.2f", specialDrinksPrices[index]));
}
}
});
//CENTER PANEL
//Register listeners for cart and remove buttons
jbtCart.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e){
itemPrice = Double.parseDouble(jtfItemPrice.getText());
itemSubtotal += itemPrice;
jlblItemPrice2.setText(String.format("%4.2f", itemPrice));
jlblSubtotal2.setText(String.format("%4.2f", itemSubtotal));
}
});
//Display itemPrice and itemSubtotal in Your Subtotal sub-menu
jbtRemove.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e){
itemPrice = Double.parseDouble(jlblItemPrice2.getText());
itemSubtotal = Double.parseDouble(jlblSubtotal2.getText());
itemSubtotal -= itemPrice;
jlblItemPrice2.setText(String.format("%4.2f", itemPrice));
jlblSubtotal2.setText(String.format("%4.2f", itemSubtotal));
}
});
}}
Может кто-нибудь помочь?