JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

film.setName(scan.next())

scan.next()returns a String so that looks OK. Check the error message sagain, it's probably something else.

i was unable to call the addFilm method. :< why?

You need an instance of whatever class addFilm is defined in. What class is "collection" an instance of? Once again, check the exact error message.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Other people may the same problem in future, so can you describe how you solved it, for their benefit? ... and mark this "solved" so people know.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Exactly what did you set which environment variable to?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Exactly what did you set which environment variable to?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Is this your problem:
the jre bin folder isn't in my path so I make that my current directory to execute javac etc. That's why I want to put my java source code in the same directory
?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Please reply in English. Who says its mandatory to save the file there? What is the file?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you don't have an administrator password then you can't store a file there.
Why do you want to do that? What is the file? Maybe there is somewhere else you can put it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Read right through this recent topic - it's directly relevant.
http://www.daniweb.com/software-development/java/threads/387421

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The doc for NoSuchMethodError says
"Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed."
Try deleting all your compiled .class files and re-compile everything.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

When you handle a GUI event in Java there is an Event object passed to your handler. The event object has a getSource() method that returns the object that generated the event. Eg in an Action listener (responds to button presses and the like) you provide a handler method with this signature

public void actionPerformed(ActionEvent arg0)

in which you can call

arg0.getSource()

to return the source object (JButton or whatever)
Similar classes and methods exist for every kind of GUI event

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I'm going to (respectfully) disagree with the previous 2 posts.
Using NetBeans or another IDE to generate Swing code when you don't understand Swing will just lead you into more and more confusion. You'll get hundreds of lines of code that almost but not quite work, and you'll have no idea what to do next. Reading machine-generated code is a terrible way to learn about a subject.
Swing is a big complicated topic, so it's not easy to learn. The Oracle tutorials are of the very highest quality, and you won't find anything better. If you don't have the time (or patience) for "lots and lots of reading" then maybe you should switch to an easier subject.
The best advice I can give you is to start with the first Oracle tutorial and take them one at a time. Within each topic you can often skip the last couple of pages before moving on - it's usually pretty clear which pages are necessary for what follows.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

How can we possibly answer that? You haven't told us what next is or what drawimage is or where they are.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, you didn't say that before.
If you use elapsedDays then it's really easy. Whichever date has the highest elapsedDays is the later of the two.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You just need to compare the year/month/day (in that order) from the current date and the date that's passed as a parameter

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

DaniWeb Member Rules include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/forums/faq.php?faq=daniweb_policies

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The equals method requires one parameter, which is the object with which the current object is being compared. You use the fields of the two objects to decide whether you consider them to be equal or not.
eg You have a Person class. You consider two Person objects to be the same if the names and dates of birth are the same:

public boolean equals(Person other) {
  if (name.equals(other.name) & dob.equals(other.dob)) return true;
  else return false;
}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You need to create an instance of Moon and add it to your main window somewhere.
repaint() tells Java that you want your panel to be repainted. It will result in Java calling your class's paintComponent method, which is where & when the actual repaint will happen. If you don't call repaint() then Java won't know that you need to repaint the panel, and your paintComponent may not get called.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You add a drawclass and call its method, but that draws nothing. The drawing code is in class Moon.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Are you certain? Do you have a test case that shows that behaviour?
readLine will return a zero-length String (ie "") for an empty line; that's completely different from a null value.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Each read method has its own way of signalling EOF when you attempt to read past the end of file, eg returning -1 for the number of bytes read. Because some read methods return (eg) Strings don't return a number, they have to signal EOF some other way, such as returning a null. Check the API doc for the read method(s) you are using to see how they return EOF.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The if test can't cause that problem. Exactly what error message do you get?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

letter == "V" The == tests for letter and "V" both being exactly the same Object, which they are not, so it's always false.
To test whether two string Objects contain the same sequence of characters you need the equals method, as in letter.equals("V")

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You're really getting your indexes and lengths crossed up here.
If you are going to have the conventional [j] inside the loop then the limit for i is array.length, and the limit for j is array.length
... and v.v. if you really must use [j] (confusing)

If this is leading to a brain meltdown then I suggest the following:
1. explicitly document which index is student and which is question.
2. create variables for the number of students and number of questions
3. call your loop vars student and question rather than i and j
thus making it look like:

