help making a GUI

I think I'm almost done

Page 1 of 1

5 Replies - 1281 Views - Last Post: 17 June 2007 - 06:23 PM Rate Topic: -----

#1 lindy87124  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 02-March 07

help making a GUI

Post icon  Posted 15 June 2007 - 08:30 PM

I think I got what I need for the primary part of the program. The only exceptions are that I am not sure why it won't calculate the inventoryValue, I still need to add the calculation of the 5% re-stock fee and the calculation for the entire inventory. After I get that all I'll need help with is creating the GUI.
Here is the code that runs beautifully!
public class cdinventory
{
	String cdName;
	int itemNumber;
 	int quantity;
 	double unitPrice;
 	
 	public void setCdName (String name)
 	{
 		cdName = name;
 	}//end setCdName
 	
 	public void setItemNumber (int number)
 	{
 		itemNumber = number;
 	}//end setItemNumber
 	
 	public void setQuantity (int quant)
 	{
 		quantity = quant;
 	}//end setQuantity
 	
 	public void setUnitPrice (double price)
 	{
 		unitPrice = price;
 	}//end setUnitPrice
 	
 	public String getCdName ()
 	{
 		return cdName;
 	}//end getCdName
 	
 	public int getItemNumber ()
 	{
 		return itemNumber;
 	}//end getItemNumber
 	
 	public int getQuantity ()
 	{
 		return quantity;
 	}//end getQuantity
 	
 	public double getUnitPrice ()
 	{
 		return unitPrice;
 	}//end getUnitPrice
 	
 	public class artist extends cdinventory
 	{
 		String artistName;
 		
 		public void setArtistName (String artist)
 		{
 			artistName = artist;
 		}//end setArtistName
 		
 		public String getArtistName ()
 		{
 			return artistName;
 		}//end getArtistName
 		 		
 	}//end class artist

	public static void main (String[] args)
	{
		cdinventory cd = new cdinventory();
		cd.setCdName (" ");
		cd.setItemNumber (000);
		cd.setQuantity (10);
		cd.setUnitPrice (5.99);
		System.out.println("CD Name: " + cd.getCdName());
		System.out.println("CD Number: " + cd.getItemNumber());
		System.out.println("Number in stock: " + cd.getQuantity());
		System.out.println("Price each:$ " + cd.getUnitPrice());
		int quantity = 0;
		double unitPrice = 0.00;
		double inventoryValue = quantity * unitPrice;
		System.out.println("The value of the inventory for this cd is:$ "+ inventoryValue);
		
		int [] inventory;
 		inventory = new int [1000];
	
		
 	}//end method main
 }//end class cdinventory


I am starting to get excited! I think I can finally see the light at the end of the tunnel!!!
If someone can just guide me in how to do the calculations and GUI I will be done!
:D

This post has been edited by lindy87124: 15 June 2007 - 08:34 PM


Is This A Good Question/Topic? 0
  • +

Replies To: help making a GUI

#2 GWatt  Icon User is offline

  • member icon

Reputation: 257
  • View blog
  • Posts: 3,035
  • Joined: 01-December 05

Re: help making a GUI

Posted 16 June 2007 - 05:55 AM

Well, I don't know what sort of calculations you want, so I'll skip to the GUI.
I think the best place to learn this is to go to the java.sun.com site, and look at the tutorials.

Here is one such tutorial:
http://java.sun.com/...torial/uiswing/
Was This Post Helpful? 0
  • +
  • -

#3 THE_RAM  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 30-March 07

Re: help making a GUI

Posted 16 June 2007 - 02:29 PM

well, the first thing to do when creating a GUI-based application I would suggest you to do is to use the import javax.swing.JOptionPane but I usually use this one for applets; or you could use import javax.swing.JFrame.

I have attached a sample of how to create a basic interface using the JFrame.

Attached File(s)


This post has been edited by THE_RAM: 16 June 2007 - 02:31 PM

Was This Post Helpful? 0
  • +
  • -

#4 lindy87124  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 02-March 07

