Hello again!
In class we started this chapter on Graphics and I am struggling to understand it, it seems like it all hit me at once, I did the readings but it just seems like gibberish.
My problem, is that in the GUI it keeps overriding the last data it put up.
Here's my code:
First the GUI
//CameraGUI import javax.swing.*; import java.awt.*; public class CameraGUI extends JFrame { JTextArea ta = new JTextArea(25,40); JScrollPane sp = new JScrollPane(ta, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); JPanel pane = new JPanel(); public CameraGUI() { super("Camera Inventory Program"); setDefaultCloseOperation(EXIT_ON_CLOSE); setBounds(100,100,500,500); pane.add(sp); add(pane); setVisible(true); } }
Then the Main program
//Thomas Harrald //IT215 Checkpoint Inventory Program //Camera Inventory program import java.util.Arrays; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.IOException; // Stores and then gets info on a Camera public class CameraProgram4 { static CameraGUI mainGUI = new CameraGUI(); public static void main(String args[]) { CameraClass[] cameras; CameraClass nikonCamera= new CameraClass( 3100, "Nikon", "Electronics", 5, 10.00); CameraClass sonyCamera = new CameraClass( 4500, "Sony", "Electronics", 10, 300.00); CameraClass canonCamera= new CameraClass( 1550, "Canon", "Electronics", 3, 40.00); DigitalCamera kodakCamera = new DigitalCamera( 3000, "Kodak", "Electronics", 20,5.00, 1080); cameras = new CameraClass[ 4 ]; cameras[ 0 ] = nikonCamera; cameras[ 1 ] = sonyCamera; cameras[ 2 ] = canonCamera; cameras[ 3 ] = kodakCamera; mainGUI.ta.setText(cameras[0].toString()); mainGUI.ta.setText(cameras[1].toString()); } }
If someone needs the other two files I can put them up.