JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The Java language allows you to call a static method using an instance to identify the class, eg

 MyClass ins = new MyClass();
 ins.staticMethod();

this is now considered to be bad form and you are supposed to use the class to call static methods, ie
MyClass.staticMethod();

Just update your static method calls to use the class rather than an instance.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Who knows? Just keep printing them at earlier and earlier stages of the program until you find out where they are going null. Once you know exactly where it will probably be easy to find out why.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That sounds like theTeams[i].getName(); is returning nulls or maybe empty Strings (""). The only way to diagnose this is to keep printing those values until you find out where exactly they are going wrong.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That code looks OK to me. Have you tried printing the contents of names at the point where you create the default model?
ps in a general catch block it's best to call e.printStackTrace(); rather than printing e.toString because printStackTrace() prints all the available info about the error, rather tha just a summary.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Line 1 creates a local variable "names", creates a new array of Strings, and sets names to refer to that array. 2-4 store info in the array. Then, at the end of the method, the variable "names" goes out of scope and ceases to exist. That was the only reference to the String array, so that now has no references, so it will be garbage collected.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I don't understand this code

String [] names = new String[theTeams.length];
for(int i=0; i<names.length; i++){
    names[i] = theTeams[i].getName();
}

You create that variable, but then let it go out of scope without using it at all, and so the array you created will be garbage collected.

 teamBox = new DefaultComboBoxModel();
jComboBox1.setModel(teamBox);

that will give you an empty combo box - you haven't put any data in the model.

If Team has a sensible toString method, then why not just
jComboBox1.setModel(new DefaultComboBoxModel(theTeams));
or maybe
jComboBox1.setModel(new DefaultComboBoxModel(names));
?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There's too much missing code there to be able to diagnose this (just one eg is there a second declaration of jComboBox1 somewhere?). Have you tried the obvious debugging steps, eg print theTeams at various points in the code to check that it has the data you expect?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I don't understand what difference it makes if I get an object from the list and use it to call the method (the object still doesn't have that particular method assigned to it

Not so! You declare categories like this: ArrayList<CarbonFootprint> categories
ie categories is an ArrayList containing only CarbonFootprint objects (objects that implement the CarbonFootprint interface). So the compiler will prevent you adding any object that is not a CarbonFootprint, and equally knows that any object you get from that ArrayList wil be a CarbonFootprint, and will therefore have the getCarbonFootprint() method.

As for the rest... scudzilla already said it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Learning the language itself from c++ ... you'll have 95% of it with a few days
Learning the API - a lifetime

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

categories is an Object of type ArrayList, and ArrayLists do not have a getCarbonFootprint() method.
You must get one or more actual CarbonFootprint objects from tyhe list, then use it/them to call CarbonFootprint's getCarbonFootprint() method. eg

ArrayList<String> strings = .....
strings.toLowerCase(); // ERROR = ArrayLists do not have that method
strings.get(0).toLowerCase(); // correct
for (string s : strings) {
   s.toLowerCase(); // correct
}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Project - right click -> properties -> libraries

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Probably refers to the different ways that numbers are typed, thousands separator, decimal point etc eg US 12,34.56 in France would be 12.345,56, and I think some countries leave a blank as the thousands separator

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Go to the "Problems" tab in the window at the bottom (currently showing "Console") to get a complete list of all the compilation errors that the red underlines are flagging. That will give you complete error descriptions that you or we can use to fix this.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You have hit the limits of what automatic code generation can do for you. You will have to create your table model by writing your own code - handing exceptions for non-numeric input etc. The line of code in your last post is exactly the right place to start.
NetBeans GUI code generation only works for fixed layouts, it's really just "training wheels".

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I don't know how to make this any simpler for you. Of course you can dynamically set or change the number of rows in your table. Have you read the API documentation for JTable, or the tutorial which it links to? You just make your model the right size.

JTable is just a view of an underlying TableModel. It's the TableModel that defines the number of rows and columns. You create your table model with whatever number of rows you want.
For example, have a look at the constructors for DefaultTableModel

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Just make your model the right size.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The row count tells you the number of rows in yout table's model, just like length() tells you the number of chars in a String. It makes no sense to set it, because then it would be wrong. Just make your model the right size.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Lists use methods to add and access elements, not the [] notation. eg categories.add(new Bike(200.00)); Check the ArrayList API documentation for all the methods you can use.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

... just hacked that code to sync col widths from one table to a second table immediately below it.Column re-size is absolutely flawless on my ordinary Core i3 - when resizing the top table there's no visible lag or difference between the top and bottom tables, so go for it!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Have a look at this thread that's about spanning headings across multiple columns in a JTable and keeping them synched when the table's columns are re-sized...
http://www.daniweb.com/software-development/java/threads/454696/creating-a-table-in-a-table/
... about half way down there's a little proof-of-concept I wrote to monitor column width changes and update heading widths to match. You can run it to see how responsive/smooth it is, and you may find that much of the code is directly releant to your problem, eg listening for column width changes and getting the latest widths of all the columns.
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It should update about as fast as your pc can execute the code - normally it would be very responsive and pretty smooth I think.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I guess you could create a TableColumnModelListener to monitor changes in your JTable's TableColumnModel and get the updated widths of each TableColumn and use those to update the bottom table? A bit tortuous, but probably not very much code when you finally work it all out.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Obviously you can't close the result set while the user is trying to "next" his way through it. You need to keep that result set open until the form is closed.

Create window:   do SQL, create result set
Previous/Next:   move through result set, display the current record
Close window:    release all SQL-related resources that were created when the window was opened, including the result set
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

In that case your structure is going to have to change. Right now you start again with a new SQL query every time the next button is pressed. You should just do that SQL once, when the form is started, and keep the result set. Then in the button handler you can execute one rs.next() and update all the fields - using setText not append.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What is supposed to happen? eg start this form with the first record displayed then move on to the next record each time that ActionPerformed is called? Or something else?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Line 18 if (rs.next... will only execute the following code zero or one times. Didn't you mean
while (rs.next... ?

ps line 43 is a disaster. You get the message string and completely ignore it, so you will never see any error messages. Replace that line with e.printStackTrace(); to see the full details of any diagnostics

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Use unbuffered output streams when you want each write to be processed immediately - eg Writing a log file - you don't want the last few messages to be lost when the program crashes and the buffer is lost. Another eg - writing to a network stream to send chat messages to another PC - you want each message to be sent immediately, you don't want them stored up until there is a complete buffer-full to be sent.
I can't think of any cases where you would prefer an unbuffered input stream

As for why it's called a "buffer" - have a look at some of the many other uses for that word and you'll see how the concept fits: http://en.wikipedia.org/wiki/Buffer

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

JRE is everything you need to run Java programs, primarily (1) a JVM and (2) all the class files for the Java API and (3) other bits and pieces that are needed for some of the API classes (DLLs etc)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Since you don't actually do anything with those classes it doesn't matter what attributes they have, so maybe this example is a bit too simple?
Do you still have your code for two or more console-based games (tictactoe, hangman, scissors/paper/rock or whatever)?. If so it may be interesting to package those as classes into a simgle games console app where you can chose which games to play and (here's the relevenat bit) implement an interface to start a game, and get player statistics (start(), get name of game, date/time played, win/lost ...) so they all can be started and contribute to the statistics via that interface. Just a thought...

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This isn't about the key bytes, it's the outputBuffer - for which you confusingly re-use the input buffer.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I don't understand your last post. sorry.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you check the API doc for doFinal before posting? - it includes

If the output buffer is too small to hold the result, a ShortBufferException is thrown. In this case, repeat this call with a larger output buffer. Use getOutputSize to determine how big the output buffer should be.

My guess is that you make the output buffer the same size as the input, but you forgot that the input will be padded before being encrypted.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You have an input that is not a multiple of 8 bytes, but you specify a encryption with no padding. If you don't allow the algorithm to pad your string then it's up to you to make sure its a multiple of 8 bytes.
See http://stackoverflow.com/questions/4183853/encryption-message-in-java

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Swing was not part of the first version of Java - which only had java.awt
So originally swing was a java extension.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You shouild know by now that we are going to ask for the exact complete text of all your error messages. "My main problem is with blah" is not in any way helpful.

Begginnerdev commented: Yeppers +8
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Create a new JOptionPane, let it create a JDialog that contains it, position the JDialog, make it visible... eg something like

      JOptionPane pane = new JOptionPane("Click one:", 
           JOptionPane.QUESTION_MESSAGE,  JOptionPane.YES_NO_CANCEL_OPTION);
      JDialog d = pane.createDialog(null); // see mKorbel's post for better ways to do this
      d.setLocation(400,400);              // see mKorbel's post for better ways to do this
      d.setVisible(true);
      // modal dialog - automatically waits here until dialog closed
      System.out.println(""Dialog was closed with button " + pane.getValue());
      d.dispose();
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

"identify all the end points that are that distance away"
Does that imply that there is a finite list of known end points?
If not, just get a random deltaX in the range (0 - drivingDistance), set deltaY to (drivingDistance - deltaX), so the sum of the x and y distance is the desired total, then the end point is x +or- deltaX, y +or- deltaY

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You're about to point out that doing pythagorus on two gaussians doesn't give a gaussian hypotenuse?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Just a random x between 0 and (width of space) - linear distribution, ditto y?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Maybe allocate starting x and y at random, then chose the end x and y as (start x) + (suitable gaussian), (start y) + (suitable gaussian).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The Random class has a nextGaussian() method, so that's obviously going to be part of yur solution...
http://docs.oracle.com/javase/7/docs/api/java/util/Random.html#nextGaussian%28%29

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Check the API documentation for JTextField, you know, the one that starts "JTextField is a lightweight component that allows the editing of a single line of text."
Try JTextArea, "A JTextArea is a multi-line area that displays plain text"

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You could write a simple Java program to read a text file, delete any leading integers and write it back out. 15 minutes tops.

sash_kp commented: This would be a peculiar way for doing this. However i found a nice and simple way. In sublime text2 using macros i am able to get this thing done easily. Btw thanks for your support. +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's the output (with stars) that my code produces I doubt that you will get it much simpler than that.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You could make this easier for us by explaining what it's supposed to achieve, or at least posting some sample output, but at a guess, how about

  String stars = "***********************************************";
  int n = 5;
  for (int i = 1; i <= n; i++) {
     System.out.println(stars.substring(0, Math.min(i, n - i + 1)));
  }
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You should just get a zero-length String "" for the missing entries.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

How can a combo box be equal to a String? - they're completely different things.
You didn't post the relevant code, but at a guess you probably want to compare the text currently in the combo box. I'm sure you can guess the method that gives you the text!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You are still passing the data to encrypt as a String. That will be corrupted for anything other than ASCII text. Get rid of the |Strings and just work with byte[]

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Forget the Strings. Encryption/decryption just treats everything as bytes, so the last thing you want is Java doing character "interpretation" of those bytes into/out of some random character set. Just read the input file as an array of bytes, encode that to an array of bytes and write those bytes to the output file along with/just like the key (array of bytes). Ditto for decryption.
The file extension is a special case if you assume it is pure ASCII (under 0x7f) so you can convert that String to array of bytes for writing to file, and vice-versa.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I already told you in your previous topic that you cannot use a String to hold a byte array and expect to get it back unchanged.

byte[] in = ....
String s = new String(in);
byte[] out = s.getBytes();
// depending on your default character set, out will NOT be the same as in, 
// particularly for byte values >= 0x7f