7,116 Posted Topics
Re: Is the problem calculating what the line should be, or is it just drawing it? How are you drawing your solar system so far? | |
Re: That sounds like a perfectly reasonable and interesting Java project, assuming you can get access to the live info through some kind of internet service. Downloading/copying databases is unlikely to give you the kind of real-time data you want. Finding that access must be step one, because if you can't … | |
Re: Beware of confusing your terminology here... methods can not be "unchecked", only Exceptions can be. If you drill further into the JavaDoc you will see that all three exceptions that nextInt may throw extend RuntimeException and are therefore unchecked. The definition of nextInt() in the API source code does not … | |
Re: Probably refers to the different ways that numbers are typed, thousands separator, decimal point etc eg US 12,34.56 in France would be 12.345,56, and I think some countries leave a blank as the thousands separator | |
Re: I guess you could create a *TableColumnModelListener* to monitor changes in your *JTable*'s *TableColumnModel* and get the updated widths of each *TableColumn* and use those to update the bottom table? A bit tortuous, but probably not very much code when you finally work it all out. | |
Re: Have you checked the file contents - eg is it an HTTP header or some such? | |
Re: Hello Anil I assume that you are the Anil who wrote the code that link refers to? Please remember that this is not a forum for self-promotion. The DaniWeb rules that you agreed to include "Do ensure that all posts contain relevant content and substance and are not simply vehicles … | |
Re: There's too much missing code there to be able to diagnose this (just one eg is there a second declaration of jComboBox1 somewhere?). Have you tried the obvious debugging steps, eg print theTeams at various points in the code to check that it has the data you expect? | |
Re: Learning the language itself from c++ ... you'll have 95% of it with a few days Learning the API - a lifetime ![]() | |
Re: Since you don't actually do anything with those classes it doesn't matter what attributes they have, so maybe this example is a bit *too* simple? Do you still have your code for two or more console-based games (tictactoe, hangman, scissors/paper/rock or whatever)?. If so it may be interesting to package … | |
Re: Is that when one of your windows has the focus, or is it the same as the original question? | |
Re: I admit that I don't understand this question fully, but since nobody else has any answer at all, here's my best shot. The diagram you linked to looks like a UML class diagram, in which case that will map to Java (very briefly) as follows: Each box is a class … | |
Re: The row count tells you the number of rows in yout table's model, just like length() tells you the number of chars in a String. It makes no sense to set it, because then it would be wrong. Just make your model the right size. | |
Re: *Typically* you would have main create the model then create the GUI, passing a ref to the model into the GUI constructor, so the GUI can use the model's accessor methods. Model m - new Model(...) // model knows nothing about the GUI GUI g = new GUI(m, ...) // … | |
Re: I think this is probably a JavaScript thing, not Java. Try posting it in the Web Development section | |
Re: I see no code to paint bullets! In your paintComponent, around line 79, you need to loop through your arraylist of bullets, painting each bullet at its current x,y position. | |
Re: It's not clear whether this is a genuine recommendation or just commercial spam. I'm following it up with the OP, but in the meantime I suggest you all treat this with great care and suspicion. | |
Re: > you'll have instantiate a new enum. ? You can't instantiate enums. They are created some time before they are first needed and that's it. | |
Re: ... between 0 to 99 > public int nextInt(int n) > > Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), | |
Re: Use unbuffered output streams when you want each write to be processed immediately - eg Writing a log file - you don't want the last few messages to be lost when the program crashes and the buffer is lost. Another eg - writing to a network stream to send chat … | |
Re: Line 18 `if (rs.next...` will only execute the following code zero or one times. Didn't you mean `while (rs.next...` ? ps line 43 is a disaster. You get the message string and completely ignore it, so you will never see any error messages. Replace that line with `e.printStackTrace();` to see … | |
Re: Swing was not part of the first version of Java - which only had java.awt So originally swing was a java extension. | |
Re: JRE is everything you need to run Java programs, primarily (1) a JVM and (2) all the class files for the Java API and (3) other bits and pieces that are needed for some of the API classes (DLLs etc) | |
Re: Hi tyranx, welcome to DaniWeb. Did you notice the date of this thread? It was marked as "solved" five months ago, so your answer is a little late! Your contributions are very welcome - have a look at some of the more recent topics tha thave not yet been marked … | |
Re: The normal sort is an ascending sort, the lesser objects sort before the greater, so is o2 is greater than o1 it will sort after it. Just think of numbers - you expect them to sort 1,2,3,4,5... smaller/lesser first, greater/larger after | |
Re: You have an input that is not a multiple of 8 bytes, but you specify a encryption with no padding. If you don't allow the algorithm to pad your string then it's up to you to make sure its a multiple of 8 bytes. See http://stackoverflow.com/questions/4183853/encryption-message-in-java | |
Re: Hello lena1990 Well done! Please share your solution with us all - how did you solve it? | |
Re: Each tab should be created as an instance of a class, so each instance will have its own instance variable values for its own fields. Wherever you have the code to control the creation of new tabs, keep an ArrayList of those instances so you can reference them, and thus … | |
Re: TitledBorder is because you don't import it. It's javax.swing.border.TitledBorder, so importing javax.swing.* won't import it. As for java.awt.GridBagConstraints, I don't know why that is giving a problem when you import java.awt.* | |
Re: > I would like to know if there is a way to put the code for each of the four operators into their own method, and just have the main method print the questions and ask for the answers? Yes, it's just like you said! Put the code for each … | |
Re: One case where you won't have a setter is where the field is immutable by design. Often this will be some kind of ID or serial number field which cannot change becuase it's used as the unique persistent identifier fr this object (the primary key in the underlying data storage). | |
Re: > this makes the program runs so slow that makes it out of the question Is this an assumption, or did you try it? You can sort a lot of objects in milliseconds on a 21st century PC. Anyway, without seeing more of your code it's hard to understand why … | |
Re: Create a new JOptionPane, let it create a JDialog that contains it, position the JDialog, make it visible... eg something like JOptionPane pane = new JOptionPane("Click one:", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION); JDialog d = pane.createDialog(null); // see mKorbel's post for better ways to do this d.setLocation(400,400); // see mKorbel's post for better … | |
Re: Yes, it's completely possible. All you need is to run your server program on a computer that your client can connect to. For example that could be your own computer if you configure your router/firewalls to make it accessible from the web, or you could use a commercial hosting service. | |
Re: Along with your x and y coordinaltes you could have a boolean for mouth up. In your key event handler set the boolean correctly when the user presses up or down. In your paint method use that boolean in an if test to draw the arc up or down | |
Re: Hello kssk Please note the [DaniWeb rules](http://www.daniweb.com/community/rules), including "Do not hijack old forum threads by posting a new question as a reply to an old one" Please start a new topic for your question, and also remember "Do provide evidence of having done some work yourself if posting questions from … | |
Re: Can you avoid that problem by using only weak references? | |
Re: "identify all the end points that are that distance away" Does that imply that there is a finite list of known end points? If not, just get a random deltaX in the range (0 - drivingDistance), set deltaY to (drivingDistance - deltaX), so the sum of the x and y … | |
Re: The Random class has a nextGaussian() method, so that's obviously going to be part of yur solution... http://docs.oracle.com/javase/7/docs/api/java/util/Random.html#nextGaussian%28%29 | |
Re: You could write a simple Java program to read a text file, delete any leading integers and write it back out. 15 minutes tops. | |
Re: Check the API documentation for JTextField, you know, the one that starts "JTextField is a lightweight component that allows the editing of a single line of text." Try JTextArea, "A JTextArea is a multi-line area that displays plain text" | |
Re: Hi hlut, welcome to DaniWeb. Thanks for your feedback. It's good to know that people are finding our service useful. (ps: Don't worry about stultuske's post - I think he misunderstood yours.) | |
Re: First thing to remember is that Java doesn't really have a "2D array". All arrays have a single dimension BUT any element may itself be an array (etc recursively). So what you have is an array of arrays. It sounds like you want to sort the "outer" array using the … | |
Re: That's possibly the worst first post I have ever seen! 1. You give exactly zero idea of what kind of game - tic-tac-toe on the console, WoW-type massive online role play, chess with AI that can beat a grand master, a completely new game...? 2. What makes you think this … | |
Re: One thing looks odd... "globalStack" is an instance variable, not static, so there is one "global" stack for each Thread. At the very least that's a *terrible* name | |
Re: \ is an escape character, eg \n = newline. For a single \ you need to code two \ | |
Re: You could make this easier for us by explaining what it's supposed to achieve, or at least posting some sample output, but at a guess, how about String stars = "***********************************************"; int n = 5; for (int i = 1; i <= n; i++) { System.out.println(stars.substring(0, Math.min(i, n - i … | |
Re: There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in doing your homework for you. DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence … | |
Re: Comments: I looked quickly at that code and decided I didn't have time to try to understand it. It's just too complex & nested. IMHO that's a result of not breaking the app up into enough classes. Read the rules of the game - the most common noun is "ship". … |
The End.