1,678 Posted Topics
Re: [url]http://java.sun.com/javase/6/docs/api/java/lang/SecurityManager.html#checkDelete(java.lang.String[/url]) That might be of interest to you. I'm pretty sure if there is some security measure, you aren't going to be allowed to delete the file. That is, after all, the point... right? | |
Re: It's not necessarily better style/design. And if the job of one function requires another function, then you should call the other function within the first function. You shouldn't use main to do it. And I'm kind of curious how to do this as well, which is why I am upping … | |
Re: I don't know what Garwick's algorithm is. Logically, if one section of the shelf needs more room, you will then have to re-divide the other sections so that the whole thing takes up the same amount of room as it did previously. Obviously, your project description is suggesting a method … | |
Re: Dijkstra's algorithm would not be easy to modify, I don't think. . if you do the algorithm on paper, you end up with a 'trail' of visited Nodes in your shortest path. This means that when you program it, you're essentially keeping track of each Node on the shortest path. … | |
Re: Another thing, that isn't the source of your problem... you might need to have a different Object for each layout. You're using the same 'cards' GridLayout for both. I'm not really sure about that but I typically see a different one for each panel. (Someone confirm or deny that?) | |
Re: If your class that you're making an ArrayList of is called Supplier, write a toString method in the Supplier class. The toString method should return a String that contains all the information (name, etc) for a Supplier. Then, for each Supplier in the ArrayList, do yourTextArea.append(Supplier.toString()) | |
Re: Well, just for the hell of it, I'm going to write a Sudoku program also. It might take me a few days since I have other things to do this week and I don't know how to play the game yet. Lol. Could you post your input that's taking a … | |
Re: How can I access variable in the frame from a component 2-3 levels bellow? The class that contains the user ID and password should have a get method. Just call it and return the relevant info to caller. No need to pass it to things that don't need it. | |
Re: If its possible to do so then the Javadoc for RandomAccessFile will tell you how. edit: It looks like it should do it by default from what I just read. Post your code in code tags. | |
Re: [QUOTE=~s.o.s~;764923]> whenever you access a method, it gives you a summary of what the > method does, as given in the API ...so do the online java docs. But in most of the cases we end up with a bunch of CTRL + SPACE programmers who find it too troublesome … | |
Re: Make a boolean allNums = true; 1. Create an array of size 20. 2. Loop: Read the numbers in, and put them into the array 3. Loop: Check the array at each index. If the number isn't there for any index, set allNums to false. 4. If allNums is true, … | |
Re: try this [CODE=JAVA]File file = new File("C:/theFile.txt"); file.delete();[/CODE] | |
I managed to delete the only up to date saved copy of an important Java project I had (I know, I know). I have the compiled .class files and I know it's possible to decompile them. Can anyone direct me to any references or anything to help me do this … | |
Re: You can't use "==" as a comparator on Objects. On Objects, "==" will only tell you if the two Objects are at the same memory location, I believe. In any case, it will not compare the two things for equality like it would if you said "does int 1 == … | |
Re: I would imagine that Puneetkay is correct since this is what I know from experience. But if you want to explicitly delete the file, use the File class. [url]http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html[/url] File myFile = new File("fileName.txt"); myFile.delete(); | |
Re: Have you managed to send the site a request to look up the weather (based on the zip you send it) yet? If not, plain text isn't going to do you any good. So let us know which part you are stuck at. | |
Re: Not really. I could be wrong, but I remember this girl making earlier threads similar to this one. Not that she deserves to be harassed, just ignored. | |
Re: I think you could also save yourself a lot of the if statements if you used a counter to index the correct part of the array along with modulus and/or division. | |
Re: Does it have to be a JOptionPane? JOptionPane's are usually supposed to be used to display messages, not get them, I think. They can also display a list of choices and get the user's choice. Here's the Sun tutorial for JOptionPane: [url]http://www.j2ee.me/docs/books/tutorial/uiswing/components/dialog.html[/url] If you're open to using different types of … | |
Re: I don't see how giving suggestions is an unfair advantage, as long as nobody is doing his work for him. I can understand if you're unwilling to help him because he hasn't shown any effort (as I am) but if it's an unfair advantage, then any help given on Daniweb … | |
Re: You didn't mention what you want to do with the data once you retrieve it. But you can retrieve any of the digits using theString.charAt(index). You can also use Integer.parseInt(String) once you get that digit, to see if its a 0, a 1, or neither. There might be a performance … | |
Re: George, I think I understood everything you were saying up to here. "I also want to register/unregister message sender/receivers dynamically." What does that mean? Because up until then, it sounded like you simply wanted a generic priority queue, which is not hard to implement yourself, since Java already provides a … | |
Re: Why would you use a loop to search? Look at the methods for the Vector class. Particularly, look at the indexOf method. If you override the equals method from the Object class, then use indexOf, it will return the index of the thing you are looking for. So your "search" … | |
Re: Yes, but that still doesn't guarantee that value will == 0, unless you explicitly set it to be so. | |
Re: And you don't have to use recursion to test whether something is a palindrome or not. | |
Re: You want to put your choices in a while loop, so that they will continuously be displayed on the screen. [CODE]while(true){ // Your choices that you listed above go here. The way the program should exit is when the user inputs '4' to exit, you should say System.exit(0); // You … | |
Re: [url]http://java.sun.com/j2se/1.4.2/docs/api/java/io/PrintWriter.html[/url] Look at the API. Do you see a constructor for PrintWriter that takes a String as an argument? (Change your code so that your PrintWriter takes the correct argument) You might want to look at this link, since from the API, it isn't immediately obvious which type of Object … | |
Re: First of all you need a class to represent each 'game'. The class would contain the following data: int correctNumber; int guessesAllowed; int guessesLeft; You might need a few more things. You also need to split each task into methods. For example, prompting the user for their guesses could be … | |
Re: You can't create Objects of an abstract class. So its impossible to add them to an ArrayList. An abstract class defines methods/data so that any classes which extend it have to implement those methods/data. Read this. [url]http://java.sun.com/docs/books/tutorial/java/IandI/abstract.html[/url] | |
Re: Couldn't you also convert the char to an integer, then compare the two chars? Being careful, of course, for case considerations? | |
Re: Google 'Timer Java'. If I remember correctly, a similar question to this one was asked a few weeks ago, and the solution is to use the Timer class because it is invoked on the Event Dispatch Thread (and thus won't cause problems w/ your GUI stuff) | |
Re: Do you not understand Vernon's point about the variable ba? Learn the basics first, then work your way up. Btw, what are you referring to when you say 'input name'? Also, post your code that you think is incorrect, or ask a specific question. And make sure to use code … | |
If I have a hash function h(k, f(i)) and f(int i){ return c * i; } And the first index that it tells me to insert the element at already has an element there, what do I do? Would the proper way to insert an element the first time be … | |
I'm trying to read in the whole file at once. If this code ever fails, my whole project will fail. I'm using the following: byte[] theFile = new byte[input2.available()]; then, input2.read(theFile); The API says something about blocking. What exactly is blocking, when will it happen, and how will it affect … | |
Re: I just spent 5 minutes looking over your code and I have no idea what you're talking about. Could you explain what you want each one of your classes to do? Then, explain which of these classes is not working like you want it to, and explain how you want … | |
Re: Use code tags when you post code. Also, all you have to do to figure out if your code is correct is print out the array after you read it in. If it doesn't print out the same thing as the input file, then it isn't correct. To refer to … | |
Re: If I'm not mistaken, she is just looking for a way to "pause" after each word is displayed, but she doesn't know it. She thinks what Stul said above - that it's just not working - but it probably is working and just is disappearing too fast to be seen. … | |
[CODE]public void generateBits(Node root, int current, int counter){ if (root== null) return; if (root.left == null && root.right == null){ list.add(new HuffCode(root.theChar, current, counter)); } else{ current<<= 1; //move all the bits 1 spot to the left generateBits(root.left, current, counter+1); generateBits(root.right, (current | 1), counter+1); } }[/CODE] Somehow, this method … | |
I had a problem w/ efficiency - The problem was that using String concatenation was inefficient for large text files, when reading the whole file into the String. I've since thought about it, and I guess this is because Strings are immutable - so every time concatenation is done, a … | |
Re: Making a class serializable in java means that you can read it from and write it to a file in binary form. So when your program exits, that is when you should be writing all of your objects to the file. When your program starts, you read them in from … | |
I'm having trouble with storing bits as a byte. I've read probably 30 different sources about this already. I'm doing Huffman Compression. Lets say I read in the character "c" and I am supposed to output "1010". How would I go about doing that? I know how to write bytes … | |
Re: [QUOTE=neo_gr8est1;751733]Can someone please help with this project of mine? I am not really good at GUI... create a new account, check account status. and make purchase with a credit card. Create a New Account You must ask the user to input some information: applicant's name (e.g. "John Smith"), application date … | |
Re: ^ That code looks wrong. Who modifies main to throw an Exception? Also, since his Exception is printing "Invalid ID", your code would print the same thing twice. And most importantly, when you declare a method as 'throws Exception' in the method header, the method that calls it has to … | |
Re: There are a lot of ways you could produce that code using while loops or for loops, but most of them should not be coded using a while loop or for loop, unless your teacher is trying to make you use a math formula to calculate the number of '*' … | |
Re: Your professor already gave you basic steps on how to begin. Try those and when you get stuck, tell us what you don't understand. We won't do your assignment for you. | |
Re: You should only be setting mouseLeft, mouseRight, etc to true if, in fact, the mouse was moved in that sector. When your mouseMoved method gets called, you are setting ALL of them to true, then calling repaint. The way you're currently doing it, if mouseLeft were to be set true, … | |
Re: Why would you post something in German. Lol | |
Re: [QUOTE=Sereal_Killer;747062]there is no way to use the return value of a method for creating an int variable[/QUOTE] That is not true. | |
Re: Your professor gave you whats called a GUI. A GUI is just a window that, in this case, provides the user with a way to enter data. Now, to elaborate on that idea, I'll comment some of your professor's code to help you understand what he wants you to do. |
The End.