Results 1 to 5 of 5
  1. #1
    sabrown311313 is offline Member
    Join Date
    Sep 2008
    Posts
    3
    Rep Power
    0

    Default Java GUI creation help?

    Im trying to create a GUI which would display the information one
    product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, restocking fee, and the value of the inventory of that product. Any advice or help



    Here is my code:

    import java.util.Scanner;
    import java.util.Arrays;

    public class InventoryProgramPart3
    {

    // main method begins program execution
    public static void main(String args[] )
    {
    // create Scanner to obtain input from command window
    Scanner input = new Scanner( System.in );

    // display a welcome message to the InventoryProgramPart3 user
    System.out.println( "Welcome to Inventory Program Part 3!" );

    // office softwares

    softwares[] softwares = new softwares[100]; // an array of 100 supplies

    softwares buisness = new softwares( 4000, "Microsoft Office 2007", 60, 120.75 );
    softwares security = new softwares( 5000, "Norton Internet Security 2009", 75, 75.00 );
    softwares games = new softwares( 2000, "World of Warcraft Pc Game", 30, 66.00 );
    softwares os1 = new softwares( 1000, "Windows Vista", 15, 245.25 );
    softwares os2 = new softwares( 3000, "Windows XP", 45, 175.50 );

    // display the inventories one at a time
    os1.showInventory();
    games.showInventory();
    os2.showInventory();
    buisness.showInventory();
    security.showInventory();

    // sort softwares by name
    for ( int i = 0; i < args.length; i++ )
    System.out.println( args + ", " );

    double array[] = { 78.75, 142.50, 157.50, 165.00, 93.75 };
    double total = 0;

    // add each element's value to total
    for ( int counter = 0; counter < array.length; counter++)
    total += array[ counter ];
    System.out.printf( "\nTotal inventory value is: $%.2f\n", total );

    System.out.println( "\nThank you for using Inventory Program Part 3!\n" );

    } // end method main

    } // end class InventoryProgramPart3

    // Office Softwares
    class softwares
    {
    public int softwareNumber;
    public String softwareName = new String();
    public int softwareUnits;
    public double softwarePrice;

    // set software number
    public void setSoftwareNumber( int number )
    {
    this.softwareNumber = number;
    } // end method set softwares number

    // return software number
    public int getSoftwareNumber()
    {
    return softwareNumber;
    } // end method get softwares number

    // set softwares name
    public void setSoftwaresName( String name )
    {
    this.softwareName = name;
    } // end method set softwares name

    // return softwares name
    public String getSoftwaresName()
    {
    return softwareName;
    } // end method get softwares name

    // set softwares in stock
    public void setSoftwaresUnits( int units )
    {
    this.softwareUnits = units;
    } // end method set softwares units

    // return softwares units
    public int getSoftwaresUnits()
    {
    return softwareUnits;
    } // end method get softwares units

    // set Softwares price
    public void setSoftwaresPrice( double price )
    {
    this.softwarePrice = price;
    } // end method set softwares price

    // return softwares price
    public double getSoftwaresPrice()
    {
    return softwarePrice;
    } // end method get softwares price

    // calculate softwares inventory value
    public double getValue()
    {
    return softwareUnits * softwarePrice;
    } // end method softwares inventory value

    // four-argument constructor
    softwares(int number,String name,int units,double price )
    {
    softwareNumber = number;
    softwareName = name;
    softwareUnits = units;
    softwarePrice = price;
    } // end four-argument constructor

    // display inventory
    public void showInventory()
    {
    System.out.println(); // outputs blank line

    System.out.println( "Product Number: "+softwareNumber );
    System.out.println( "Product Name: "+softwareName );
    System.out.println( "Number of Units: "+softwareUnits );
    System.out.printf( "Unit Price: $%.2f",+softwarePrice );

    // value() method and display the value
    System.out.printf( "\nInventory value of "+softwareName+ " is = $%.2f\n",
    getValue() );

    } // end display inventory

    } // end class softwares

    class manufacturer extends softwares
    {
    // holds the softwares manufacturer
    private String softwaresManufacturer;

    /

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Please exactly tell me where are you stuck now. Testing a code and fix is not a practical thing actually.

  3. #3
    sabrown311313 is offline Member
    Join Date
    Sep 2008
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Please exactly tell me where are you stuck now. Testing a code and fix is not a practical thing actually.
    I cant figure out how to output to a GUI for this code

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,581
    Rep Power
    25

    Default

    Start by reading the Java Tutorial for Swing. Swing is the GUI part of java. Read about classes like JFrame, JPanel, and many many more. Not something that can be done in a day or week.
    Search for examples on the forum. JFrame should get you lots of examples. Or look at the posts by hardwired, he's posted lots of working code.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Object creation and memory issues
    By bugger in forum New To Java
    Replies: 11
    Last Post: 11-29-2007, 12:56 PM
  2. Java Applet re-creation problem
    By Mikalai.Kardash in forum Java Applets
    Replies: 0
    Last Post: 07-23-2007, 02:09 PM
  3. creation of new function
    By an8086 in forum Advanced Java
    Replies: 1
    Last Post: 07-16-2007, 02:20 PM
  4. creation of new folder in the mail
    By an8086 in forum Advanced Java
    Replies: 1
    Last Post: 07-15-2007, 05:10 PM
  5. An Introduction to Eclipse PDE - File Creation
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 05-09-2007, 06:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •