Question

Convert the following GUI application into an Applet. Do not delete any part of the GUI...

Convert the following GUI application into an Applet. Do not delete any part of the GUI program, just comment out the part of the program not required. Another Java code is required

// Java code:

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class PizzaShopping extends JFrame

{

JCheckBox ckb[];

JLabel jlb1;

JRadioButton radio[], radio1[];

static String[] pizzaToppings = "Tomato,Green peppper,Black olives,Mushrooms,Extra cheese,Pepproni,Sausage"

.split(",");

static String[] pizzaSizes = "Small: $6.50, Medium: $8.50, Large: $10".split(",");

static String[] pizzatypes = "Thin Crust, Mediam Crust, Pan".split(",");

static final String CLEAR = "clear";

static final String TOTAL = "total";

final ButtonGroup groupSizes = new ButtonGroup();

final ButtonGroup groupSizes1 = new ButtonGroup();

JPanel sizes, toppings, types;

JTextArea textArea;

static final private int[] PRICE_SIZES =

{ 650, 850, 1000 }; // pennies

public PizzaShopping()

{

super("Pizza Shop");

radio = new JRadioButton[pizzaSizes.length];

radio1 = new JRadioButton[pizzatypes.length];

ckb = new JCheckBox[pizzaToppings.length];

JPanel options = makeOptionsPanel();

add(options);

setSize(800, 450);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setLocationRelativeTo(null);

setVisible(true);

}

public static void main(String[] args)

{

new PizzaShopping();

}

private JPanel makeOptionsPanel()

{

sizes = addRadioBoxes(pizzaSizes, "Pizza Size", radio, groupSizes);

toppings = addCkBoxes(pizzaToppings, ckb);

types = addRadioBoxes(pizzatypes, "Pizza Type", radio1, groupSizes1);

JPanel size_type = new JPanel();

size_type.setLayout(new GridLayout(1, 2, 15, 10));

size_type.add(sizes);

size_type.add(types);

JPanel buttonControls = new JPanel();

buttonControls.setBorder(BorderFactory.createEmptyBorder(1, 10, 1, 10));

JButton clear = new JButton("Clear");

clear.setActionCommand(CLEAR);

clear.addActionListener(new MyButtonListener());

JButton total = new JButton("Process Selection");

total.setActionCommand(TOTAL);

total.addActionListener(new MyButtonListener());

buttonControls.add(clear);

buttonControls.add(total);

JPanel si_ty_cont = new JPanel();

si_ty_cont.setLayout(new GridLayout(2, 1, 15, 15));

si_ty_cont.add(size_type);

si_ty_cont.add(buttonControls);

JPanel p = new JPanel();

p.setLayout(new GridLayout(1, 2, 15, 15));

p.add(toppings);

p.add(si_ty_cont);

p.setAlignmentX(Component.LEFT_ALIGNMENT);

JPanel completePanel = new JPanel();

jlb1.setAlignmentX(Component.CENTER_ALIGNMENT);

completePanel.setLayout(new BoxLayout(completePanel, BoxLayout.PAGE_AXIS));

JLabel jlb = new JLabel("Your order: ", SwingConstants.LEFT);

textArea = new JTextArea();

textArea.setRows(5);

JScrollPane sp = new JScrollPane(textArea);

sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

jlb1 = new JLabel("Welcome to Home Style Pizza Shop");

jlb1.setFont(new Font("Courier New", Font.BOLD, 20));

jlb1.setForeground(Color.RED);

completePanel.add(jlb1);

completePanel.add(Box.createVerticalGlue());

completePanel.add(p);

completePanel.add(Box.createVerticalGlue());

completePanel.add(jlb);

completePanel.add(sp);

return completePanel;

}

private void calcPrice()

{

int total = 0, subTotal = 0;

int priceIndex = 0, priceIndex1 = 0;

for (int i = 0; i < radio.length; i++)

{

if (radio[i].isSelected())

{

priceIndex = i;

break;

}

}

for (int i = 0; i < radio1.length; i++)

{

if (radio1[i].isSelected())

{

priceIndex1 = i;

break;

}

}

textArea.setText("");

StringBuilder sb = new StringBuilder();

sb.append(String.format("Pizza type: %s%n", pizzatypes[priceIndex1]));

sb.append(String.format("Pizza size: %s%n", pizzaSizes[priceIndex]));

sb.append("Toppings : ");

total += PRICE_SIZES[priceIndex];

String accumTops = "";

for (int i = 0; i < ckb.length; i++)

{

if (ckb[i].isSelected())

{

accumTops += "" + i + ",";

subTotal += 150;

}

}

if (!accumTops.isEmpty())

{

String[] orderedTops = accumTops.split(",");

for (int i = 0; i < orderedTops.length; i++)

{

sb.append(String.format("%s, ",

pizzaToppings[Integer.parseInt(orderedTops[i])]));

}

}

else

{

sb.append(String.format("%s%n", "

}

total += subTotal;

sb.append(String.format("\nAmount Due: $ %d.%2d%n", total / 100, total % 100));

textArea.setText(sb.toString());

}

private JPanel addRadioBoxes(String[] opts, String title, JRadioButton jrb[],

ButtonGroup bg)

{

int rows = opts.length;

JPanel p = new JPanel();

addBorder(p);

p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));

jlb1 = new JLabel(title);

jlb1.setFont(new Font("Courier New", Font.ROMAN_BASELINE, 18));

jlb1.setForeground(Color.RED);

p.add(jlb1);

JPanel p1 = new JPanel();

p1.setLayout(new GridLayout(rows, 1));

for (int i = 0; i < rows; i++)

{

jrb[i] = new JRadioButton(opts[i]);

p1.add(jrb[i]);

bg.add(jrb[i]);

}

p.add(p1);

return p;

}

private void addBorder(JPanel p)

{

p.setBorder(BorderFactory.createLineBorder(Color.RED));

}

private JPanel addCkBoxes(String[] opts, JCheckBox checkbox[])

{

int rows = opts.length;

JPanel p = new JPanel();

addBorder(p);

p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));

