2,777 Posted Topics
Re: A general comment on your coding style: Instead of chaining all those constructors and methods in one statement, break them up into separate single steps. I'm not sure what your mess of code does with creating a new DataInputStream object every time around the loop. The reason the first 'a' … | |
Re: To fill a component with characters you need the size of the component and you need to get the size of the characters in pixels. See the FontMetrics class. It has many methods for getting sizes. Use the Graphics class getFontMetrics method to get the needed object. | |
Re: See the Java Tutorial for code samples.[URL="http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/"]http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/[/URL] | |
Re: [QUOTE]"I get reach end of file parsing"[/QUOTE] Is that an error you get when trying to compile the program? Some times you need to add some } at the end of the program. Add one } and try compiling. Same error, then add another. etc If that doesn't work then: … | |
Re: There are two steps in using arrays of objects: First define the array -> creates empty slots with null values Second assign values to each of the slots/elements in the array. You haven't done the second step. You need to put a Student object into the array before you can … | |
Re: What is the purpose of removing the label? Do you want all the components to shift to fill in the hole where the component has been removed? Please use code tags around posted code to make it more readable. Use icon above to right. Info here: [URL="http://www.java-forums.org/misc.php?do=bbcode#code"]http://www.java-forums.org/misc.php?do=bbcode#code[/URL] [B]Please fix your … | |
Re: [QUOTE] how can i do the rest[/QUOTE] Please be more specific about what you want to do. | |
Re: [QUOTE] I am not getting it to work.[/QUOTE] Does it execute? Is there output? Can you copy and paste here the program's output and explain what is wrong with it? | |
Re: [QUOTE]This doesn't work[/QUOTE] Please explain. Show what the code outputs now and explain what is wrong with it and show what you want it to be. | |
Re: [QUOTE]Void means the method takes no arguments[/QUOTE] void means the method returns no value | |
Re: Ok here's a start: [CODE] class Car { }[/CODE] You'll have to fill it in a bit. Take it one step at a time. For example decide what fields it needs, define them and then add the accessor methods. Write a small test pgm to exercise it by creating it, … | |
Re: [QUOTE] I always get null when I run the program[/QUOTE] Please copy and paste here the full text of all error messages. | |
Re: Please post your code inside of code tags.Use the icon above to right. Info here: [URL="http://www.java-forums.org/misc.php?do=bbcode#code"]http://www.java-forums.org/misc.php?do=bbcode#code[/URL] Your command line needs to include the current directory indicated by a . C:\Users\User>java -cp [COLOR="red"].;[/COLOR]quaqua.jar Account Since your class is in a package, you also need to include the package path to the … | |
Re: Use if statements following the logic of the statements you have in bold letters. Do you know how to write a multipart condition test in an if statement. For example: if(exp1 oper exp2) where cond1 and cond2 are boolean expressions (like: a < 4) and oper is a boolean operator … | |
Re: Can you ask specific questions about your problem? What do the values you labeled as output and players.txt represent? The output part has 3 lines with 2 tokens on each line, the players.txt part has 4 lines with 3 tokens on each line. What is the relationship between these two? | |
Re: The class Newfile must implement the inherited abstract method. Read the API doc for that interface and make sure you have correctly coded the methods it defines. | |
Re: There are probably many ways to do that. | |
Re: [QUOTE]wont re-execute when the wrong number is entered.[/QUOTE] What controls the re-execution of the loop? Where is the value set to allow the loop to exit? If you can't see where your logic problem is by playing computer with a piece of paper and pencil, Try adding some print outs … | |
Re: [QUOTE] it doesnt work well.[/QUOTE] Please explain what happens. For debugging: print out the String being searched for with delimiters to verify the computer is using what you expect. What is the relationship between studentName and book.studentName? [QUOTE]i have a comparator function.. in the class:[/QUOTE] Can you explain what a … | |
Re: You forgot to post your code and your questions about problems you are having with your code. | |
Re: You don't give enough information to understand what your problem is. [QUOTE]i don't know how can I do so[/QUOTE] You can't do it. As tong1 said, you can NOT put an int value in boolean array. | |
Re: Look at the PixelGrabber class for a way to get the pixels for an image. Also look at the BufferedImage's getRGB() method | |
Re: You could read a whole line into a String and then create a Scanner to read individual words from that String. To rewind back to the beginning of the String, create a new Scanner with that String again. | |
Re: Please explain what the code is doing or not doing. Try debugging the code by adding print outs to show where the execution flow is going. Please put your code in code tags. Use icon above to right. Info here also: [URL="http://www.java-forums.org/misc.php?do=bbcode#code"]http://www.java-forums.org/misc.php?do=bbcode#code[/URL] | |
Re: [QUOTE]ArrayIndexOutOfBoundsException: 5 at Duplicates.NumberCheck(Duplicates.java:32)[/QUOTE] The array referenced at line 32 of you code does NOT have 6 elements in it. How does the value of the index exceed the array size when you execute line 32? If you're not sure how the value changes, print it out each time you … | |
Re: Play computer with the code. Take a piece of paper and write down the values of the variables as you mentally execute each statement. For example the first time this statement is executed: for(int count = 0; count <= 3; count++) count will have a value of 0 Add some … | |
Re: [QUOTE]But I want the output to look like this: intNum + doubleNum = sum [/QUOTE] This is too simple but here's what you are asking for: System.out.println("intNum + doubleNum = sum"); or is it this: System.out.println(intNum + " + " + doubleNum + " = " + (intNum + doubleNum)); … | |
Re: [QUOTE]You are required [/QUOTE] Shouldn't it say: "I are required"? Do you have any specific questions about the project? | |
Re: [QUOTE] it doesn't work[/QUOTE] Please describe or show the problem. | |
Re: Try printing out the value of letterGrade after it is assigned a value to see what the computer thinks it is. | |
Re: What java programs have you written so far? Do you know how to write a class with a main method? Start with that and add on. Also could you speak English when posting? | |
Re: Try asking the question on a javascript forum for better answers. | |
Re: Hard to say. Are you sure the img object holds a valid image? | |
Re: Please post your code in code tags to preserve formatting and to show the real code without there being a hyperlink in the middle of it. | |
Re: What code do you have so far for your problem? | |
Re: [QUOTE]i need to have something that can link a keyword with the "image". [/QUOTE] Look at the Map class or its extensions. The value could be a list of the images associated with the keyword. Is the "image" an object containing an image or is it a String? | |
Re: Can you explain what your problem is with creating a window? Your current code creates one, so you know the code to use. You could create a new class that extends JFrame, create it, initialize it and set it visible. | |
Re: To help you see what is happening as you do the math, print out the values as they are generated. Think of a decimal number in these terms where di is a decimal digit value 0-9: 1000*d1 + 100*d2 + 10*d3 + d4 when you reverse this number the d1 … | |
Re: [QUOTE]Use "if" to work out what button has been pressed,[/QUOTE] Look at the Event object passed to the action listener. It has methods you can use to determine what object sent the event. Your code already has that? Can you explain what your problem is? You know how to get … | |
Re: [QUOTE]I'm not sure how to return the info in the class method.[/QUOTE] I don't see what method you are talking about. Line 27 is in the main method which does NOT return any values (its void) Please explain. Do you get any errors when you compile the program? | |
Re: Sorry, I missed your question. Does the program work ok? | |
Re: Where is the variable: scan defined? The compile can not find it. There is a variable: input that points to a Scanner object. Is that it? | |
Re: Where do you want to create the source? As a disk file or as a String? A disk file could use the javac command to create the class file, the String could be compiled by a JavaCompiler object. What questions do you have about creating a java source? Why do … | |
Re: Perhaps if you could get the source file for the applet,you could rewrite it to work on the new hardware. | |
Re: [QUOTE] use a 2d array instead of a regular for loop[/QUOTE] Apples and oranges. An array is used to store data A loop controls execution [QUOTE]how i should go abouts displaying the buttons on the board.[/QUOTE] How does that question relate to the posted code? You'd use some layout manager … | |
Re: Try debugging your code by making the method calls separately and printing out the values or the variables as they are executed. You must not be using the methods correctly. By doing each step by itself and examining the results you will see what you are doing wrong. jtextArea1.append(source.replace("aa", "q")); … | |
Re: Break up the equation into simple binary operations and someone can show you the code. For example to multiply two variables: var1 * var2 [QUOTE] how do I represent the symbol x[/QUOTE] A variable named: x would be defined by putting a type in front of the x: <THE TYPE … |
The End.