Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i want to add image for my java GUI program so please help me. i want to add image to be in top of the

i want to add image for my java GUI program so please help me. i want to add image to be in top of the program as in the picture.Please put any random picture for burger so i can see the output and Please mention what lines you used to put the image.

this is the colde

import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener;

import javax.swing.*;

interface GUI { static final JFrame frame = new JFrame("BURGER RESTAURANT "); static final JButton button = new JButton("Make an Order"); static final JLabel menu1 = new JLabel("Menu"); static final JLabel co = new JLabel("Customize Order: "); final String a[] = { "none", "Cola", "Sprite", "Mirinda" }; static final JComboBox co1 = new JComboBox(a); static final JLabel drinks =new JLabel("Drinks : ");

static final JLabel sizeLabel =new JLabel("Size : "); static final JRadioButton regular = new JRadioButton("Regular"); static final JRadioButton large = new JRadioButton("Large"); final String s[] = { "Fish Burger", "Chicken Burger", "Classic Burger", "Double Burger", "Fries" }; final int priceArray[] = {11, 13 ,15 , 18, 10}; static final JComboBox menu = new JComboBox(s); static final JTextField result = new JTextField(); static final JLabel eA=new JLabel("Enter Amount: "); static final JButton makeP = new JButton("Make Payment"); static final JButton total = new JButton("View Total"); static final JLabel totalA = new JLabel("Total Amount:Press Calculate Total"); static final JLabel last=new JLabel("Thanks for Visiting Us..!!");

static final JCheckBox Tomatoes = new JCheckBox("Tomatoes"); static final JCheckBox lettuce = new JCheckBox("lettuce"); static final JCheckBox Onions = new JCheckBox("Onions"); static final JCheckBox pickled = new JCheckBox("pickled"); static final JCheckBox ketchup = new JCheckBox("ketchup"); static final JCheckBox cheese = new JCheckBox("cheese");

}

//Implemented Inheritance public class Burger12 implements GUI { //Implemeted Encapsulation private static int totalAmount = 0;

public static void calculateTotal(String S,int a) { totalAmount=0; if(a>0) { totalAmount+=a; } for(int i=0;i

public static void calculateTotal(String S,String co,int a) { totalAmount=0; if(a>0) { totalAmount+=a; } for(int i=0;i

break;

} } }

public static void main(String[] args) { button.setBounds(50, 30, 150, 30); frame.add(button); frame.setSize(300, 300); frame.setLayout(null); frame.setVisible(true); Image logo = Toolkit.getDefaultToolkit().getImage("burger.jpg"); frame.setIconImage(logo); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button.setBounds(0, 0, 0, 0); menu1.setBounds(100, 100, 200, 30); co.setBounds(100, 150, 200, 30); sizeLabel.setBounds(100, 260,100,30); regular.setBounds(400, 260, 100, 30); large.setBounds(500, 260, 100, 30); menu.setBounds(400, 100, 200, 30); co1.setBounds(400, 300, 200, 30); drinks.setBounds(100, 300, 200, 30); Tomatoes.setBounds(400, 150, 100,30); frame.add(Tomatoes); Onions.setBounds(400, 180, 100,30); frame.add(Onions); ketchup.setBounds(400, 210, 100,30); frame.add(ketchup); lettuce.setBounds(510, 150, 100,30); frame.add(lettuce); pickled.setBounds(510, 180, 100,30); frame.add(pickled); cheese.setBounds(510, 210, 100,30); frame.add(cheese); total.setBounds(100, 350, 300, 30); totalA.setBounds(100, 400, 500, 30); makeP.setBounds(0,0,0,0); frame.add(sizeLabel); frame.add(totalA); frame.add(total); frame.add(co1); frame.add(drinks); frame.add(menu1); frame.add(co); frame.add(regular); frame.add(eA); frame.add(large); frame.add(result); frame.add(menu); frame.add(last); frame.add(result); frame.add(makeP); frame.resize(700, 700); frame.revalidate(); frame.repaint(); //labmda exprmisson regular.addActionListener((ActionEvent e1) -> { large.setSelected(false); }); large.addActionListener((ActionEvent e1) -> { regular.setSelected(false); }); total.addActionListener((ActionEvent e1) -> { int totalCustomizationPrice = 0; int customizationPrice = 3; // for every customization $3 will be added if(Tomatoes.isSelected()) totalCustomizationPrice += customizationPrice; if(Onions.isSelected()) totalCustomizationPrice += customizationPrice; if(ketchup.isSelected()) totalCustomizationPrice += customizationPrice; if(lettuce.isSelected()) totalCustomizationPrice += customizationPrice; if(pickled.isSelected()) totalCustomizationPrice += customizationPrice; if(cheese.isSelected()) totalCustomizationPrice += customizationPrice; String S=menu.getItemAt(menu.getSelectedIndex()); String co1Text = co1.getItemAt(co1.getSelectedIndex()); if(co1Text.equals("")||co1Text == null||co1Text.equals("none")) { if(regular.isSelected()) { calculateTotal(S,totalCustomizationPrice + 5); }else { calculateTotal(S,totalCustomizationPrice + 8); } }else { int drinkPrice = 3; if(regular.isSelected()) { calculateTotal(S,co1Text,totalCustomizationPrice + drinkPrice + 5); }else { calculateTotal(S,co1Text,totalCustomizationPrice + drinkPrice + 8); } } totalA.setText("Total Amount: "+totalAmount); makeP.setBounds(100,500,300,30); eA.setBounds(100,450,200,30); result.setBounds(400,450,200,30); makeP.addActionListener((ActionEvent e2) -> { double z=Double.parseDouble(result.getText().toString()); if(z

image text in transcribed

Image here Menu Fish Burger Customize Order: Tomatoes lettuce Onions pickled ketchup che Size : Regular Large Drinks : none View Total Total Amount:Press Calculate Total

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

2. Discuss various aspects of the training design process.

Answered: 1 week ago

Question

5. Discuss the key roles for training professionals.

Answered: 1 week ago