jlb1 = new JLabel("Each Topping at $1.50", SwingConstants.LEFT);

jlb1.setFont(new Font("Courier New", Font.ROMAN_BASELINE, 18));

jlb1.setForeground(Color.RED);

p.add(jlb1);

JPanel p1 = new JPanel();

p1.setLayout(new GridLayout(rows, 1));

for (int i = 0; i < rows; i++)

{

checkbox[i] = new JCheckBox(opts[i]);

p1.add(checkbox[i]);

}

p.add(p1);

return p;

}

private void clearButtons()

{

groupSizes.clearSelection();

groupSizes1.clearSelection();

for (int i = 0; i < ckb.length; i++)

{

ckb[i].setSelected(false);

}

textArea.setText("");

}

class MyButtonListener implements ActionListener

{

@Override
public void actionPerformed(ActionEvent e)

{

if (e.getActionCommand().equals(CLEAR))

{

clearButtons();

}

else if (e.getActionCommand().equals(TOTAL))

{

calcPrice();

}

}

}

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class PizzaShopping extends JFrame //we do not use the Jrame in the Applet

{

JCheckBox ckb[];

JLabel jlb1;

JRadioButton radio[], radio1[];

static String[] pizzaToppings = "Tomato,Green peppper,Black olives,Mushrooms,Extra cheese,Pepproni,Sausage"

.split(",");

static String[] pizzaSizes = "Small: $6.50, Medium: $8.50, Large: $10".split(",");

static String[] pizzatypes = "Thin Crust, Mediam Crust, Pan".split(",");

static final String CLEAR = "clear";

static final String TOTAL = "total";

final ButtonGroup groupSizes = new ButtonGroup();

final ButtonGroup groupSizes1 = new ButtonGroup();

JPanel sizes, toppings, types;

JTextArea textArea;

static final private int[] PRICE_SIZES =

{ 650, 850, 1000 }; // pennies

public PizzaShopping()// we take the constructor void init() in the applet because the init method is called by the web browser

{

super("Pizza Shop");//when we use init we do not use the super method

radio = new JRadioButton[pizzaSizes.length];

radio1 = new JRadioButton[pizzatypes.length];

ckb = new JCheckBox[pizzaToppings.length];

JPanel options = makeOptionsPanel();

add(options);

setSize(800, 450);//we can not give the size to the applet because the size will be given by the web browser

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setLocationRelativeTo(null);

setVisible(true);

}

public static void main(String[] args)// we don't use the main funtion in the applet because the the main class is already called by the applet viewer window

{

new PizzaShopping();// same

}

private JPanel makeOptionsPanel()

{

sizes = addRadioBoxes(pizzaSizes, "Pizza Size", radio, groupSizes);

toppings = addCkBoxes(pizzaToppings, ckb);

types = addRadioBoxes(pizzatypes, "Pizza Type", radio1, groupSizes1);

JPanel size_type = new JPanel();

size_type.setLayout(new GridLayout(1, 2, 15, 10));

size_type.add(sizes);

size_type.add(types);

JPanel buttonControls = new JPanel();

buttonControls.setBorder(BorderFactory.createEmptyBorder(1, 10, 1, 10));

JButton clear = new JButton("Clear");

clear.setActionCommand(CLEAR);

clear.addActionListener(new MyButtonListener());

JButton total = new JButton("Process Selection");

total.setActionCommand(TOTAL);

total.addActionListener(new MyButtonListener());

buttonControls.add(clear);

buttonControls.add(total);

JPanel si_ty_cont = new JPanel();

si_ty_cont.setLayout(new GridLayout(2, 1, 15, 15));

si_ty_cont.add(size_type);

si_ty_cont.add(buttonControls);

JPanel p = new JPanel();

p.setLayout(new GridLayout(1, 2, 15, 15));

p.add(toppings);

p.add(si_ty_cont);

p.setAlignmentX(Component.LEFT_ALIGNMENT);

JPanel completePanel = new JPanel();

jlb1.setAlignmentX(Component.CENTER_ALIGNMENT);

completePanel.setLayout(new BoxLayout(completePanel, BoxLayout.PAGE_AXIS));

JLabel jlb = new JLabel("Your order: ", SwingConstants.LEFT);

textArea = new JTextArea();

textArea.setRows(5);

JScrollPane sp = new JScrollPane(textArea);

sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

jlb1 = new JLabel("Welcome to Home Style Pizza Shop");

jlb1.setFont(new Font("Courier New", Font.BOLD, 20));

jlb1.setForeground(Color.RED);

completePanel.add(jlb1);

completePanel.add(Box.createVerticalGlue());

completePanel.add(p);

completePanel.add(Box.createVerticalGlue());

completePanel.add(jlb);

completePanel.add(sp);

return completePanel;

}

private void calcPrice()

{

int total = 0, subTotal = 0;

int priceIndex = 0, priceIndex1 = 0;

for (int i = 0; i < radio.length; i++)

{

if (radio[i].isSelected())

{

priceIndex = i;

break;

}

}

for (int i = 0; i < radio1.length; i++)

{

if (radio1[i].isSelected())

{

priceIndex1 = i;

break;

}

}

textArea.setText("");

StringBuilder sb = new StringBuilder();

sb.append(String.format("Pizza type: %s%n", pizzatypes[priceIndex1]));

sb.append(String.format("Pizza size: %s%n", pizzaSizes[priceIndex]));

sb.append("Toppings : ");

total += PRICE_SIZES[priceIndex];

String accumTops = "";

for (int i = 0; i < ckb.length; i++)

{

if (ckb[i].isSelected())

{

accumTops += "" + i + ",";

subTotal += 150;

}

}

if (!accumTops.isEmpty())

{

String[] orderedTops = accumTops.split(",");

for (int i = 0; i < orderedTops.length; i++)

{

sb.append(String.format("%s, ",

pizzaToppings[Integer.parseInt(orderedTops[i])]));

}

}

else

{

sb.append(String.format("%s%n", "

}

total += subTotal;

sb.append(String.format("\nAmount Due: $ %d.%2d%n", total / 100, total % 100));

textArea.setText(sb.toString());

}

private JPanel addRadioBoxes(String[] opts, String title, JRadioButton jrb[],

ButtonGroup bg)

{

int rows = opts.length;

JPanel p = new JPanel();

addBorder(p);

p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));

jlb1 = new JLabel(title);

jlb1.setFont(new Font("Courier New", Font.ROMAN_BASELINE, 18));

jlb1.setForeground(Color.RED);

p.add(jlb1);

JPanel p1 = new JPanel();

p1.setLayout(new GridLayout(rows, 1));

for (int i = 0; i < rows; i++)

{

jrb[i] = new JRadioButton(opts[i]);

p1.add(jrb[i]);

bg.add(jrb[i]);

}

p.add(p1);

return p;

}

private void addBorder(JPanel p)

{

p.setBorder(BorderFactory.createLineBorder(Color.RED));

}

private JPanel addCkBoxes(String[] opts, JCheckBox checkbox[])

{

int rows = opts.length;

JPanel p = new JPanel();

addBorder(p);

p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));

jlb1 = new JLabel("Each Topping at $1.50", SwingConstants.LEFT);

jlb1.setFont(new Font("Courier New", Font.ROMAN_BASELINE, 18));

jlb1.setForeground(Color.RED);

p.add(jlb1);

JPanel p1 = new JPanel();

p1.setLayout(new GridLayout(rows, 1));

for (int i = 0; i < rows; i++)

{

checkbox[i] = new JCheckBox(opts[i]);

p1.add(checkbox[i]);

}

p.add(p1);

return p;

}

private void clearButtons()

{

groupSizes.clearSelection();

groupSizes1.clearSelection();

for (int i = 0; i < ckb.length; i++)

{

ckb[i].setSelected(false);

}

textArea.setText("");

}

class MyButtonListener implements ActionListener

{

@Override
public void actionPerformed(ActionEvent e)

{

if (e.getActionCommand().equals(CLEAR))

{

clearButtons();

}

else if (e.getActionCommand().equals(TOTAL))

{

calcPrice();

}

}

}

}

Applet program:-

package pizza;
import java.applet.Applet;
import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class PizzaShoping extends Applet

{

JCheckBox ckb[];

JLabel jlb1;

JRadioButton radio[], radio1[];

static String[] pizzaToppings = "Tomato,Green peppper,Black olives,Mushrooms,Extra cheese,Pepproni,Sausage"

.split(",");

static String[] pizzaSizes = "Small: $6.50, Medium: $8.50, Large: $10".split(",");

static String[] pizzatypes = "Thin Crust, Mediam Crust, Pan".split(",");

static final String CLEAR = "clear";

static final String TOTAL = "total";

final ButtonGroup groupSizes = new ButtonGroup();

final ButtonGroup groupSizes1 = new ButtonGroup();

JPanel sizes, toppings, types;

JTextArea textArea;

static final private int[] PRICE_SIZES =

{ 650, 850, 1000 }; // pennies

public void init()

{

//super("Pizza Shop");

radio = new JRadioButton[pizzaSizes.length];

radio1 = new JRadioButton[pizzatypes.length];

ckb = new JCheckBox[pizzaToppings.length];

JPanel options = makeOptionsPanel();

add(options);

//setSize(800, 450);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setLocationRelativeTo(null);

setVisible(true);

}

private void setLocationRelativeTo(Object object) {
   // TODO Auto-generated method stub
  
}

private void setDefaultCloseOperation(int exitOnClose) {
   // TODO Auto-generated method stub
  
}

//public static void main(String[] args)

//{

//new PizzaShopping();

//}

private JPanel makeOptionsPanel()

{

sizes = addRadioBoxes(pizzaSizes, "Pizza Size", radio, groupSizes);

toppings = addCkBoxes(pizzaToppings, ckb);

types = addRadioBoxes(pizzatypes, "Pizza Type", radio1, groupSizes1);

JPanel size_type = new JPanel();

size_type.setLayout(new GridLayout(1, 2, 15, 10));

size_type.add(sizes);

size_type.add(types);

JPanel buttonControls = new JPanel();

buttonControls.setBorder(BorderFactory.createEmptyBorder(1, 10, 1, 10));

JButton clear = new JButton("Clear");

clear.setActionCommand(CLEAR);

clear.addActionListener(new MyButtonListener());

JButton total = new JButton("Process Selection");

total.setActionCommand(TOTAL);

total.addActionListener(new MyButtonListener());

buttonControls.add(clear);

buttonControls.add(total);

JPanel si_ty_cont = new JPanel();

si_ty_cont.setLayout(new GridLayout(2, 1, 15, 15));

si_ty_cont.add(size_type);

si_ty_cont.add(buttonControls);

JPanel p = new JPanel();

p.setLayout(new GridLayout(1, 2, 15, 15));

p.add(toppings);

p.add(si_ty_cont);

p.setAlignmentX(Component.LEFT_ALIGNMENT);

JPanel completePanel = new JPanel();

jlb1.setAlignmentX(Component.CENTER_ALIGNMENT);

completePanel.setLayout(new BoxLayout(completePanel, BoxLayout.PAGE_AXIS));
//setLayout(new BoxLayout(completePanel, BoxLayout.PAGE_AXIS));

JLabel jlb = new JLabel("Your order: ", SwingConstants.LEFT);

textArea = new JTextArea();

textArea.setRows(5);

JScrollPane sp = new JScrollPane(textArea);

sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

jlb1 = new JLabel("Welcome to Home Style Pizza Shop");

jlb1.setFont(new Font("Courier New", Font.BOLD, 20));

jlb1.setForeground(Color.RED);

completePanel.add(jlb1);

completePanel.add(Box.createVerticalGlue());

completePanel.add(p);

completePanel.add(Box.createVerticalGlue());

completePanel.add(jlb);

completePanel.add(sp);

return completePanel;

}

private void calcPrice()

{

int total = 0, subTotal = 0;

int priceIndex = 0, priceIndex1 = 0;

for (int i = 0; i < radio.length; i++)

{

if (radio[i].isSelected())

{

priceIndex = i;

break;

}

}

for (int i = 0; i < radio1.length; i++)

{

if (radio1[i].isSelected())

{

priceIndex1 = i;

break;

}

}

textArea.setText("");

StringBuilder sb = new StringBuilder();

sb.append(String.format("Pizza type: %s%n", pizzatypes[priceIndex1]));

sb.append(String.format("Pizza size: %s%n", pizzaSizes[priceIndex]));

sb.append("Toppings : ");

total += PRICE_SIZES[priceIndex];

String accumTops = "";

for (int i = 0; i < ckb.length; i++)

{

if (ckb[i].isSelected())

{

accumTops += "" + i + ",";

subTotal += 150;

}

}

if (!accumTops.isEmpty())

{

String[] orderedTops = accumTops.split(",");

for (int i = 0; i < orderedTops.length; i++)

{

sb.append(String.format("%s, ",

pizzaToppings[Integer.parseInt(orderedTops[i])]));

}

}

else

{

sb.append(String.format("%s%n"));

}

total += subTotal;

sb.append(String.format("\nAmount Due: $ %d.%2d%n", total / 100, total % 100));

textArea.setText(sb.toString());

}

private JPanel addRadioBoxes(String[] opts, String title, JRadioButton jrb[],

ButtonGroup bg)

{

int rows = opts.length;

JPanel p = new JPanel();

addBorder(p);

p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));

jlb1 = new JLabel(title);

jlb1.setFont(new Font("Courier New", Font.ROMAN_BASELINE, 18));

jlb1.setForeground(Color.RED);

p.add(jlb1);

JPanel p1 = new JPanel();

p1.setLayout(new GridLayout(rows, 1));

for (int i = 0; i < rows; i++)

{

jrb[i] = new JRadioButton(opts[i]);

p1.add(jrb[i]);

bg.add(jrb[i]);

}

p.add(p1);

return p;

}

private void addBorder(JPanel p)

{

p.setBorder(BorderFactory.createLineBorder(Color.RED));

}

private JPanel addCkBoxes(String[] opts, JCheckBox checkbox[])

{

int rows = opts.length;

JPanel p = new JPanel();

addBorder(p);

p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));

jlb1 = new JLabel("Each Topping at $1.50", SwingConstants.LEFT);

jlb1.setFont(new Font("Courier New", Font.ROMAN_BASELINE, 18));

jlb1.setForeground(Color.RED);

p.add(jlb1);

JPanel p1 = new JPanel();

p1.setLayout(new GridLayout(rows, 1));

for (int i = 0; i < rows; i++)

{

checkbox[i] = new JCheckBox(opts[i]);

p1.add(checkbox[i]);

}

p.add(p1);

