Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone rewrite this in utilizing JavaFX application only? Right now it's using Java Swing and old awt libraries, but I want this to be

Can someone rewrite this in utilizing JavaFX application only? Right now it's using Java Swing and old awt libraries, but I want this to be in JavaFX application only since Java Swing is outdated. The output is supposed to display GUI window that allows the user to select one deck, one truck assembly, and one wheel set from either listView controls or ComboBox controls. Then the JavaFX application should display the subtotal, amount of sales tax at 7%, and the total of the order in the GUI window.

import java.awt.Color; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.ListSelectionModel; public class Skateboards extends JFrame implements ActionListener{ public JComboBox wheels; public JComboBox trucks; public JComboBox decks; public JLabel deckLabel; public JLabel truckLabel; public JLabel wheelLabel; public JLabel miscLabel; public JLabel subLabel; public JLabel subtotal; public JLabel totalLabel; public JLabel total; public JLabel taxLabel; public JLabel tax; public JList misc; public JButton calculate; public String []deckString = {"Master Thrasher", "Dictator", "Street King"}; public String[] truckString = {"7.75 inch axle", "8 inch axle", "8.5 inch axle"}; public String[] wheelString = {"51 mm", "55 mm", "61 mm"}; public String[] miscString = {"Grip Tape", "Bearings","Riser Pads", "Nuts and Bolts Kit"}; public int[] deckPrices = {60, 45, 50}; public int[] truckPrices = {35, 40, 45}; public int[] wheelPrices = {20, 22, 28}; public int[] miscPrices = {10, 30, 2, 3}; public Skateboards(){ setSize(550,300); setTitle("Skateboard Shop"); setLocation(150,150); Container contentPane = getContentPane(); contentPane.setLayout(null); contentPane.setBackground(Color.WHITE); deckLabel = new JLabel("Decks:"); deckLabel.setBounds(57,17,80,25); contentPane.add(deckLabel); decks = new JComboBox(deckString); decks.setBounds(5,40,150, 25); contentPane.add(decks); decks.setSelectedIndex(2); truckLabel = new JLabel("Trucks:"); truckLabel.setBounds(240,17,80,25); contentPane.add(truckLabel); trucks = new JComboBox(truckString); trucks.setBounds(190,40,150, 25); contentPane.add(trucks); trucks.setSelectedIndex(2); wheelLabel = new JLabel("Wheels:"); wheelLabel.setBounds(430,17,80,25); contentPane.add(wheelLabel); wheels = new JComboBox(wheelString); wheels.setBounds(375,40,150, 25); contentPane.add(wheels); wheels.setSelectedIndex(2); misc = new JList(miscString); //data has type Object[] misc.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); misc.setLayoutOrientation(JList.HORIZONTAL_WRAP); misc.setVisibleRowCount(-1); misc.setBounds(200, 100, 160, 80); contentPane.add(misc); miscLabel = new JLabel("Miscellaneous Services:"); miscLabel.setBounds(190,75, 150, 25); contentPane.add(miscLabel); subLabel = new JLabel("Subtotal: "); subLabel.setBounds(150,210,120,25); contentPane.add(subLabel); totalLabel = new JLabel("Total: "); totalLabel.setBounds(170, 250, 120, 25); contentPane.add(totalLabel); total = new JLabel(); total.setBounds(210, 250, 120, 25); contentPane.add(total); subtotal = new JLabel(); subtotal.setBounds(210, 210, 80, 25); contentPane.add(subtotal); taxLabel = new JLabel("Tax: "); taxLabel.setBounds(175,230,80,25); contentPane.add(taxLabel); tax = new JLabel(); tax.setBounds(210, 230, 80, 25); contentPane.add(tax); calculate = new JButton("Calculate"); calculate.setBounds(200,180,120,25); contentPane.add(calculate); calculate.addActionListener(this); } public static void main(String[] args) { Skateboards shop = new Skateboards(); shop.setVisible(true); shop.setDefaultCloseOperation(EXIT_ON_CLOSE); } @Override public void actionPerformed(ActionEvent arg0) { calculateTotal(); } public void calculateTotal(){ int wheelIndex = wheels.getSelectedIndex(); int deckIndex = decks.getSelectedIndex(); int truckIndex = trucks.getSelectedIndex(); int[] miscArray = misc.getSelectedIndices(); int miscTotal = 0; for(int i =0; i

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

Step: 3

blur-text-image

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

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions