Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need Help with adding the listed arrays to this JAVA GUI instead of Strings and the output should be displayed in a text Area below

Need Help with adding the listed arrays to this JAVA GUI instead of Strings and the output should be displayed in a text Area below similar to this

ex. Type: Magazine " "ID: " "Title " "Type" "release Date " "Price" "Quantity "

The program should end give a message dialog stating what has been checked out.

image text in transcribed

import javax.swing.*; import java.awt.event.ActionListener; import java.awt.Component; import java.awt.event.*;

public class Genre{ JFrame f; private Component component;

Genre() { f=new JFrame("Libary Inventory Manager"); JLabel label = new JLabel("", JLabel.CENTER); label.setText("Welcome To the Libaray Manager You Have 4 Selections To Choose From!"); label.setOpaque(true); label.setBounds(50,50,570,20); JLabel label1 = new JLabel("", JLabel.CENTER); label1.setText(""); label1.setOpaque(true); label1.setBounds(50,450,400,20); //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JButton b=new JButton("Checkout"); b.setBounds(275,300,200,50); String Books[]={"Books","Calculus Early Trancendentals","Under the Stars","Cat in The Hat","The Betrayal of the Seven","The Story of the Twins","Fighters"}; final JComboBox cb=new JComboBox(Books); cb.setBounds(5, 100,150,40); String Magazines[]={"Magazines","Skateboading Made Simple","Tilted Streamers","Best Home furniture for 2017!","Celebrity Gossip!","Scientific Advancements of Solar Energy","Best Looking homes of 2017!"}; final JComboBox cb1=new JComboBox(Magazines); cb1.setBounds(190, 100,170,40); f.add(cb1); String CDS[]={"CDS","Recovery","Best Jazz of the 70's","KidsBop12","Millenium","Curt Cobain Secret Tracks","2016 Best Hits"}; final JComboBox cb2=new JComboBox(CDS); cb2.setBounds(390, 100,170,40); f.add(cb2); String Articles[]={"Articles","Wars In the Middle East","Drugs on Wall Street","Most popular Instruments","Scanning for Gold","Bringing back Americas Jobs","Legendary Sea Creatures"}; final JComboBox cb3=new JComboBox(Articles); cb3.setBounds(610, 100,170,40); f.add(cb3); f.add(cb); f.add(label); f.add(label1); f.add(b);

f.setLayout(null); f.setSize(800,650); f.setVisible(true); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(cb.getSelectedIndex()>0) {String data = "You Added: " + cb.getItemAt(cb.getSelectedIndex()); label1.setText(data); cb.setSelectedIndex(0); cb1.setSelectedIndex(0); cb2.setSelectedIndex(0); cb3.setSelectedIndex(0); } else if(cb1.getSelectedIndex()>0) {String data1 = "You Added: " + cb1.getItemAt(cb1.getSelectedIndex()); label1.setText(data1); cb.setSelectedIndex(0); cb1.setSelectedIndex(0); cb2.setSelectedIndex(0); cb3.setSelectedIndex(0); } else if(cb2.getSelectedIndex()>0) {String data2 = "You Added: " + cb2.getItemAt(cb2.getSelectedIndex()); label1.setText(data2); cb.setSelectedIndex(0); cb1.setSelectedIndex(0); cb2.setSelectedIndex(0); cb3.setSelectedIndex(0); } else if(cb3.getSelectedIndex()>0) {String data3 = "You Added: " + cb3.getItemAt(cb3.getSelectedIndex()); label1.setText(data3); cb.setSelectedIndex(0); cb1.setSelectedIndex(0); cb2.setSelectedIndex(0); cb3.setSelectedIndex(0); } else {label1.setText("Please Pick One Of The Listed Please!"); } } }); } int returnValue = JOptionPane.showConfirmDialog( component,"Ready To Checkout? "); String message = null;{ if (returnValue == JOptionPane.YES_OPTION) { message = "Yes"; } else if (returnValue == JOptionPane.NO_OPTION) { message = "No"; System.exit(0); } else if (returnValue == JOptionPane.CANCEL_OPTION) { message = "Cancel"; System.exit(0); } else if (returnValue == JOptionPane.CLOSED_OPTION) { message = "Closed"; System.exit(0); } } public static void main(String[] args) { new Genre(); } }

Arrays to be added

LibraryItem[] Books = new LibraryItem[max]; Books[0] = new Book(215231,"Calculus Early Trancendentals","19 April 2000","James Stewart",50,4); Books[1] = new Book(31241, " Under the Stars ","January 12 2006", "Jake Timer",21,3); Books[2] = new Book(1100 , "Cat in The Hat" , "April 21 1992" , "Dr.Seuss" ,15,4); Books[3] = new Book(1100 , "The Betrayal of the Seven" , "April 21 1990" , "Robert Baldwin",23 ,3); Books[4] = new Book(1100 , "The Story of the Twins" , "June 2 1832" , "Eleanor Tulip" ,45,3); Books[5] = new Book(1100 , "Fighters" , "April 16 1945" , "Susie Gold" ,5,2); LibraryItem[] Magazines = new LibraryItem[max]; Magazines[0] = new Magazine(2313,"Skateboading Made Simple","Skateboarding","26 June 2013",15,3); Magazines[1] = new Magazine(2600,"Tilted Streamers", "Comedy", "23 July 2017",13,4); Magazines[2] = new Magazine(1133,"Best Home furniture for 2017!","Informational", "12 December 2012",5,6); Magazines[3] = new Magazine(999,"Celebrity Gossip!","Celebrity","7 June 2014",16,23); Magazines[4] = new Magazine(232,"Scientific Advancements of Solar Energy","Science,", "15 August 2016",12,4); Magazines[5] = new Magazine(1780, "Best Looking homes of 2017!","Home Improvement","1 October 2016",5,6); LibraryItem[] Articles = new LibraryItem[max]; Articles[0] = new Article(214,"Wars In the Middle East","History",15,4); Articles[1] = new Article (66,"Drugs on Wall Street","Informational",6,6); Articles[2] = new Article(25,"Most popular Instruments", "Music Info",12,6); Articles[3] = new Article(62,"Scanning for Gold","Informational",7,8); Articles[4] = new Article(15,"Bringing back Americas Jobs","Political", 6,10); Articles[5] = new Article(66,"Legendary Sea Creatures","Oceanography",12,7); ElectronicMedia[] CDS = new ElectronicMedia[max]; CDS[0] = new CD("Jazz" ,"15:00" , "Best Jazz of the 70's",20,4); CDS[1] = new CD("Pop"," 12;31", "Kids Bop 12",15,7); CDS[2] = new CD("Hip-Hop","37:00","Recovery",12,4); CDS[3] = new CD("Pop","13:00","Millenium",20,3); CDS[4] = new CD("Rock","7:36","Curt Cobain Secret Tracks",12,5); CDS[5] = new CD("Pop","15:00","2016 Best Hits",12,6);

Libary Inventory Manager Welcome To the Libaray Manager You Have 4 Selections To Choose From! Books Magazines CDS Check ou You Added: Calculus Early Trancendentals Articles Libary Inventory Manager Welcome To the Libaray Manager You Have 4 Selections To Choose From! Books Magazines CDS Check ou You Added: Calculus Early Trancendentals Articles

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

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago