Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, I assume that is only part of the batch file, or you are supposed to run another batch before that one, because it is trying to create a jar file from classes that aren't there. Do you have any docs for this POWERTRAK stuff or is it an internal app?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You cannot define a method inside another method - and that is what your code is trying to do.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Hey Baltazar

Another solution to your problem would be to talk with your 225 TA and attending the labs. :) I went over this exact piece of code two weeks in a row now (using Scanners as other posters have nicely pointed out).

Just a thought. Sorry to bother the rest of you.

Cheers,
David (225 TA)

Hehe!
Busted!

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

wow. that worked. so, setpreferredsize instead of logo.getsize was the answer?

Would you explain why that would make a difference?

The layout manager uses the preferred size of a component in determining how much space to allocate for it in the layout. If preferred size is not set it will try to determine one on its own based upon inspection of the component. Since you don't have any other components in that panel, just a custom paint routine, it didn't have anything to go on and probably gave it a size of 0x0 (or nearly, I'm not really sure there).

The point is, setPreferredSize(), setMinimumSize(), and setMaximumSize() are used by the layout managers in determining the initial, min, and max sizes to allocate to your components.

Just a side note:
You could also add the following constructor to your ShapesJPanel class, which would keep the preferred size info inside the panel that requires it

public ShapesJPanel(){
         super();
         setPreferredSize(new Dimension(75,150));
     }
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, use this instead

// add shapesJPanel to frame    
ShapesJPanel logo = new ShapesJPanel();
logo.setPreferredSize(new Dimension(200,200));
getContentPane().add( logo );
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need to add the mysql driver jar to your classpath.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Um, this class has nothing in it. Are you sure this is the code? It's also called Shapes - not ShapesJPanel.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It would help if you posted the ShapesJPanel code.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
// add shapesJPanel to frame    
ShapesJPanel logo = new ShapesJPanel();
logo.setSize(125,200);
getContentPane().add( logo );
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

How are you displaying the logo? You may have to set the size on your panel before you add it to your container if the logo has no intrinsic size of its own.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Is there anything in the ShapesPanel?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I would assume that is because you have explicitly set the table height. If you only give it a couple of rows, those rows will fill the available height.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

As peter_budo pointed out, there are some organizational issues with the way you are trying to build your layouts, but I think if you put

getContentPane().add( new ShapesJPanel() ); // add shapesJPanel to frame

right after you set the layout in initComponents(), your panel should show up fine.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You might try adding /wait to the start command you are using, since you are chaining process commands here:

Process p = r.exec("cmd /c start /wait run.cmd");
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You dug up this 2 year old post in the Java forum just to promote your mainframe and COBOL?

<boggle>

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Or I could just do this.
if (++currCD >= listModel.size()) currCD= 0;
and not worry about it at all. Is this ugly programming by pro standards?

That is exactly what I was trying to get you to figure out. You don't need any method calls to know that the first index is zero.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Keeps coming from my fingers, but I know currCD and lastElement cannot be compared like that.

Which is why I keep pointing out listModel.size(). That is the current number of items in your list. That number -1 is the index of the last item. If your pointer equals the number of items, you have incremented too far and need to wrap back to the index of the first item.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>with first I think you been trying to say

currCD = listModel.get(0);

and last will be like thhis

currCD = listModel.lastElement();

don't forget deal with exception

His usage there misled you a bit. Actually, the currCD variable is just an int index for the current cd, so the get(0) and lastElement() won't apply since they return the objects in those positions.

This is a simple matter of keeping track of an index. listModel.size()-1 is the index of the last item. From there, implementing your next() and last() code should be trivial to figure out.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

C^2 :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You don't want to get currCD-- from listModel, just currCD. You have already decremented it in the statement that handles the bounds rollover.

size()-1 is the index of the last item in the model, i.e. 10 items indexed from 0-9.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Criticizing things without knowing where they are used and how they impact the software world is a bit uncalled for...

Yes, ok, UML is not without value. I'm just still bitter from the Rational Process training seminars foisted upon us back when I was in a large corporation :icon_neutral:

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

My bad, you'll need to use String.valueOf( newCD.getItemno() ) in the setText method for the numeric entries or a DecimalFormat formatter.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You simply call setText() on the textfield with the value from the cd object.

itemField.setText( newCD.getItemno());
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

UML is great!... for selling books and useless corporate OO design seminars...

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
if (--currCD<0) currCD = listModel.size()-1;

and then listModel.get(currCD); would work just fine.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

C# with XNA is gaining some popularity as well, but production games for the most part still rely on C++. As said above - it depends on what you want to program. As a new game programmer, the language is going to be the least limiting thing you'll face.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your parsing problem is clear from the exception message:

[B]Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: ""

[/B]It's trying to parse an int from an empty string. If you look at the code in your previous handler, you have it backward. You want to set the text to the value from the object - not the other way around.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

One I had not even considered until you asked it. I want to go back one record at a time, when I hit the very first record I would like to just loop around to the last record and start the process over again. Any suggestions?

Well, think about your index in relation to the list. If the decrement puts it past 0 you know what you want the next value to be and listModel has a size() function to help you out.

no1zson commented: The most helpful guy on this board ... at least to me. :o) +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, that is because it is a JList, which is suppose to display multiple items. toString() merely determines what the list displays for each item you add to it.

