Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Check my edit. I forgot that you have to click that link above the form :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can view all of your reputation from the User Control Panel. Click the link for Latest Repuation Received.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can create that menu bar as a reusable bean form by selecting the following: New > Swing GUI Forms > Bean Form and specifying javax.swing.JMenuBar as the super class in the final step of the wizard.

After you have it built, you can add it to a JFrame by right-clicking it and selecting Add From Palette > Beans > Choose Bean and then typing in the full class name of the bean you created.

Hope that helps.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Are you executing "testcircle"?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your error message should also indicate which method does not exist. Which one is it complaining about?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You should be able to set the main class in the project properties in the "Run" section.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Executable jar files need a Main-Class: entry in the manifest file.
More info here: http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Honestly I've yet to use GroupLayout for anything but fixed layouts that I've thrown together recently. For forms that resize predictably, I'm more used to GridBagLayout and tend to stick with that (.. and you kids get off my lawn! *shaking fist* :P )

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Based on your code, I'm assuming you want to put those parameters from your method into the 'values()' clause of your insert. To do that, you need to build that sql string by concatenating the actual parameter values into a sql string "VALUES ("+id+","+ ... You current code has the variable names themselves as the values to insert into the table: VALUES (id, fn... and that isn't even a valid sql statement.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you are creating that layout in Netbeans, keep in mind that it just decides to use the GroupLayout by default for a new JFrame rather than the old default of FlowLayout, which may throw you off if you aren't expecting it. If that is the case, you can explicitly set the layout manager to whatever you want through the right-click menu in the Inspector.

(I'm just guessing you might be using Netbeans based on prior history. Disregard if that is not the case :) )

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It depends entirely on the layout manager you have set and how you add the JTabbedPane component. It will behave like any other container component in that context.

JTabbedPane tabPane = new JTabbedPane();
tabPane.add("Test 1",new JPanel());
tabPane.add("Test 2",new JPanel());
getContentPane().add(tabPane);
pack();

will create a tabbed pane that fills the frame.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's complaining because you sent this exact string as your values

"VALUES (id, fn, ln, phone, add, city, st, zip, age, sex, hr, hrs)        "

You didn't concatenate them in or use a PreparedStatement to set them, you just sent that string to the db and those are not valid values for the insert.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Have you looked at whether you might need some braces after your if() statement? I don't think you want to execute this characters[i] = Character.toUpperCase(letterReplace); for every iteration of your loop.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Of course, it's a lot easier if you just have the index of your array/list be the power: 4x^2+5x^3+6 --> [6, 0, 4, 5]

iamthwee commented: damn right +18
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I hope you are not holding your breath as you wait, since homework help is generally only given to those who demonstrate some effort.

These are not "code by request" forums. Post your code and state what problems you are having or ask specific questions about concepts you do not understand.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's a static method for the Char class - ie
Char.isLowerCase(characters);

Yep, but he was calling it on an element in an array of 'char', hence the "char cannot be dereferenced" error. If he used it as you indicated, a static method call, it would work fine.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

characters[i].isLowerCase() is not valid for char - it's a primitive, not an object.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Keep in mind that you are performing a very limited scope 'test' with that finalization. It is a single trivial object that is only in scope while main() is executing and goes out of scope just before the JVM exits, which is not reflective of most other runtime conditions. There is seldom a need to explicitly set a reference to null in that manner. Once it goes out of scope and there are no longer any active references to it, it will be garbage collected and finalized by the JVM as needed.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Trash t = new Trash();
t=null;
System.gc();
System.runFinalization();

does run the finalization. Finalize is a bit of a tricky thing and really shouldn't be relied upon as a cleanup mechanism. If you need to close resources, you should put explicit methods in for that and call them when required. You can read more about this here: http://www.codeguru.com/java/tij/tij0051.shtml#Index296

stephen84s commented: Good Post +7
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
img = ImageIO.read(new File("C:\\Users\\General Use\\Pictures\\0118080951"));

should work fine.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Here's another option as well, using ImageIcon and JLabel:
http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>so essentially two threads are trying to paint the same window at once, resulting in glitches?
Somewhat, yes. I don't have a concrete answer to the "what exactly?" of why the glitches could occur. It would depend entirely on the various UI toolkit code that renders the components and state inconsistencies they may be vulnerable to under certain multiple thread access conditions. I was just speaking generally to the fact that Swing is a single-threaded model and multiple threads attempting to alter the visible state of the components could produce erratic behavior due to inconsistent memory states since they weren't designed for multi-threaded access.

This pdf may be of interest: http://today.java.net/today/2005/04/19/desktop.pdf

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>How could a paint request possibly occur though. . it can't occur programmatically (before setVisible returns)
It can if the setVisible call is being processed on a thread other than the EDT. Consider that things like moving your mouse over a component, dragging another window across a component, resizing, etc. all generate repaint requests on the EDT. If you're building your GUI on some other thread, the EDT is perfectly free to pop in with a paint request before it's fully constructed.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The 'unsafe' part would be a chance that some portion of the components might still be in an inconsistent state that would produce errors or graphical "glitches" if a paint request happened to be processed. Essentially it's still "under construction" and may exhibit inconsistent behavior if accessed by another thread.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Any help offered here is a completely voluntary effort. As such, your own attitude is going to determine the extent and nature of that help. The attitude demonstrated above is certainly not going to encourage much assistance in the future.

Good luck with your efforts.

(You should also know that most posters never mark their questions as solved. Many don't even trouble themselves to say thanks or come back at all after their issue is resolved. Using that as a metric of "helpfulness" is useless.)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes. You want to see if either dimension is smaller than the box you already found.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You still need to add the criteria to check if box is smaller than foundBox.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, it's hard to say because you haven't posted any updated code in awhile. You could get more specific answers about why your method is behaving in a certain manner if you would post it. We can't see over your shoulder from where we are sitting :P

As you loop through the boxes, the logic of your if() checks should be:
1) Is this box big enough for each parameter?
2) If so, is it smaller than the last box I found that was big enough or is this the first box I've found that's large enough (this is the null case)?
3) If so, then save the reference to this box.