return p;

}

private void clearButtons()

{

groupSizes.clearSelection();

groupSizes1.clearSelection();

for (int i = 0; i < ckb.length; i++)

{

ckb[i].setSelected(false);

}

textArea.setText("");

}

class MyButtonListener implements ActionListener

{

@Override
public void actionPerformed(ActionEvent e)

{

if (e.getActionCommand().equals(CLEAR))

{

clearButtons();

}

else if (e.getActionCommand().equals(TOTAL))

{

calcPrice();

}

}

}

}

Add a comment
Know the answer?
Add Answer to:
Convert the following GUI application into an Applet. Do not delete any part of the GUI...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please help me debug this Create a GUI for an application that lets the user calculate...

    please help me debug this Create a GUI for an application that lets the user calculate the hypotenuse of a right triangle. Use the Pythagorean Theorem to calculate the length of the third side. The Pythagorean Theorem states that the square of the hypotenuse of a right-triangle is equal to the sum of the squares of the opposite sides: alidate the user input so that the user must enter a double value for side A and B of the triangle....

  • Simple java questions Q2.java: import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Q2 extends JFrame { public static void createAndShowGUI() { JFrame frame = new JFrame(&#3...

    Simple java questions Q2.java: import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Q2 extends JFrame { public static void createAndShowGUI() { JFrame frame = new JFrame("Lab"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Font font = new Font("Sans-serif", Font.BOLD, 20); JLabel label = new JLabel("Enter a word"); label.setFont(font); JTextField textField = new JTextField(10); textField.setFont(font); JButton button = new JButton("Enter"); button.setFont(font); Font font1 = new Font("Sans-serif", Font.BOLD, 30); JCheckBox sansSerif = new JCheckBox("Sans-serif"); sansSerif.setFont(font1); JCheckBox serif= new JCheckBox("Serif"); serif.setFont(font1); Font font2 = new Font("Sans-serif", Font.ITALIC, 15); JRadioButton...

  • Objective: GUI Layout manager Download one of the sample GUI layout program. Use any GUI layout...

    Objective: GUI Layout manager Download one of the sample GUI layout program. Use any GUI layout to add buttons to start each sort and display the System.nanoTime in common TextArea panel. The question is a bit confusing so i will try to simplify it. Using the GUI ( I made a unclick able one so you have to make it clickable), allow a user to sort the text file based on what they click on. example: if i click merge...

  • Swing File Adder: Build a GUI that contains an input file, text box and Infile button....

    Swing File Adder: Build a GUI that contains an input file, text box and Infile button. It also must contain and output file, text box and Outfile button. Must also have a process button must read the infile and write to the outfile if not already written that is already selected and clear button. It must pull up a JFile chooser that allows us to brows to the file and places the full path name same with the output file.  Program...

  • With the Code below, how would i add a "Back" Button to the bottom of the...

    With the Code below, how would i add a "Back" Button to the bottom of the history page so that it takes me back to the main function and continues to work? import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextField; public class RecipeFinder { public static void main(String[]...

  • I have been messing around with java lately and I have made this calculator. Is there...

    I have been messing around with java lately and I have made this calculator. Is there any way that I would be able to get a different sound to play on each different button 1 - 9 like a nokia phone? Thank you. *SOURCE CODE* import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; class Calculator extends JFrame { private final Font BIGGER_FONT = new Font("monspaced",Font.PLAIN, 20); private JTextField textfield; private boolean number = true; private String equalOp = "="; private...

  • I have currently a functional Java progam with a gui. Its a simple table of contacts...

    I have currently a functional Java progam with a gui. Its a simple table of contacts with 3 buttons: add, remove, and edit. Right now the buttons are in the program but they do not work yet. I need the buttons to actually be able to add, remove, or edit things on the table. Thanks so much. Here is the working code so far: //PersonTableModel.java import java.util.List; import javax.swing.table.AbstractTableModel; public class PersonTableModel extends AbstractTableModel {     private static final int...

  • Can someone modify my code so that I do not get this error: Exception in thread...

    Can someone modify my code so that I do not get this error: Exception in thread "main" java.lang.NullPointerException at java.awt.Container.addImpl(Container.java:1043) at java.awt.Container.add(Container.java:363) at RatePanel.<init>(RatePanel.java:64) at CurrencyConverter.main(CurrencyConverter.java:16) This code should get the amount of money in US dollars from user and then let them select which currency they are trying to convert to and then in the textfield print the amount //********************************************************************* //File name: RatePanel.java //Name: Brittany Hines //Purpose: Panel for a program that convers different currencyNamerencies to use dollars //*********************************************************************...

  • JAVA Hello I am trying to add a menu to my Java code if someone can...

    JAVA Hello I am trying to add a menu to my Java code if someone can help me I would really appreacite it thank you. I found a java menu code but I dont know how to incorporate it to my code this is the java menu code that i found. import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ButtonGroup; import javax.swing.JCheckBoxMenuItem; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JRadioButtonMenuItem; public class MenuExp extends JFrame { public MenuExp() { setTitle("Menu Example");...

  • Lab Assignment : In this lab, you are going to implement QueueADT interface that defines a...

    Lab Assignment : In this lab, you are going to implement QueueADT interface that defines a queue. Then you are going to use the queue to store animals. 1. Write a LinkedQueue class that implements the QueueADT.java interface using links. 2. Textbook implementation uses a count variable to keep track of the elements in the queue. Don't use variable count in your implementation (points will be deducted if you use instance variable count). You may use a local integer variable...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT