JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
31: rolls[diceValue - 1] = rolls[diceValue - 1] += 1;

That is positively wierd. Two assignments for the same variable like that - I'd have to read the JLS to know which was executed first!

What's wrong with

rolls[diceValue - 1]++;

Ditto line 58, except that I don't know why you are doing that increment anyway

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Most of the symbols it can't find are the names of standard API classes, so it looks like you forgot (some of) the import statements at the start of your .java file(s)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You want to run an app in another jar when a button is clicked?

The easiest way is to use the Desktop class which can open a file in its default application - if you open the other jar file then the default will be to run it using javaw. It's as easy as:

desktop = Desktop.getDesktop();
File JarFile = new File(thePathAndNameOfTheJarFile);
desktop.open(JarFile);

It doesn't make the slightest difference whether you use NetBeans, Eclipse, or any other development tools. A jar is a jar.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, let's not take over this thread with a separate discussion.

SintherPal's post ignored two of the DaniWeb Community Rules:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
and
"Do not solicit for help by email"
Those violations would justify my deleting the post, but newcomers do get a certain amount of slack, and DoogleDude's response was spot on.

IF SintherPal shows some evidence of having dome some work then we will all try to help, here in the public forum where everyone can contribute and learn, not by email or PM.
JC

Please, no more posts here until SintherPal has replied.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Your mistake is declaring the same variable name twice. On line 9, just use the one you already have, don't declare a new one.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes.
YOu have TWO variables"NumberArray", declared on lines 5 and 9.
The one you initialise is declared on line 9, and never used anywhere else.
The one declared on line 5 is the one you (try to) use, but that's not initialised.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

EXACTLY what code are you executring and EXACTLY what is thet COMPLETE error message?

ps Did you intend that line 9 will create a new "NumberArray" variable? The NumberArray that you initialise in setNumberArray isn't the one declared on line 5!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can use System.setOut(PrintStream out) to send all your console output to a file instead of the console, without having to change any other code.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Personally I hate Scanner. It's amazing how often we get threads here where people have mixed nextInt's and nextLine's and can't understand why it's not working. It was intended to be an easy thing for beginners, but it has too many odd behaviours to be safe.
My preference is always to use a BufferedReader to read whole lines from the console...

BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
inputString = in.readLine();

... then parse the contents as necessary using split, Integer.parseInt etc etc

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You may nor want to read this post, because the embarassment will be hard to bear...

You get the input string via inputString = input.next(); which reads the next token. Tokens are delimited by the default of a blank. You never read the rest of the line. I hate Scanner.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I don't understand - what do you mean by "breaking at the space"? All your code does is to replace the space in the output by whatever repChar was input earlier. In what sense does that "break"?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Here at DaniWeb we try to help people learn Java and develop their Java skills. We do NOT do people's homework for them. Your post explains and teaches nothing, it just gives the OP a chance to cheat. In future please help by pointing people in the right direction - eg tell them which classes and methods they should read about, or give them some sample code that they will have to understand and adapt to their needs. If you feel you should correct someone's code then that's useless if you don't explain what you changed and why you changed it as you did. If you need to explain with actual code then explain why you coded it the way you did. Don't just spoon-feed them a solution to copy and paste.

castajiz_2 commented: you are right +4
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

In that case you just

loop through the characters of the string
  if it's a space then break
  check that it's <=255
     convert to binary string (see previous post for leading zeros)
     append that to output string
return the string

Based on your previous threads I can't see why you are having any problem with something so simple!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sorry, that's still not clear to me. Can you post an actual small example of an input/output pair? Is it like this?:
in: "ab c"
out: "01100001 01100010"

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

"stops working" means what exactly?

You can force leading zeros by
a) prepending eights zeros, then substring the last 8 chars of the result
or
b) add 256 to the value before converting to a binary string, then drop the first character
or
c) probably lots of other ways?

ps line 22 should probably be a while, not a single-pass if

pps: You have fallen into the trap of thinking of Java chars as ASCII. They are not. ASCII is a 7 bit code with just English letters. Java chars are 16 bits and encode letters from all kinds of languages and scripts (including English letters, which have the same values as in ASCII). If you assume ASCII then your code will fall over as soon as it hits a letter that's not an un-accented A-Z.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OP posted two questions:

1) What are three ways of creating a String object ?
2) What is the difference between string concat method and simply adding 2 strings ?

I think the various responses have answered both. Job done.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you count methods that return a String then there will be an unlimited number of them. Internally, however, they will have to come down to one of the three techniques that the compiler understands (ps: Daemion CC - don't forget concatenation with the + operator).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK!

"abc"
new String(something);
string1 + string2

The only difference I know between concat and + is their behaviour when either of the String refs is null.

(ps please don't use abbreviations like N for "and" - many of our readers have English as a second or third language)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Which part is the problem? Is there really nothing in the {}?
How is the class Song declared?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

ps I don't want to start a flame war, but in my experience NetBeans is always well ahead of Eclipse in its support for new versions of Java, it usually has beta versions tracking the betas of the Java version, and a solid final release on the same day. Eclipse support seems to be held back with final testing etc only starting after the offical release of the Java version.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Initially looks like this

732c545c04d43d76f48a1f56efde78b9

then resized...

b2779793e86ba380ed86ac5e31c7ff57

and resized again...

1b4d0144a782fb5697722bf6e52d2742

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Please explain exactly what is confusing you. I assume you have Googled these questions and read some of the standard answers.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I tried your fxml file in Netbeans/Java8 and it loaded OK and diplayed a (slighly wonky) calculator-type screen. No errors.
Maybe you have an old version, or a mismatch between the layout editor and the compiler versions???

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's close. You just need to print the family before going into the loop for the titles

for(int a = 0; a < family.length; a++)
    print family[a] 
    for(int b =0; b< titles[a].length; b++) {
        print titles[a][b]) 
    }
}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's because arrays in Java start with element 0
eg if you have 3 elements they are numbered [0]. [1] and [2]
that's 0 to (number of elements)-1
You soon get used to that and it becomes automatic.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Something like (pseudo-code):

for i = 0 to no of families -1
   get family name & store it in names array[i]
   for j = 0 to no of titles for this family -1
      get title & store it in titles array[i][j]
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That makes sense, but if the 2D array is going to hold the titles for each name, it needs to be an array of String[][], not int[][], that's all

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It looks like the problem is with the arrays you are using, noy how you print them.
You create a 2d memberNames array that looks like it should have one row for each family and member names for that family in the row, but its an array of ints, not Strings. Then you set up a titles array that is String[], but it is only one-dimensional, so it's not organised by family.
I recommend that you sit down with pen and paper and draw out your data structures with some sample data. When that makes sense, go back to the PC and convert it into Java arrays.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

rather, the value assigned to the variable.

??? the variables are reference variables, and their values are references, so the original comment about comparing the values that the references refer to seems right to me... or did you have something else in mind?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hi hannahaddad
There is nothing wrong with your post, but please be aware when answering Ermina. He/She has a history of posting homework questions and expecting someone to provide the answer, and doesn't seem to want to do any work (eg: didn't bother to follow up the API reference that I gave above).
Just providing complete answers isn't going to help him/her develop a constructive attitude to learning Java

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

a and b are reference variables. The == operator for references tests if those two references are equal - ie that they both refer to the same object.

