1,678 Posted Topics
Re: [CODE=Java]public Object getValueAt(int row, int col) { return rosterList.get(row); for(int i = 0; i < 28; i++) <------- unreachable statement error { return col = i; } }[/CODE] You said return rosterList.get(row) which causes whatever element is at rosterList.get(row) to be returned. When you return something, you are literally "returning" … | |
Re: Aren't "adding the books" to the database and "storing the books to the database" the same exact thing? You said them as if they were different. And we don't do chats and stuff like that, keep it on the site. | |
Re: public class DVD extends Product He means they have to go above where you make the class declaration. (Also note that if you have a package declaration, they should go below that). Example: package whatever; import whatever.*; public class Other{ } | |
Re: You can import the class where "InterruptedExeption" is located. You're getting the error "cannot find symbol, class InterruptedExeption" because the compiler does not know what that class is. It doesn't know because you have not imported the resources. And "InterruptedExeption" is obviously a class you created, because you spelled Exception … | |
Re: There will be a "carry over" if the result can't fit into a 32 bit integer, presumably, which will cause the carry flag to be set. Then you just need to check the carry flag, which will be 1 if there was a carry, 0 otherwise | |
Re: You're in the wrong forum, but if you were in the correct one, pasting a project description at people is unlikely to get you anything except complaints. | |
Re: I don't know too much about KeyListeners, but [CODE=Java] if ((e.getKeyCode() == KeyEvent.VK_ALT) && (e.getKeyCode() == KeyEvent.VK_ENTER)) { txtArea.setText(txtArea.getText()); txtArea.setText("\n"); } if (e.getKeyCode() == KeyEvent.VK_ENTER) { lblDisplay.setText(txtArea.getText()); txtArea.setText(""); txtArea.requestFocus(); } [/CODE] doesn't look like it could possibly work. If the first of those statements was true, then the second one … | |
Re: [QUOTE=niek_e;865588]You both [i]do[/i] realize that we can't access area 51 right?[/QUOTE] They're aware. If it's anything like most sites, not a whole lot goes on in the employees only area/mod lounge/whatever its called anyway. (Although the site I adminned only has 100,000 members and this one has 5x that, so … | |
Re: [url]http://daniweb.com/forums/announcement9-3.html[/url] And use =Java as the syntax. | |
Re: You can't test a piece of code you wrote? And your professor told you not to test it? Hmm. And if you use Eclipse or netbeans, they will create a package for you quite easily. If you need instructions on how to do it in either of those IDEs, I … | |
Re: All the links Vernon pointed you towards are Timer related, it seems like. His may be a better solution than what I'll show you, but there is another way to do it pretty easily: Use Thread.sleep(milliSeconds); Then call whatever method it is you wanted to run every five seconds. You … | |
Re: Another student in your class posted on this forum not too long ago. At least I'm assuming that's the case, since you guys basically have the same exact program other than the movie names. Anyway, your problem is that you are overwriting your dvd in the Invent2 class. edit: Nevermind. … | |
Re: You should also consider marking your threads as solved when you consider them solved. IMHO its kind of rude to repeatedly get help and not bother saying thank you by marking as solved. | |
Re: You're in the wrong forum. And generally, a for loop is better for iteration than a while loop is if you know what values you want to iterate over. | |
Re: Save the sentence that they type in into a String, lets call the String mySentence. Then use javax.swing.JOptionPane.showMessageDialog(null, mySentence); and it will display your string in a window. | |
Re: You have a while loop that does while (noOfRentUnits is 0). But you never set noOfRentUnits to anything other than 0. Furthermore, you said profit = total rent - maintenance expense. But you defined total rent as noOfRentUnits * whatever, and you defined maintenance expense as noOfRentUnits * whatever. Both … | |
Re: Make a class that extends JApplet. And follow [URL="http://java.sun.com/docs/books/tutorial/uiswing/components/tabbedpane.html"]this tutorial[/URL] to make tabs. | |
Is using (in the paint method) g.clearRect() the correct way to clear the screen? It's working but I don't know if there is a better way. . google says it is supposed to clear automatically when update is called but that doesn't seem to happen. | |
I have a list of teams, it can be any length. Now, for each team, I want to create a 2D box that says the team's name in the box. And I want to match these teams up against each other. So basically I want to be able to drag … | |
Re: I think he was being sardonic. That might be the wrong word. In any case, he was giving you as much information on the topic as you're going to get, considering the unclearly written, uncommented code that you posted & the code it uses which you didn't post. Not to … | |
Re: As hard as I searched, I did not see a question mark anywhere, leading me to believe you didn't ask one. | |
Re: If you want things to show up in a grid then use GridLayout. I'm not saying its impossible to do otherwise but why make your job harder than it needs to be. | |
Re: That's because scanToken = new Scanner(line); creates a new Scanner object based on the String, line, that you passed as the argument. Obviously, since line is a String, it is not an integer, and trying to read ints from it will not succeed. The first declaration of Scanner that you … | |
Re: If you could read the forum rules by tonight, I'd appreciate it, unless you think someone is going to do your code for you. [url]http://www.daniweb.com/forums/announcement9-2.html[/url] | |
Re: if (iStream.close() { // print out the results here. System.out.print("Enter a fname: "); System.out.print("Enter a fname: "); System.out.print("Enter a fname: "); System.out.print("Enter a fname: "); System.out.print("Enter a fname: "); System.out.print("Enter your vote (0-4): "); } } First of all you have a syntax error because there is no closing paren … | |
Re: Do a web search - BubbleSort is a very common algorithm. You won't have trouble finding hundreds of Java code examples. Compare them to what you have and you'll see what sections you need to implement. If you're still confused at that point, then come ask. | |
Re: Implement ActionListener. In your actionPerformed method, write a for loop to set each element of the array to null. [url]http://java.sun.com/docs/books/tutorial/uiswing/events/actionlistener.html[/url] | |
Re: "however should i do this seperate from the mouselistener on the component itself??" I might be misinterpreting what you said, but if not, you can define an inner class that implements MouseListener, then add a mouse listener of that inner class type to the component. [url]http://www.javaworld.com/javaworld/javaqa/2000-03/02-qa-innerclass.html?page=2[/url] edit: as for your … | |
Re: [url]http://lists.apple.com/archives/java-dev/2003/Aug/msg00683.html[/url] I'm not sure how helpful that reference is, but there are hundreds of answers to this question on the web. And on daniweb there are quite a few as well. | |
Re: Google search? [url]http://support.adobe.com/devsup/devsup.nsf/docs/51545.htm[/url] | |
Re: Not supposed to give away code, as this doesn't really help you learn, but any explanation I give you will be much more complicated than the code itself is, and might confuse you, so here is how you do it. public String toString(){ String s = ""; if (power==true){ s … | |
Re: So that we can initialize our program's variables without knowing ahead of time what they should be initialized to. Consider the String class (that Java provides for you). If there wasn't a constructor String s = new String("This is what it'll say!"); then I couldn't make the String say that. … | |
Re: If what you're trying to do is width/2, You need to input the width, then have the program divide it by two for you. Sorry if that doesn't answer your question, I'm not quite sure I understand. | |
Re: Like the error message says, you're trying to call a method that takes int,int,int but you're passing int,int,int[]. So either re-declare the method as taking an int[] as one of the parameters, or call the existing method correctly. | |
Re: Not sure if that is a homework question or not, but that is a good question. Here is one example I found on the web, it seems legitimate, and it makes a good point that you would not be able to have the same functionality without the inner class. [url]http://www.sbras.ru/win/docs/java/tutorial/java/javaOO/innerclasses.html[/url] … | |
Re: It sounds like what you want is just a JLabel followed by a JTextField. [url]http://java.sun.com/docs/books/tutorial/uiswing/components/textfield.html[/url] | |
Re: You can't instantiate an abstract class or call an abstract method as far as I know. What exactly are you trying to do? Post the code where you're trying to "get the abstract method to work". | |
Re: A member here suggested this tutorial on animation a few days ago: [url]http://www.developer.com/java/article.php/893471[/url] I don't know how helpful it will be, or if it answers your question, just passing it along since it is an animation tutorial suggested by a reliable member here. | |
Re: Yes, use a JTabbedPane. Tutorial [URL="http://java.sun.com/docs/books/tutorial/uiswing/components/tabbedpane.html"]here[/URL]. And you create buttons using the JButton class. If you have to move the buttons around, you might want to look into different Layout Managers, some are better than others as far as giving you control over where things are placed. | |
Re: You could also simply go to the directory where your netbeans projects are, and drop any files that your program needs in the right place. Then netbeans will automatically include them in your jar file and your program will find them correctly. | |
Re: No, that does not work. What you need to do is each time you generate a random number, check every index of the array (using a for loop) to see if that random number has been generated before. If it has, generate a random number and check again. If it … | |
Re: You have to write the method using a method body. What's the point of having a method that does nothing, like your current one would, anyway? Either that or declare the class as abstract. Listen to your compiler. | |
Re: Objects are just representations of things and their data. Each class in Java represents an Object. So, for example, if you made a class called Car [CODE=Java]public class Car{ String steeringWheel; String brake; int horsepower; int miles_per_gallon; public Car(String typeOfWheel, String brakeType, int power, int mpg){ steeringWheel = typeOfWheel; brake … | |
Re: You are in the Java forum. I imagine you'd get a better answer in the correct forum. | |
Re: Well explain what, specifically, you need help with. i.e. X method ]doesn't work, and it is supposed to do Y. Or I need help with reading in the file. etc. | |
Re: Did you try: if (turn > 0){ return CCW; }else if (turn < 0){ return CW; } return COLLINEAR; Worth a try, and does the same thing as you were trying to do with your code above. | |
Re: Well, you declared a double[] doubleArray. So you have to change the method header of the total_average method to double[], not to double, since you want to pass in an array of doubles. Then in your main method just say total_average(doubleArray); | |
Re: Errors: 1. "string" is not a type of Object. It is "String". Change that declaration of public static void main string[] args to public static void main String[] args. 2. You declared a, b, c, and d twice. You can only declare a variable once. Saying 'int whatever' declares a … | |
Re: For any class that implements Map, you can use Map's get method() to get the value, then assuming it is a float, add it to the other float. [url]http://java.sun.com/javase/6/docs/api/java/util/Map.html[/url] eh? [url]http://www.daniweb.com/forums/thread189520.html[/url] The other thing you should do is not double post threads. |
The End.