Re: help making a GUI

Posted 17 June 2007 - 02:02 PM

View PostGWatt, on 16 Jun, 2007 - 05:55 AM, said:

Well, I don't know what sort of calculations you want, so I'll skip to the GUI.
I think the best place to learn this is to go to the java.sun.com site, and look at the tutorials.

Here is one such tutorial:
http://java.sun.com/...torial/uiswing/

Thanks for your information.
First, the calculations I need are that the program has to calculate the inventory of the individual item and add a 5% re-stock fee, then it has to calculate the entire inventory.
BTW, I have checked out the Sun Java tutorial and to me, it is very confusing because it shows a different way of creating a GUI than what my book shows or what other tutorials I have looked at show.

Quote

well, the first thing to do when creating a GUI-based application I would suggest you to do is to use the import javax.swing.JOptionPane but I usually use this one for applets; or you could use import javax.swing.JFrame.

Thank you. I think what I need to use is a JOptionPane because this GUI has to have buttons (First, Next, Previous, Last, Add, Delete, Modify). It also has to display all of the information related to the individual CD as well as the re-stock fee and total value of the entire inventory. Does anyone have any suggestions?
Was This Post Helpful? 0
  • +
  • -

#5 lindy87124  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 02-March 07

Re: help making a GUI

Posted 17 June 2007 - 02:51 PM

Okay, Here is an exact list of what this GUI needs to have. I am kind of working on a code for it, but it is very difficult.
  • the GUI must display the information for each product, one at a time, including item name, number, number of units in-stock, price per unit, value of the inventory of that item, artits name, re-stock fee, and total value of the entire inventory.
  • the GUI must have buttons that allow the user to move to the first item, next item, previous item and last item. if the user is displaying the first item and and clicks on the "previous" button, the last item should display. If the user is on the last item and clicks the "next" button the first item should display.
  • the GUI should include an "Add" button, "Delete" button, and a "Modify" button. These buttons should perform the corresponding actions. If an item is added to the inventory, an item number should be added that is one number more than the previous item.
  • the GUI should include a save button that saves the inventory to a C:\data\inventory.dat file
  • the GUI should include a search button that allows the user to search for an item using the item name or the item number. If the item is not found, an appropriate message should display. If the item is found, the corresponding information should display.
  • the GUI should include a company logo of some sort

Was This Post Helpful? 0
  • +
  • -

#6 lindy87124  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 02-March 07

Re: help making a GUI

Posted 17 June 2007 - 06:23 PM

Okay. Here is what I have for my GUI code
import javax.swing.*; 
import java.awt.*; 

public class window extends JFrame { 
	 public window() 
	 { 
		 super("CD Inventory"); 
		 setSize(350, 355); 
		 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
		 setVisible(true); 
		 Container pane = getContentPane(); 
		 FlowLayout flo = new FlowLayout(); 
		 pane.setLayout(flo); 
		 JButton add = new JButton("Add"); 
		 JButton delete = new JButton("Delete"); 
		 JButton modify = new JButton("Modify"); 
		 JButton first = new JButton("First"); 
		 JButton next = new JButton("Next"); 
		 JButton previous = new JButton("Previous"); 
		 JButton last = new JButton("Last"); 
		 JButton save = new JButton("Save"); 
		 pane.add(add); 
		 pane.add(delete); 
		 pane.add(modify); 
		 pane.add(first); 
		 pane.add(next); 
		 pane.add(previous); 
		 pane.add(last); 
		 pane.add(save); 
		 setContentPane(pane);
		 
		 JLabel pageLabel = new JLabel("Search: ", JLabel.RIGHT); 
		 JTextField pageAddress = new JTextField(20); 
		 pane.add(pageLabel); 
		 pane.add(pageAddress); 
		 setContentPane(pane); 
	 }  


The problem I am having is that I can't get my layout just right. I have been researching various layout managers, but I'm not sure which one to use. I thought that the ones that I used above would make the layout the way I wanted but it didn't. Can anyone help?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1