Read the API doc for the String class, specifically its equals method.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Just google for it. The WikiPedia article on "event driven architecture" has a section specifically about Java Swing GUIs

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
if(minDistance == 0) {
   minDistance = distance;

Not such a good idea if two of the points are at the same position (and nobody has said they can't be), in which case they will be the closest pair, and the distance really will be zero. This code will then replace that with the next distance, even though it's bigger.
Much better to initialise minDistance properly (see previous post)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Look at your initial value for minDistance. Do you think you will ever find a smaller value than that? So the if test on line 10 will always be false.

Start minDistance at some very large value (larger than any distance you will calulate) Integer.MAX_VALUE would be the obvious choice.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Centering things is a responsiblility of the layout manager. Have a look at this and chose a layout manager that handles sizing & centering the way you want.
Note also the the frame has a layout manager that positions the panels, but the panels have their own layout managers (not necessarily the same) that layout the labels etc in the panels.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The player would be moving, so how would you determine which object is the closest since you wouldnt just want to check if the player is colliding with all other objects?

Checking for rectangles overlapping is so quick & easy that you may as well just do it for all the possible objects - it's only going to cost you a few microseconds. Deciding which ones to check will probably cost more than just doing the check!
Checking for overlaps is probably ueasier using top, botton, left , right coords

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Simply test for a -1 selected index before trying to use it!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes aFile could be either, but if on the first pass of the loop aFile is not a directory then the call to recursiveTravesrsal (line 6 above) is made using some random value of childFolder.
childFolder is only correctly initialised when the for loop processes a directory

Yes, NIO is so different that your would start again, but it does use better programming patterns that are used massively in Java 8

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
for (File afile : files) {
   if (afile.isDirectory()) {
      this.childFolder = new Folder(afile);
      parentFolder.add(childFolder);
   }
    recursiveTraversal(afile, this.childFolder);
}

If the first n Files are files (not directories) the variable childFolder is noy set and presumably inherits some left-over value from a previous class?

ps: This kind of thing is much easier using the current I/O classes in Java 7/8 ("NIO" or "NIO2") rather than the old File class.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

mustafaaaltup:
Your question is too vague. Please be more specific. How far have you got with this? What, exactly, is stopping you now?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Excellent!
Please mark this "solved" for our knowledge base. You should start a new thread if you run into any new problems.
cheers
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The only way to compare equality between objects of a class is to use the class's equals method - the very one that you are writing now!
But if you use getCels() to get the value of each Temperature in degrees Celcius then that value is a primitive double, so you can use binary operators eg t1.getCels() > t2.getCels() because both those values are just doubles.
(Hint: == is a problem with floating point values, so don't be surprised if it doesn't work exactly as you would hope)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I just meant that the English specification "t1 in degrees Celcius" is easily implemented in your program by t1.getCels()

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

So your definition of "equal" is sonething like:
Temperatures t1 and t2 are "equal" if and only if t1 in degrees Celcius == t2 in degrees Celcius, within the precision of their double values.
(or exactly the same with both Farenheit values)

I can't explain that more clearly without just giving you the code (which we don't do for homework, as I'm sure you understand)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

(tempNum)==(testObj)

tempNum is a double primitive
testObj is an object of class Temperature

they are so different in kind that using == makes no sense - its like asking "is London equal to Tuesday?"

For equals you want to know if two Temperature objects are "equal", where it's up to you to decide what "equals" means for Temperatures. The obvious answer is that the value of both Temperatures expressed in the same units (C or F) should be the same, within the limits of their floating point precision. You already have the get methods you need to get the values to compare.

ps: good coding guide part XIV: <soapbox>
the names you use for your variables and methods tells everything about your code and you as a programmer. "tempNum" is a horrible name for a temperature value that isn't temporary or just a number.
When you try to think of a good name you get into things like "currentTemperatureInTheUnitsSpecifiedByTempUnit" - which is onbviously silly, but a clear sign that the variable itself is confusing.
Personally that signals to me that I should simplify my design to the point where its easy to explain what the variables are. Eg in this case I would chose a unit to hold the temperature in (eg degrees Kelvin or Absolute) , and always convert F or C into that unit. Now I can name the variable "degreesKelvin", get rid of the tempUnit variable altogether, and the code is instantly 100% …

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK. got it
5(tempNum-32)/9
isn't a valid expression. You must specify the multiplication explicitly. It's just not one of the compiler's best error messages ;)
(ps no point having doubles for the results when the input (tempNum) is just a float.

Raymond_3 commented: haha! wow thanks james can't believe it was just me needing to put an asterisk! +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That looks OK - maybe the parens are already out of step before that code?
Also, I don't know what the data type for tempUnit is, but it's unusual to see a char as parameter for equals. char is an integer primitive type, for which == is appropriate.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Looking at that table the most obvious approach is to create a simple class that represents one row, with instance variables for each column. The whole table is then just a one-dimensional array of objects of that class. That array is also then 90% of what you need for a custom TableModel to display the whole thing in a JTabel.
The getters & setters may be just a bit tedious to write (or use Eclipse/Netbeans to generate them for you), but that's how you implement stuff like controlling R/W access to certain values.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Please mark this "solved" if it's working now.
Thanks
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sorry, I haven't used awt for 15 years, and I have forgotten whatever I did know.
I guess you will just have to search through the API doc.

But there are some general errors to fix...
the ONLY thing you should ever do in paint(Graphics g) is paint. You have no control over when or how often it will be called. So, for example, if you add an action listener in there, an new action listener will be added every time awt decides a repaint is needed.
The right thing to do is to add a listener to the button as part of your init. In the listener get the radius and store that in an instance variable, then call repaint().
In your paint just use the current value of radius to paint the text and circle.