If you just want to show a single description then all you need is a text area or a label to show the description for a particular object.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

toString() is a method of the CdwArtist class. You do not need to access the list at all - it's purpose is to return information about the object instance itself. Methods that need that information call aCdObject.toString() to get it's string value. You seem to be running yourself in circles there but I cannot see why. You had a working toString() on the class so I'm not sure what you are trying to change.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You cannot call a method on an int.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

listModel does not have a newCD method. It has a get(int index) method, which you have used before. Just retrieve the object like you have in the past and call toString() on it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

For your purpose, all you really need is one formatter in the cd class

DecimalFormat formatter = new DecimalFormat("$0.00");

and used in toString() like

" Stock Value: " + formatter.format(getValue()) +
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

As it says, $all_rsArticles is not a valid result, which means your query failed. Try putting

if (!$all_rsArticles){
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}

after your query to see what's going on with it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I looked at the documentation, and I know it should help, but it does not. I just do not yet understand how to read those parameters on that site and mine down to what I need.

I understand it's a lot to swallow, but keep in mind, if you intend to do much with programming at all, in any language, you'll eventually need to get comfortable with using the api docs and Sun has a lot of links in there to tutorials that present basic usage.

You may also find the following tutorial in debugging helpful in squashing some of the errors you come across:
http://www.seas.upenn.edu/~cse1xx/projects/Debug/GuideToDebugging/beginners.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I disagree. Between forums and friends there is plenty of personality and intelligence to interact with. I'd at least consider having fun with the hotter one and enjoying other pursuits (intellectual and social) with people other than my significant other.

That being said, I've had a girlfriend of option two and absolutely loved having debates and discussions on politics, religion, and society. ;)

I suppose it comes down to the intention of the somewhat ambiguous "which one would you choose?". Bod might be okay for an occasional fling thing if you can not go insane listening to the "crap", but for a long-term choice I still stand by my original statement.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I suppose you would need to first parse out the hrefs from the links and then get the content from each those urls and search for the match. Regular expressions parsing could do both or perhaps HtmlEditorKit
http://java.sun.com/javase/6/docs/api/javax/swing/text/html/HTMLEditorKit.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

To format string output you just need to pass the numeric value to the format() method

myFormat.format(aDecimalValue);

http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

which one would you choose?

Someone who gives pause to the question deserves to live with the "crap and idiotness" (sic)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

stevex, your poll makes no sense whatsoever - much like the rest of what you posted....

That has to be some of the most useless drivel I have read in some time.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

One issue may be that you are creating FormattedTextFields with a null format. You pass an uninitialized NumberFormat variable to them. Correcting those though will not affect what you are getting in the toString output. To make those conform to a format you will need to use a DecimalFormat such as new DecimalFormat("0.00") which has a format() function that you can use to present the string representation that you need.
http://java.sun.com/javase/6/docs/api/java/text/DecimalFormat.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I am sure this is a symptom of the problem, but the only thing that IS showing up is Name, Artist and .05 for restocking fee, everything else, even price that I enter shows up as 0. Something has to be pointed to the wrong place I think.

Yes, it sounds like your setters are not being called properly.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I assume you have read all of the discussion in the manual page?
http://us.php.net/manual/en/function.rand.php

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Seems you should do your dissertation on an area that you understand well and I doubt that we are the best judges of that...

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
while (!$validUser) {
  ...
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Consider also that methods may be called in toString() as well, so this is just as valid

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

You can code getValue() either way you choose: by maintaining a "value" variable and updating it as other properties are changed, or by simply returning the calculation itself return nstock * price; (this would not be so great for performance if the calculation was called often or was expensive to calc. That really isn't a consideration in your particular case though.).

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It looks like you are getting a lot closer to something that will work out. I don't see any way for a user to add a CD though and you have already filled your array to the hard-coded max of 5 items. I assume you have put that part in to test the workings of your first(), last(), etc. methods?

no1zson commented: Always has a suggestion +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Inventory3.java:128: int cannot be dereferenced
cdNameField.setText(currCD.getcdName());
^
Inventory3.java:129: int cannot be dereferenced
artistField.setText(currCD.getArtist());

I think some of my logic may be off. I have taken the day off work tomorrow to try and work through one or both of these programs to completion. The more coding experience I can get under my best with either application the better. Finals are coming up in a couple weeks.

Again, you are trying to use the integer index value like an object. You need to actually get that object (using currCD as the index) from your listModel as a CdwArtist object.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Count the number of params in your super() call and take a look at the base constructor.