| | |
Impementing First GUI into Current App
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
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.
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.
I never drew first, but I drew first blood.
I'm no ones son, unforgiven.
I'm no ones son, unforgiven.
•
•
•
•
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?
http://java.sun.com/docs/books/tutor...ersalDemo.java
and there is more info here:
http://java.sun.com/docs/books/tutor...FocusTraversal
Makes sense, I will work on that and see what I come up with.
My toString() is pretty simple:
so, in the pane it just spits out
Arist
eether CD Name
isclaimer 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.
My toString() is pretty simple:
Java Syntax (Toggle Plain Text)
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
eether CD Name
isclaimer 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.
I never drew first, but I drew first blood.
I'm no ones son, unforgiven.
I'm no ones son, unforgiven.
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.
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.
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,
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.
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,
Java Syntax (Toggle Plain Text)
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.
I never drew first, but I drew first blood.
I'm no ones son, unforgiven.
I'm no ones son, unforgiven.
•
•
•
•
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.
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.
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.
Last edited by no1zson; Jul 25th, 2007 at 1:18 pm.
I never drew first, but I drew first blood.
I'm no ones son, unforgiven.
I'm no ones son, unforgiven.
![]() |
Other Threads in the Java Forum
- Previous Thread: How to download a file
- Next Thread: Java image programming question
| Thread Tools | Search this Thread |
Tag cloud for Java
affinetransform android api apple applet application arc arguments array arrays automation binary bluetooth businessintelligence chat class classes client code component database desktop draw ebook eclipse encode equation error event exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer intersect j2me java javaexcel javaprojects jmf jni jpanel julia linked linux list loop mac main map method methods mobile netbeans newbie number online open-source oracle parameter print problem program programming project properties recursion reference replaysolutions rotatetext scanner score screen scrollbar server set size sms socket sort sql string superclass swing template test threads time tree windows working xstream