So after this has checked all the boxes, you should be left with the smallest box that fits the height and width parameters or a null variable if none of them are big enough.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And are you comparing that box against the smallest foundBox so far? You still need to compare the Box against the current "foundBox" to keep the smaller of the two. so you also need

// pseudocode: inside the if() statement mentioned above
if (foundBox==null || thisBox is smaller than foundBox){
  foundBox = thisBox
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ah, sorry, I only glanced over the assignment and missed that requirement. You could change your if() criteria to check that the box is big enough to hold the item. If it's big enough, check against the one you have already found to see if the current box is smaller (or if foundBox is null). If it is, set 'foundBox' to the current box. When you're done, 'foundBox' should contain the smallest box that will accommodate the dimensions you specified.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You'll need add some code to separate that piece then. You could do that with:
a) regular expressions, which I posted a link about above
b) String.split() on spaces and step through the resulting array to identify the parts that you want to keep
c) step through the line of text with more calls to indexOf() to find the substring of interest

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, so in regards to my (edited) post up above, why not alter what you have written to accept both parameters, height and width, and return the Box that is found (or Boxes in your case, but I would recommend renaming that to just Box because that more accurately reflects what it is - you don't have a single instance of a "Boxes"). The code that is searching for a particular box doesn't care what its index is in some arbitrary inventory list is - it needs a Box, so return that. Here is your method changed to return the Box(es) object. I'll leave it to you to add the parameter to also pass in a width and check that in your if() statement.

public Boxes findBox(int height)
{
  Boxes foundBox = null;
  for(Boxes box : inventory)
  {
    if (box.getHeight() == height)
    {
      foundBox = box;
      break; // you found it, no point in looking any further
    }
  }
  return foundBox;
}

Keep in mind, this method will return null if it doesn't find a matching box, so the code that calls this method needs to check that the return is not null before it attempts to do anything with that Box.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

In the future, try to put all of the relevant info in a single post rather than composing it across many. It's rather difficult to answer a question that is actually only an incomplete portion of a question.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You haven't given enough info to answer that. It depends upon how you have stored those objects and their data. The part about "choosing" the method is odd as well.

edit: Okay, you added another post while I was typing. Why not take both height and width and compare both values in your loop, then return the Box object that matches?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

As JamesCherrill mentioned above, don't pass 'memAd' to your table model constuctor, pass the Adult[] array.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And after you've managed the open/read operations mentioned above, read through this tutorial on regular expressions for the data extraction: http://java.sun.com/docs/books/tutorial/essential/regex/index.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If Main.class is declared in a package named "sort2" and in a folder of that same name, then from the root directory (the one containing the sorts directory), you invoke the class as "sort2.Main". The package is part of locating the class.
This tutorial may be helpful: http://java.sun.com/docs/books/tutorial/java/package/index.html

lllllIllIlllI commented: Couldnt have been a better post +2
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Is your Main class in a folder called "sort2" and does it have a "package sort2;" declaration?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your description is a little bit difficult to understand, but I think you are saying the extra spaces are causing you trouble in the split() result? You can make it ignore those by altering your pattern to allow for one or more occurrences of those characters. Try this "[-.!? ,\n]+" for your split pattern.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Here is a simple example of using a Map for something like what you are doing.

// simple map for rule patterns to their descriptions
Map<String,String> patternMap = new HashMap<String, String>();
patternMap.put("(?i)\\s*[a-zA-Z]+ing\\s*","Ends with 'ing'");
patternMap.put("(?i)\\s*[a-zA-Z]+ly\\s*","Ends with 'ly'");
patternMap.put("(?i)\\s*th[a-zA-Z]+\\s*","Starts with 'th'");

// now let's run this against some text
String someWords = "The early bird can be found eating the worm over there, Billy.";
for (String s : someWords.split("[ ,\\.]") ){
    for (String pattern : patternMap.keySet()){
        // if we find a match, print it along with its description
        if (s.matches(pattern)){
            System.out.println(s + ": "+patternMap.get(pattern));
        }
    }
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The table model is a bit much to digest for someone who is new to Java. If you are just trying to print the array contents into a text area, you can do something along the lines of this

String[][] stuff = {
    {"a","b","c"},
    {"x","y","z"},
    {"Bob","Mary","Steve"}
};
StringBuilder output = new StringBuilder();
for (int row=0; row<stuff.length; row++){
    for (int col=0; col<stuff[row].length; col++){
        output.append(stuff[row][col]);
        output.append("\t");
    }
    output.append("\n");
}
jTextArea1.setText(output.toString());

You just need to put together a string representation of each Adult object in your array and append those together into a single larger string that you can put in the text area.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Map is complicated? What is complicated about a key-value pair look up?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That certainly isn't the only logic problem. Why are you opening and reading the same files over and over for each portion of your split() result?

I'll mention one last time: read up on HashMap.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You're correct that you need to create a copy of that object before you alter it. Using '=' is setting the two variables to be references to the exact same object in memory, hence it reflects the changes. If your Matrix class doesn't implement the clone method then you will have to take whatever steps are necessary to create a copy yourself.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yeah, it's definitely tough to fight with the urges constantly for days on end but it does get much easier to brush them off after about 3-4 weeks. The first 3 days are the absolute worst of it.

Thinking about the fact that I had already smoked 23 years and wondering how much longer I could get away with the roulette was enough to keep me from giving in - just barely though on many, many occasions.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Look up HashMap in the API docs.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Caveat emptor.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yeah, I guess I quit just before the recent price hike. I saw they're up to around $5.50 here. That's just crazy.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you want to look through any of them, I found some of these articles helpful: http://whyquit.com/ and Allan Carr's book "The Easy Way To Stop Smoking" is good too for dealing with the psychological "why" of smoking.

It took me many months (years?) of "next week..." or "in a couple of days..." before I bit the bullet and just put them down. It's still weird sometimes to not smoke, since I smoked for my entire adult life (23 years, started at 15), but realizing there is not one positive thing to offset all the negatives keeps me from picking up another one. If you decide to get free again, good luck!