1,678 Posted Topics
Re: This is the Java forum. Java is an Object Oriented programming language. Javascript is a web-based scripting language. | |
Re: Since you're using the File class, you can use the class's getName method to return the name of the file associated with it. If that method doesn't work for you, here is the Javadoc [url]http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html[/url] | |
Re: Read in the first three lines and throw them away. Using fscanf, you can read in doubles with %lf, floats with %f, and you can use %s to read in Strings. %s will get rid of the first word I believe (first thing matches by the delimiter pattern, which is … | |
Re: With Google. April Fools! Read this tutorial, I think it is what you are looking for. And I also think I linked someone to it maybe a day ago. [url]http://java.sun.com/docs/books/tutorial/2d/images/index.html[/url] | |
Re: Using setVisible(true) on the JFrame should be making it appear. However, I noticed that you're removing a Container, the JScrollPane, from the JFrame after setting it to invisible. Why not just remove it, then call the validate method? [url]http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Container.html#validate([/url]) edit: I'm going to run your code and see if I … | |
I was doing a bit of reading, and according to what I read, GUIs can be set up and realized in any thread, but doing more GUI work in a normal thread (non-EDT) after a call to setVisible can be dangerous. The explanation given is as follows: [QUOTE]The example constructs … | |
Re: what are you having trouble with? I'd like to help, but what you're trying to do is foreign to me. I'd like to assume it is the same as any other Java code, but that may or may not be the case. | |
Re: I don't know how to play Backgammon but I imagine since GNU's Backgammon game is open source (right?) I suppose you could use file input/output to play each other. | |
Re: This can be accomplished the same way you would "connect" two classes that are not GUI classes. You have to make sure your GUI class implements ActionListener though. ActionListener has one method, actionPerformed(ActionEvent e), so implement that method and put the code to get the search term from the text … | |
Re: Read this. I have a feeling it will help you, since it says it is a tutorial on loading and displaying images in Java. :) [url]http://java.sun.com/docs/books/tutorial/2d/images/[/url] | |
Re: Are you using netbeans or another IDE? And if so, what? In netbeans you can accomplish this by right clicking the Form (on the listing, underneath where it says the project name->package name->form) then clicking save as template, I believe. | |
Re: An example. . . (You can google Java WAV and a lot more will come up if this one doesn't work for you) [url]http://www.anyexample.com/programming/java/java_play_wav_sound_file.xml[/url] This is probably a difficult read but it seems to have a lot of relevant and useful information. [url]http://java.sun.com/docs/books/tutorial/sound/sampled-overview.html[/url] | |
Re: You can't use a return statement unless you are in a method, so I'm assuming that is the case here. And to figure out the index, 1. Keep a counter and increment it each time you don't find the element you're looking for. Then return the counter I can't think … | |
Re: We do not write code for people. We help people learn to write their own code. | |
Re: You basically want to set it up so that everything gets repainted, not just your rectangles. So put your drawRectangle statements in the method where all the other graphics are drawn (paint I believe), and use an "if" statement and a boolean to determine if you actually want to draw … | |
Re: This is off topic. . But that appears to be a UML class diagram. . but for some reason it seems like the composition diamond on the Course_Student should be on the other side of the arrow? | |
Re: What are you having trouble with. . having the numbers in forwards/normal order, or with multiplying the numbers, or both? The Math.pow method is useful, but I'm not sure how large your numbers are. You should check out the BigInteger class. It has multiplication and exponents for large numbers. [url]http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html[/url] | |
Re: [QUOTE]The program asks the user to enter a number one time, and then asks to enter the amount of the item five times, totals each item, and then show the overall total.[/QUOTE] What is the purpose of the first number the system asks the user to enter? Is it to … | |
Re: You're using netbeans? It doesn't matter what you're using though, Java works the same regardless. If you're in one class, and you make an instance of that class, a different class will not know it exists. In order for this to happen, you would have to have something like the … | |
Re: I thought what Stephen said was pretty clear. We aren't going to write your code for you. If you don't know how to write an actionPerformed method, then check out [URL="http://java.sun.com/docs/books/tutorial/uiswing/events/actionlistener.html"]this link on how to write action listeners[/URL] | |
Re: Yes, it makes sense. This code is available on the web, it doesn't make 100% sense to me right now (haven't looked that hard really), but it does what you're looking for. It seems to just use the drawLine method to continuously draw lines where the mouse is positioned and … | |
Re: [B]Comments on circledriver class:[/B] You don't need two Scanner Objects. You can use the same Scanner Object for reading in different types of data. Also, the standard is to capitalize the class name as far as I know, so it should be called CircleDriver. [B]Comments on DB class[/B] [CODE=Java]if (select.equalsIgnoreCase("circle") … | |
Re: [url]http://www.google.com/search?q=creating+executable+jar+file&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a[/url] What do you want us to do? If you really can't accomplish this task using the command line, use an IDE like Eclipse that will do it for you. | |
Re: [QUOTE=Ezzaral;834481]Ah, sorry, I only glanced over the assignment and missed that requirement. You could change your if() criteria to check that the box is big enough to hold the item. If it's big enough, check against the one you have already found to see if the current box is smaller … | |
Re: Increase the size of the text fields? [url]http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTextField.html[/url] Notice the method "setColumns" that takes an int or Integer argument. | |
Re: You might find Eclipse's debugger useful and easy to learn. Although I've personally (In Java) been able to find errors quite quickly with simple print statements. | |
Re: I believe the String class has a toCharArray method that would help you. Then every 3 indexes are what you are looking for. Otherwise, use a for loop to add every substring of 3 chars to an array. | |
Re: Didn't we explain to you in the last thread how to use code tags? Under 'Go Advanced' there is a button that says code tags. Use it. Also add [CODE[B]=Java[/B]] to the first part. | |
Re: You should consider the fact that the pathname of the file matters, not only the file name. | |
Re: Follow Ezzaral's suggestions, unless you're only trying to get input from the user, in which case you can read in Integers, Strings, etc with Scanner. (Google java scanner) | |
Re: Post your code? I've used port numbers before, I can't speak for the similarity of my assignment to yours, but I believe I used values that darkagn suggested with no problems. I pretty much just used the Java Sun tutorials on Sockets when I used ports. But post it and … | |
Re: I would help if your explanation was coherent. Repost it but this time, make sure it makes sense. | |
Re: Or if you want to generate any old runtime error, I've learned plenty of ways to do that in my time programming. :) One of the most common is indexing an array by an index too low or too high | |
Re: FYI, to add to what Ezzaral said, the clone method makes a shallow copy, not a deep copy. So it will just be a reference to the same object, not a new copy of the object. If you want to make a new copy of an Object, which is NOT … | |
Re: The loop to populate should be a for loop, to add to what the person above me said. edit: I will check back on this tomorrow if I remember, I'm too tired right now. Sorry! | |
Re: I think this can be accomplished using int n = 0; printf("%d", n); But hey, that might be because it's the only C code I remember. | |
Re: [QUOTE=s_sridhar;832379]Writing programs for chess [complex calculations] can be done practicallly only by supercomputers[/QUOTE] Sounds false to me. Who told you that? ;) | |
Re: You forced them to input a row between 1 and 3 and a column between 1 and 3. Your array has 3 rows and 3 columns. Arrays in Java (and most other languages) are indexed from 0 to (rows-1). Which means that your array's first cell is _board[0][0], and _board[3][3] … | |
Re: When you use the code tags in the Java forum, where it says [CODE], put [CODE=java] and it will give it Java highlighting and it will number the lines. This makes it easier for everyone to find and discuss things. Also, I looked through your code, and I noticed one … | |
Re: Lets assume you have two classes, Panel1 and Panel2. You could have a method called updateFromComboBox in Panel1's class. Then, when the combo box in Panel2 is selected, you can use the updateFromComboBox method to update Panel1 based on whatever was selected in Panel2. Note that this would require that … | |
Re: You just count the number of times each one appears in the String. A simple web search would tell you that. | |
Re: So you have times stored in milliseconds in a JTable? Then use the getValueAt(row, column) method of JTable to get the values from the cells that are next to each other. If you look at the JTable documentation for the getValueAt method, you'll notice that the return type is Object. … | |
Re: This description is incomplete. | |
Re: You can use a for loop to put things into each array index. | |
Re: I don't think you can "make netbeans do it". I think you have to take Ezzaral's advice and learn how to do it by coding it yourself in the source code under the source button for netbeans. Which basically amounts to a loop that goes through the table indexes and … | |
Re: What equation exactly are you using? distance = (velocity initial) * time + one half (acceleration)(time squared) is the equation I remember. Your site is not accessible, probably because I don't go to your school. And where in your program are you getting the wrong results? You should be able … | |
Re: You posted much too much code. If your GUI isn't launching it is probably because you didn't call setVisible(true) on the JFrame, but who knows since I didn't manage to find your main method after scrolling through. | |
Re: Nobody is going to baby you through your projects. Start by asking some specific questions. If you don't know any Java programming I suggest you read a tutorial or three. | |
Re: You're doing a project for your major and you expect someone on here to give you the code? Lol.. rearry? | |
In netbeans I added a scroll pane + bar inside one of my JPanels. When I drag enough items into the JPanel, the size of the JPanel increases in netbeans. How do I get it so that it stays at a fixed size, so I can use the scroll bar? |
The End.