1,678 Posted Topics
Re: At the start of the paint method, call super.paintComponent. This should have the effect of clearing the screen. If it doesn't, draw a new rectangle on the screen that is the color you want (white or gray probably) that fills the whole screen. | |
Re: No, it is not a "reserved method". He means for you to create the method, so that [I]after[/I] your Object is created, you can use that method to pass it to the other class. A small example: [CODE=Java] public class ExampleClass{ String myString; public void setString(String otherString){ myString = otherString; … | |
Re: You could also use an anonymous inner class and create a new Runnable and put the code you want to run in a different thread in there. | |
Re: [QUOTE=Narue;892955]When I hear people say stuff like "I love programming" and "if it doesn't pay well, what's the point?" in the same sentence, I think that one of the statements is a lie.[/QUOTE] But it does pay well, so I don't know why anyone would say those things in the … | |
![]() | Re: Also, consider the fact that you can jump to the next word by reading in the next chars after each word until you find the space. You know the next word is after that space. |
What would be the best way to implement dynamic search? So, for example, given the words: the, then, behemoth, abchemto Typing in 'he' would return all of the above words since they all have he in them. Is the best way to do this using a Trie? | |
Re: For "going through the maze" I'd recommend searching daniweb and reading the other five hundred maze threads. | |
Re: Probably because your data is stored on servers, possibly multiple different servers, and you need some way of accessing it. | |
Re: Start by thinking about what inventory management is, and what processes it typically involves. Then continue by making each of those processes into a piece of functionality, dividing the functionality, and coding :) | |
Re: Try opening it with this constructor: public FileInputStream(File file); First, create the File Object. See if creating the File object also throws an Exception; if so, print the Exception's contents and getMessage() message in here. Also use the File class's file.canRead() method and tell me if it returns true or … | |
Re: It looks like I could have helped, your explanation is quite confusing though. What I don't get is why you don't simply post an example of what you are trying to accomplish. For example, I'm trying to transform 1 into 2 1. array that holds: 1 2 3 4 5 … | |
Re: Maybe I don't understand your hierarchy, but I believe you can also use super.methodName() to call the superclass's method instead of the class's method. | |
Re: The most precise unit is as precise as you can get, so Rashakil's analogy does not make sense to me. You can get less precise, but not more precise. | |
Re: If you want to write an Object out to a file, you need to implement the Serializable interface, look up "Java Serializable". If you just want to write text into a file, that is different, and you could use [code] BufferedWriter out = new BufferedWriter(new FileWriter("outfilename")); out.write("aString"); out.close();[/code] Or a … | |
Re: You can use regular expressions. I'm not good with them since I hardly use them, but they aren't that bad, just a set of rules to specify which characters to match basically. Look up regex or regular expressions java on google. | |
Re: Use a Scanner to read the numbers from the text file, and read them in as ints, not as Strings. Scanner scanner = new Scanner(new File("filePath")); int next = scanner.nextInt(); Good luck. PS the reason your current code doesn't work, at first glance, seems to be because you are reading … | |
Re: 1. Read the forum rules. 2. Read how to use code tags in the sticky 3. Explain what your code is meant to do, what it does, a description of what exactly you need help with, and where you think the problem is. | |
Re: FYI, there was recently a thread in this forum in which I explained how to create a shortest path algorithm. If you do a search for 'maze' it should be one of the first results. In short, use a queue to find the shortest path of the maze. | |
Re: edit lol I realized I was wrong. | |
Re: Post an example input file and the corresponding example output file. The examples you posted don't correspond and therefore don't make any sense to me. You also said that each line in File A translates into something in file B... give a sample of one line from File A, and … | |
Re: It might be placed correctly, but the syntax is definitely wrong. You said if (whatever); <----- the semicolon should not be there. An example if statement: if (i > 0 && i <100){ printf(whatever); } You need brackets. | |
Re: Von Savant problem? I might have spelled her name wrong. I don't remember the reasoning and this problem is actually tricky, but I think I remember the answer: yes you should switch. My guess at the reasoning would be that after the host showing the one door, you now have … | |
Re: IMO you are just over complicating things. . it isn't wise to use two tools, in this case programming languages, unless one offers features or some advantage that the other doesn't. I'd go to the C++ forum and get help with connecting to the internet rather than trying to use … | |
Re: [QUOTE=weblover;890462]i looked up the api ....and there is no method that let's u output the element of a stack ....and for the Queue where can i find a ready class for it ....thnx for help[/QUOTE] Oh, there isn't? Because by typing in "Stack java" to google I found [URL="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Stack.html"]this link[/URL]. … | |
Re: You can draw the Rectangle from within paintComponent just by using g.drawRect or g.draw3DRect or whatever the methods are. You are over complicating things by using the coordinates and whatnot. | |
Re: Yes but wouldn't grisha have realized that? The only way to get a 0 length String there is to just hit enter.... | |
Re: No, nobody uses it. The closest you will find to someone who uses binary is someone who codes in Assembly, which is broken down by an Assembler into binary. And no, it will not make you a master coder. It will probably frustrate you a good deal though. If you … | |
Re: The + operator only works with certain types. If you aren't using it with those types, then it isn't going to work. If you want more detailed reasoning on this, masijade is probably your man. But you should try using the floatValue method of the Number class, then adding the … | |
Re: OP: The idea of the try catch is that [I]if[/I] an Exception occurs, you are prepared to deal with it. The catch part deals with the Exception. The try catch construct does not throw an Exception, nor do you want to intentionally throw an Exception here. | |
Re: Without spending too much time looking at this because I need sleep, it looks like its Java code at first glance. The JButton and Jpanel etc are part of a part of java called Swing. What version of Java do you have? You might want to update. | |
Re: The way I would do this is to use a GridLayout. You can use the follow snippet to create a GridLayout with two columns: GridLayout layout = new GridLayout(0,2); Then you would add your first line, add your second line, and add a blank line TWICE. The reason for adding … | |
Re: And what is the problem? I assume this is also in your other thread? (Hint: Put it in here) :) | |
Ezzaral & James -- I remember (and found) a thread from a while back where you guys gave me an example of an Observer pattern. Basically a model had a List of interested Listeners. When the model changed, it went through a for loop, notifying each listener (the views) that … | |
Re: If you want to use a Date, a JSpinner would be a very good idea. Search it on google - there are plenty of examples. You weren't very specific about what the description is allowed to contain, but you can use a JFormattedTextField for a lot of things. Here is … | |
In one View, I have text boxes and buttons. In the other View, I have a Pie Graph that I created using JFreeChart. When the button is clicked, I want the Pie Graph to be refreshed, displaying the new percentages (based on what the user entered in the text boxes). … | |
Ok, as I mentioned to Ezzaral, I'm working on learning Eclipse RCP but it is pretty hard to find good resources. I've found one good resource but it was written in 2006 and I'm really looking for some up to date online tutorials or resources using Eclipse Ganymede. Does anyone … | |
Re: There is no GUI, so I'm assuming your job is to make one that plays this game. You're going to need to think out a design to allow the user to play the game for starters. Once you've done that, come back, describe your layout, and I'll help more | |
Re: You cannot add a JFrame, or a class that extends JFrame, to a JPanel. | |
Re: A comparison is when you compare, possibly using the compareTo method (or operators such as <, >, and ==), one Node's value to another Node's value so that you can see if the first value is greater than, less than, or equal to the second value. A key comparison is … | |
Re: I'll give a short explanation, but it is exceedingly difficult without simply creating a small maze, creating a stack and a queue, and walking through the small maze using this procedure: 1. From your current position, *initially the start* add the cells of the maze (that you can 'walk to' … | |
from Java Sun's JavaBeans tutorial: "The accessor methods for a bound property are defined in the same way as those for simple properties. However, you also need to provide the event listener registration methods forPropertyChangeListener classes and fire a PropertyChangeEvent (in the API reference documentation) event to the PropertyChangeListener objects … | |
Re: You have to create a new Object of type Random before you can use it to generate the random numbers. If you go to the link Vernon gave you, you will notice that the class is called [I]Random[/I]. So to use a method of this class, you need to create … | |
Re: I don't see the createImage method in any docs for the Image class. Post a link to the doc for me please? Also, why would it be able to construct an Image from an InputStream? What you want to do is read the data from the InputStream, then construct an … | |
Re: You could use the Java class Timer. Or you could do something inane like int i = 0; while(i < whatever) i++; And this while loop would take a certain amount of time to complete, so there would be your pause. | |
Re: A recursive termination condition is generally called a 'base case' I think. So go look up 'recursion base case' on google. I've never even heard it called a recursive termination condition before. And a base case is necessary because without one, your method will keep recursively calling itself, and will … | |
Re: And to clarify the '&' issue, if it wasn't already, the scanf function needs to know what the [I]address[/I] of something is, and the '&' is the address of operator. Since the pointer already contains the address, it doesn't make sense to use '&' in that case. | |
Re: I don't mean to give you different advice than Vernon, but it seems odd that you'd want the Car class to track that information. The Race class should contain the method that tells you what Car(s) are in front of or behind a particular Car. The Car class probably shouldn't … | |
Re: for the first issue, I think you need to check out KeyListener. Google for some examples. No idea about the second. |
The End.