0

Fields must also be initialized!!!
duh!!
Thank you so much. This has of course pointed out other errors that I need to work on. But you have helped me so much today.
I enjoy the interaction.

I knew you would spot it if you kept looking :)

0

A few questions.
1. Formatting the output of the Jlist. My Pane has a window there and I can see what I entered, but it is just one big line of text. Where can I go to find ways to "pretty that up"
2. The fields I have that should perform calculations do not. I can enter anything I want there. Is this a result of the Jlist, or because I have them set wrong in my class?
3. Tab moves from one field to the next, until it is time to go to the second row of fields, then it does not work and I have to move the cursor there with the mouse. Is this normal?

Again, thanks for the help. I was so frustrated yesterday, and with your help, I have such a good understanding of this GUI now.

0

A few questions.
1. Formatting the output of the Jlist. My Pane has a window there and I can see what I entered, but it is just one big line of text. Where can I go to find ways to "pretty that up"

Well, I can't see it here so that's a bit tough to answer. The item in the JList will show whatever you have specified in the toString() method. You may have to play with that a bit.

2. The fields I have that should perform calculations do not. I can enter anything I want there. Is this a result of the Jlist, or because I have them set wrong in my class?

At this point they are just text fields, they don't do anything that you don't tell them to do.

3. Tab moves from one field to the next, until it is time to go to the second row of fields, then it does not work and I have to move the cursor there with the mouse. Is this normal?

The tab order is determined by the FocusTraversalPolicy. You can specify this yourself by creating your own. It's not that difficult. Here is a Sun demo on it:
http://java.sun.com/docs/books/tutorial/uiswing/examples/misc/FocusTraversalDemoProject/src/misc/FocusTraversalDemo.java
and there is more info here:
http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html#customFocusTraversal

0

Makes sense, I will work on that and see what I come up with.
My toString() is pretty simple:

public String toString()
	{
	return "Artist:" + artist +
	" CD Name: " + name + 
	" Item Number: " + itemno + 
	" Price: $" +price + 
	" In Stock: " + nstock + 
	" Stock Value: " + value + 
	" Restocking Fee: " + restock + 
	" Total Inventory Value: $"  + total;
	}

so, in the pane it just spits out
Arist:Seether CD Name:Disclaimer ItemNumber:1 Price $20.00 In Stock:1 etc etc etc all in one long row.
Are there commands or sytnax I could put in the toString() for carriage returns, or to show which number in the JList this item is? If so, where could I go to find all these options.

0

You could put the number in the string, if the CD knows it's number. You can't easily do the carriage return. It's possible but you would have to supply custom renderers for JList to use and I doubt you want to get into that just yet.

A list generally just shows items as single entries. Tables are generally used to present information in spreadsheet-like listings. If you want to display multiple pieces of info on an item in separate cells, you would want to use a table instead. JTable of course has it's own model architecture that is a bit more complex than JList.

0

I think I am going to need the cd to know its number. I want to be able to move back and forth in the list with PREVIOUS and NEXT buttons, I assume some kind of counter will need to be implimented?
I started trying to put in a "currCD" parameter just for that purpose, but got so lost in all this week that I am not sure what to try next to get it to work.
Also, on the fields, I understand that they can do anything I want, and when defining them in my parameters I thought I had them doing all kinds of things,

import java.util.*;

public class CdwArtist extends Compactdisk
{
 
 private String artist; // artist performing on cd
 private float restock; // restocking percentage
 private float total; // total of all inventory stock
  
 // Artist constructor
  public CdwArtist()
 {
 artist = "";
 restock = .05f;
 total = 0;
 }
 
 public CdwArtist(String in)
 {
 artist=in;
 }
 
 // get values
 public void setArtist(String in)
 {
 artist=in;
 }
 public void setRestock(float cdRestock)
 {
 restock = cdRestock;
 }
 public void setTotal(float cdtotal)
 {
 total = cdtotal;
 }
  
 // return value
 public String getArtist()
 {
 return (artist);
 }
	
 // returns indivudual inventory value for a disk
 public float getTotal()
 {
 return(price * nstock)+((price * nstock)* restock);
 }

but when I put value into my text field, it does not caculate anything. It stays blank until I go to that field and enter in information manually.
I would have thought that after putting in price, and nstock, a value would appear by itself.

0

but when I put value into my text field, it does not caculate anything. It stays blank until I go to that field and enter in information manually.
I would have thought that after putting in price, and nstock, a value would appear by itself.

Text fields just display data and let you edit data. They are not "bound" to fields unless you manage that binding yourself. You can make the fields respond by adding listeners such ActionListener, FocusListener, etc. These listeners allow you to perform actions when various events occur, like the user pressing enter, moving to a different component, clicking things, etc. Your button listeners do exactly this currently. They let you specify what code get executed when that event occurs.

0

OK. I do not really understand that, so I will try some reading.
I am going to close this thread since you long ago solved my original problem.

These fields and a counter is what I am working on now, and will open another thread if necessary. More like WHEN necessary.
Thanks again for all your help, Ezzaral.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.