7,116 Posted Topics
Re: Because x is an array you need to supply an index to tell Java which element of the array you are talking about, eg x[b].getName() | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules | |
Re: > its giving some weird error Java error mesages may look weird but they usually tell exactly what the problem is and exactly where it's happening. Please post the complete exact text of your errors and someone will help. | |
Re: To make it more like a c header file full of `define`s, you can declare `pubic static final` members, as bguild explained, then at then start of any .java file you can `import static mypackage.MyClass.*;` Now you can simply use the public static member names in that file without needing … | |
Re: Generate two random numbers 1-6, add them together, test the result for ==7 or whatever else you need. | |
Re: That is part of a loop that will reverse the digits in a number. It makes no sense without the loop. To see how it works, pick a number and go through that code by hand working out the results for each line. | |
Re: The view knows nothing about SQL, and so has no idea what to do with an SQL exception. On the other hand, the model knows nothing about how to talkto the user. So normally you would do something like: 1. In the model, catch the exception and write as much … | |
Re: This is the Java forum, but that's not Java. Try one of the web development or database forums. | |
Re: You need a .class file or .jar file to run javaw, a .txt won't run. But in prinicple there's no problem running javaw from within Java. ps Runtime.exec was superceeded by the ProcessBuilder class from Java 1.5 You'll find loads of examples on the web. | |
Re: You can usually hold money as an integer number of cents - very few applications ever neen to handle a fraction of cent. `int` will usually do, or `long` if you need amounts over 20 million dollars. If you write a simple method to take a value in cents and … | |
Re: Your request is very general, and sounds like it will need more time that anyone here has got. Strt by reading the [starting Java thread](http://www.daniweb.com/software-development/java/threads/99132/starting-java-java-tutorials-resources-faq), the have alook through the [Java projects for learners thread](http://www.daniweb.com/software-development/java/threads/430542/java-projects-for-learners). Pick a project that interests you and try to design/code/test a solution. If/when you get … | |
Re: Does that pattern repeat, eg score 35-40 change -=.8, score 40-45 change +=.8 etc ? | |
Re: That code is very difficult to understand, especially because you have ignored Java naming conventions and made your classes look like variables. And essential parts are missing. From what you have posted: There's a main method that isn't valid Java, but appears to try to define a run() method that … | |
Re: Rajesh's post is about as wrong as it's possible to be. ActionListeners are called on the Swing Event Dispatch Thread. Most Swing methods are not thread safe and MUST be called from the EDT and no other thread. http://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html Rajesh would have you leave the EDT in order to update … | |
Re: lailadah got "unable to access jarfile start.jar" when trying to instal Apache Solr server, but after many more tries got "invalid or corrupt jarfile C:[complete path to the file]". He's been unable to find any relevent answers on the web [or maybe lack of English skills prevented him from seeing … | |
Re: Why don't you just try that and see for yourself? (It's nearly right, and when you try it you will see what's wrong and how to fix it) | |
Re: First step is simply to do exactly what it told you to do: `Recompile with -Xlint:unchecked for details.` That will tell you what the unsafe or uchecked problem is, and exactly where it is. Then you can either update the code or add an annotation to allow the operation. | |
Re: Why don't you ask the person who wrote that code? (See also [OP's original incomplete thread ](http://www.daniweb.com/software-development/java/threads/444967/road-simulator) ) | |
Re: Hello neondroid You have not explained exactly what help you need. Nobody is going to read all that incorrectly-formatted code, then try to guess what your questions are! so please 1. Explain exactly in detail what you need to know. If you have an error then explain exactly what the … | |
Just a quick heads-up, especially for anyone using Java in their web browser. There's a "widely exploited" vulnerability in Java that could allow bypassing normal security when a Java applet is run silently upon visiting a web site. (ie It's a bad one). Users are being widely advised to disable … | |
Re: Yes, lots of ideas, but your requirement is still far to vague for anyone to give a proper reply. What kind of simulation do you need for the cars? In how much detail (see previous posts)? (In 1971/2 I worked on an IBM project to simulate the traffic flow in … | |
Re: Part1: see bguild's answer. Part2: If you start by finding palindromes then you are left with the problem of finding out if each palindrome is the product of of two numbers 100-999 (not so easy). If you start by multiplying every possible combination of two numbers 100-999. that's only 500,000 … | |
Re: if(names.equals(n)) names is an Enumeration n is args[0] which is a String. An Enumeration and a String can never be equal. ps: Hashtable is designed for this kind of thing, so it has other methods that you will find very useful... spend 10 minutes reviewing all its methods before choosing … | |
Re: Many places where Java displays text support a limited subset of HTML tags (eg JLabel). You could try some simple HTML and see if that works, eg "<HTML><H1>Hello</H1><BR>Everyone" | |
Re: The person who wrote this problem description obviously doesn't understand object oriented design, so that makes it harder for you. Judging from the variables, the class they call Library clearly does not represent a library, it represents one LibraryHolding - which is an abstract class (instance variables ID, Date of … | |
Re: Member rules link is at bottom right corner of (every?) screen. I think the one you are looking for is "Do provide evidence of having done some work yourself if posting questions from school or work assignments" J | |
Re: @raj09cs42 Taywin is being too nice to you! Posts that start "I need the code so I don't have to do my own homework..." usually get a much stronger response. There are lots of people here who will freely give their time to help you become the best Java programmer … | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Post what you have done so far and someone will help you from there. | |
Re: This is a typical problem with Scanner. Most of the methods use the delimiter (default white space) to separate tokens, and keep the following delimiter. Except for readLine that discards the following new line character(s). So, for example if you use a nextInt followed by a nextLine with a file … | |
Re: Have you read the Oracle tutorial on JTables? http://docs.oracle.com/javase/tutorial/uiswing/components/table.html | |
Re: How about ProcessBuilder to execute the necessary commands directly from your Java program? | |
Re: If the command line interface has all the needed functionality, then you can use the Java *ProcessBuilder* class to drive octave's command line interface "behind the scenes" and retrieve all its output for display in your GUI. You'll find tutorials and samples on the web. ps: don't be distracted by … | |
Re: It sounds like you don't have much programming experience? If that's the case then to make a real-life application like this from scratch is far too difficult a project for a beginner. Why not look at one of the free inveytpory applications that you can simply download and start using? … | |
Re: Remember that columns may be re-ordered relative to the underlying data model. Similarly rows can be sorted and/or filtered before display, in which case to get a row number that refers to the actual row in the data model you need the *convertRowIndexToModel* method. Those extra levels of indirection and … | |
Hello all. I'm currrently working on a GUI that needs to support dragging some application-specific objects from a selection area onto a work area (JPanel). It's currently working in a "click where to place the object, then click the Add button" mode, but that's not good enough. The obvious approach … | |
Re: There are solutions using PipedOutputStream/PipedInputStream. Basically you re-direct System.out and System.err to a piped stream, then in a separate thread read from the pipe and put the text into your JTextArea. Google will find you a few examples; most have extra stuff you may not need (eg handing System.in as … | |
Re: Your question is far too vague. setVisible(true) is the way to make an invisible component visible, but what has that got to do with singletons? If you ask a much more specific question, with enough background for us to understand what yur problem really is, then I'm sure someone will … | |
Re: Learn most of the language itself? months Learn a good subset of the Java SE API? a couple of years Learn to design & implement really good code? many years | |
Re: > You can use Bitwise unary NOT operator Check the Java Language Spec... there no such thing as a "Bitwise unary NOT operator". There is bitwise complement operator, just like the previous poster already said. ps You can also exclusive OR with a value of all 1 bits. | |
Re: There is an overlap in function between constructors and setters, and no rigid rules about which to use. But some typical guidlines include: * If a variable must be set for an instance to be valid (eg Person must have a name and social security number) then set them in … | |
Re: Serialization is a good answer. Open an ObjectOutputStream to a file with any name and extension you want. Java IO won't care about the extension. | |
Re: I think we are being too hard on OP here. He clearly has put a lot of thought into this problem, ans is now asking for more ideas. I would be more worried about whether this is intended to circumvent someone's attempt at DRM, and therefore violates DaniWeb rules. | |
Re: Line 54 you include the current cell in your counts, and also the cells diagonally above/left of the current cell. You don't seem to test the cells right/below the current one ps `if (someBoolean == true)` is a redundant way to say `if (someBoolean)` | |
Re: ^ excellent advice from Tux. Plus: sort out your indentation - it's very hard to see where blocks begin and end and, even worse, its too easy to think that the indentation accurately reflects the block structure of the code when in reality it doesn't. Finally, use lots of temporary … | |
Re: Is [this](http://stackoverflow.com/questions/4573812/how-to-convert-apk-files-to-java/5027405#5027405) any use to you? | |
Re: You're mixing nextInt and nextLine, which is a bad combination. nextInt takes the integer value but leaves the end-of-line delimiter (\n). Then nextLine takes everything up to the end of line, is a string of zero length. You need to take or skip the end of line after a nextInt … | |
Re: `Player player;` creates a reference variable that can refer to a Player object, and is initially null. `new Player(p1, p2); ` creates a Player object the two things are independent of each other. `player = new Player(p1, p2);` creates a Player object and sets player to refer to it, then... … | |
Re: Re implementing bguild's excellent suggestion: Simply create a little class Line, with vars for oldX, oldY etc. Give it a constructor that takes all the values it needs. Declare it as "implements Serializable" so it can be sent over an object stream. "history" can then be an ArrayList of LineData, … | |
Re: The NullPointerException nessage tells you the exact line where it happened. It's a lot easier if you share that with us! You can also help by printing the values of all the variables and method calls used on that exact line so we all know which one was null. | |
Re: Use the SimpleDateFormat class to convert your Date object into a String that's formatted exactly how you want to see it, and use that String in the text field. |
The End.