Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-12-2008, 05:41 PM
Member
 
Join Date: Sep 2008
Posts: 3
sabrown311313 is on a distinguished road
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;

/
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-12-2008, 07:53 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,545
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Please exactly tell me where are you stuck now. Testing a code and fix is not a practical thing actually.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 09-13-2008, 12:18 AM
Member
 
Join Date: Sep 2008
Posts: 3
sabrown311313 is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 09-13-2008, 02:17 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
Norm is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 09-13-2008, 08:28 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,545
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Yes it is, you must read/work a lot about swing. At least check all examples of our member, hardwired.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object creation and memory issues bugger New To Java 11 11-29-2007 02:56 PM
Java Applet re-creation problem Mikalai.Kardash Java Applets 0 07-23-2007 04:09 PM
creation of new function an8086 Advanced Java 1 07-16-2007 04:20 PM
creation of new folder in the mail an8086 Advanced Java 1 07-15-2007 07:10 PM
An Introduction to Eclipse PDE - File Creation JavaForums Eclipse 0 05-09-2007 08:40 AM


All times are GMT +3. The time now is 08:10 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org