// Array is indexed by [student number][question number]
for (int student = 1; student < numberOfStudents; student++) {
  for (int question = 0; question < numberOfQuestions; question++) {
     array[student][question] = etc

now it should be really obvious whether the code is right or wrong.

Like Stevanity said - "name ur variables properly". I agree - good naming makes it so much easier to understand code and avoid bugs.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you change line 153? Did it help?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you have Java 6 (which you should by now) there is a new facility for displaying a startup screen even before your code starts to execute, and updating it with progress:
http://192.9.162.55/developer/technicalArticles/J2SE/Desktop/javase6/splashscreen/

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Check out line 153 in your original posted code

for (int i=1; i<=ans[0].length; i++)

I think that's your error.
It causes you to use the no of questions to control an index that you use for students (as per my previous hypothesis)
And may follow from the terrible var name on line 148 as per Stevanity's previous comment.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I assume the first row in the answers correspond to correct answers? Thats why u do length-1??

And that's why it compares the subsequent rows in a loop with row 0?
Stevanity - i think you're a genius.
Schoolboy - did your teacher tell you about using comments to explain your code and data structures?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The no off students in 1st data is > number of questions. in 2nd & 3rd its smaller. Maybe you are confusing the questions index/loop values with the students one somewhere??? (ie looping thru 10 elements (no of questions) to access students (OK for 14 students, out of bounds for 9 students)???

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK that helps. Add a print statement in the loop to see if its i or j which is going out of range.

ps following the length-1 question, why are student arrays 1 shorter than the answer arrays? And could this cause the problem - ie 8 answers but only 7 students?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

"crashes" tells us nothing. Do you get an error or Exception message? If so please post the whole thing, including the line number(s).
EDIT: Sorry sorry sorry - just went back to main forum listing and saw your post's title. Sorry.
I'm looking at the problem now...

Line 111, why length-1?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's an IDE display of the String value with newlines, tabs etc shown as characters (which is what you need in that context).
Try printing it, as in
System.out.print(" etc

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That code looks fine to me.
It depends on what you mean by one line; it may be one String, but if you print it you will see that it prints on multiple lines.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

"\n" isn't a command, it's just a new line character and you can use it in Strings just like you use "A" or "B". So, for example, the String "ABC\nDEF" is a valid String that when printed would look like this:
ABC
DEF


Of course you could print it to the terminal like that, but then it wouldn't be usable by any other part of your program. Return it as a String and you can still print it if you want, but you can also use it to (for example) store the values in a database.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It calls Mult, passing the values of x and y-1 as parameters. Whatever result is returned from that call is then added to x.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

whats wrong in the program?

Your recursive method works for me (assuming y>=1).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

ps: That explains why it works from main but not from your second window - the code in main is not executed on the EDT, so window updates can proceed while its still executing. But your second window is opened from a Swing listener method, which does execute on the EDT.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Your code is running on Swing's Event Dispatch Thread (EDT). Everything that Swing does (including painting/updating the screen) is run on that one thread.
So your f.setVisible(true); gets put on the EDT queue to be executed when your current method has finished - ie after the 20 sec calc.
You should use a SwingWorker to execute long-running tasks, so they don't interfere with the GUI.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This is what the API doc says:

public void setRowHeight(int rowHeight)
Sets the height of each cell, in pixels. If the specified value is less than or equal to zero the current cell renderer is queried for each row's height.

So, like I said in my first post, setRowHeight(0)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You'll have to Google for details, but briefly, JTree uses a JLabel to draw each cell in the tree. But you can define your own renderer (normally a subclass of JLabel) to draw each cell however you like - eg use a bigger font for some cells, add graphics etc etc

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You could subclass TreeCellRenderer and use setCellRenderer(javax.swing.tree.TreeCellRenderer) to draw each row with any arbitrary height, and setRowHeight(0) so the the current cell renderer is queried for each row's height.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Don't know what VB has to do with Java syntax.
In Java the {} thing is to define a literal array, eg

int[] a = {1,2,3};

To assign one element of an array to another its just

a[i] = b[j];
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I have no idea if this is relevant, but your form.setVisible(true); seems at best redundant because the JFrame subclass to which it refers hasn't been populated or configured in any way.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

He did say "...considering performance issues like memory and speed".

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

BigInteger holds arbitrarily large integers as binary values (the implementation uses an array of ints to provide whatever number of bits are required). I can't imagine that there would be any faster way to hold or do arithmetic on giant numbers on an ordinary computer, and certainly it's the most memory-efficient representation.
The only exception may be if you want to work with individual digits of the decimal representation, in which case a byte array with one decimal digit per byte may be better (two decimal digits per byte if memory usage is more important than execution speed/code simplicity).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hmm... How about using "char" array of size 10^6? A char is size of byte which should be more than enough to hold that many digits?

A Java char is 2 bytes.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Your SquareBaseContainer class must provide a complete definition for the setLength(double) method. That's because BaseContainer says it implements Container - ie implements all the methods declared in Container. In fact it doesn't implement them, but that's ok because it's abstract. But when you (finally) get to a non-abstract class somebody must have implemented those methods.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, great! Mark this "solved" for the DaniWeb knowledge base.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You need to add your buttons etc to the form, otherwize they are just floating about in a vacuum. Eg

Container cp = calc.getContentPane();
...
resultTF = new JTextField(10);
[B]cp.add(resultTF);[/B]
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You create buttons etc but you don't add them to your JFrame.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can declare it, but you cannot initialise an array without specifying its size. (The size can be a variable, eg ask user how many, input integer, use that as size to initialise array)