{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

INVENTORYPROGRAMPART6 - To change this template choose...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package inventoryprogrampart6; import javax.swing.*; import java.awt.event.*; import java.util.*; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import javax.swing.JPanel; /** * * @author janaya */ public class INVENTORYPROGRAMPART6 { /** * @param args the command line arguments */ public static void main(String[] args) { // Application_DVD gui = new Application_DVD(); gui.pack(); gui.setVisible(true); } // } //Stores and then gets info on a DVD //Stores a DVD final class Application_DVD extends JFrame { private JTextArea txt; private Inventory inv; private int currentDisplay = 0; private JTextArea text; public Application_DVD() { super("DVD Program"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // quit if the window is closed init(); } public void init() { //make 3 objects ExtendedDVD p1 = new ExtendedDVD(1, "Tyler Perry's I Can Do Bad All By Myself", 3, 14.99, "24 hours"); ExtendedDVD p2 = new ExtendedDVD(2, "Shottas", 5, 19.99, "22 hours"); ExtendedDVD p3 = new ExtendedDVD(3, "Wanted", 4, 18.99, "18 hours"); // make an inventory and put in the objects
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
inv = new Inventory(); inv.add(p1); inv.add(p2); inv.add(p3); inv.sort(); // output the info for (int i = 0; i < inv.size(); i++) { System.out.println("Item number: " + inv.get(i).getItem()); System.out.println("DVD name: " + inv.get(i).getName()); System.out.println("Units in stock: " + inv.get(i).getUnits()); System.out.println("Price: $" + String.format("%.2f",inv.get(i).getPrice())); System.out.println("Total value: $" + String.format("%.2f",inv.get(i).value())); System.out.println("Fee: $" + String.format("%.2f",inv.get(i).fee())); System.out.println(); } //total val System.out.println("Total value: $" + String.format("%.2f",inv.value())); //graphical interface JPanel panel = new JPanel(); txt = new JTextArea(15,20); txt.setEditable(false);//user shouldn't change it panel.add(txt); JPanel buttonpanel = new JPanel(); buttonpanel.setLayout(new BoxLayout(buttonpanel,BoxLayout.Y_AXIS)); JPanel anotherbuttonpanel = new JPanel(); anotherbuttonpanel.setLayout(new BoxLayout(anotherbuttonpanel,BoxLayout.Y_AXIS)); JButton first = new JButton("First"); first.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) {
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}