7,116 Posted Topics
Re: The big problem here is that you have a null LayoutMamager. This is a very bad idea because when you run your program on a different computer (different screen resolution, different systen fonts) your controls will all be the wrong size. It's also a bad idea because your JFrame has … | |
Re: Not that I know of, but it's easy enough to loop backwards thru the string until you find an operator then take the substring from that place to the end. A minus sign is interesting - is it an operator or part of the number, as in "2*-3" ? | |
Re: Simply return the value of n with a `return n;` statement at the end of the method. | |
Re: The instructions are very clear and detailed. Just start with the first one "Create a class called Date", then carry on, doing one step at a time. When you get stuck, come back here, post what you have done so far, and explain exactly what's confusing you about the next … | |
Re: main is a static method - it runs without any instance of NumberCheck. But in3050 is an instance method, so it needs an instance of NumberCheck to run. You can either make in3050 static (quick fix, but heading in the wrong direction for understanding object oriented proramming) or in main, … | |
Re: You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrepestectful to the many people who give their time to help others here. There are lots of people here who will freely give their time to help you become the best Java … | |
I have a bizarre thing just happened in NetBeans - the red error markers on the LHS of the editor window have all vanished. There are still errors - the files are flagged as having errors, and the errors are correctly diagnosed when I do a clean/rebuild, but no error … | |
Re: Try writing down the logic in simple english before trying to do it in Java. Imagine you are explaining to someone else how the allocation should be done if it was a manual/paper system. This will help you get the logic clear in your own head, after which the Java … | |
Re: > how can we get the list of all the classes that are currently loaded > ... > no I want to get a hold of the instance of the class So is it version 1 or version 2? And if it's 2, how would you define "the instance of … | |
Re: In english the logic is: while (input is not equal to "right" AND input is not equal to "left") tell user to enter right or left | |
Re: hyp is a String but you are trying to set its value to a char | |
Re: depends on how you are doing it - do you override paintComponent or is it a JLabel with an ImageIcon? If it's paintComponent then just draw the image at (panel width - image with)/2, (panel height - image height)/2. Your paintComponent will be called after any resize and will always … | |
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: I tried a quick Google on android.preference.Preference and "deprecated", and immediately found pages that explain the replacement for your deprecated methods. It seems, for some reason, that the API doc in this case fails to explain how to replace them, but there are plenty of other sites that do. I … | |
Re: When in doubt read the Java Language Spec... > 4.12.5 Initial Values of Variables > ... > A local variable (§14.4, §14.14) must be explicitly given a value before it is > used, by either initialization (§14.4) or assignment (§15.26), in a way that can be > verified using the … | |
Re: This is the Java forum, but that's not Java code. Please check what language you are using, and re-post in the appropriate forum. | |
Re: Just a quick answer beause I'm going to bed now.... but situations like this are often solved by having an abstract Chunk superclass, with all the getters/setters defined, and two concrete subclasses InMemoryChunk and OnDiskChunk. The in memory version just works as expected, but the on disk version's methods trigger … | |
Re: OK, let's have a quick try... varun: 1. Where exactly is the jar on your failing XP machine? Please post an image showing the jar in its directory, and the complete directory path, so we can see exactly where it is. 2. Post an image showing your complete classpath system … | |
Re: First, let's assume you know some basic graphics stuff - how to create and display a window (if not you need to study a tutorial on that first). Then look through [this tutorial](http://docs.oracle.com/javase/tutorial/uiswing/painting/index.html) on custom painting in Swing for the basic info you will need. Using that you can draw … | |
Re: If someone knows how to help you they will. Unless, of course, you put them off with your bad manners. Your best hope is to post more useful details - like how can a jar remain blank? In any case, I suggest you stop bumping. Ps wasn't me who deleted … | |
Re: What's the complete sequence of events? Do you open a command window first, then run `java - jar ...` and want the command window to close when the app finishes? ... in which case maybe a small batch file that runs your app then has an `exit` command? | |
Re: For displaying you can also use the printf method instead of print or println. That allows you to format data while you are printing it. | |
Re: Debug this by starting at the line where you get the NPE and print the variables there to see which is null, then work back to see how that happened. From the incomplete info you gave it looks like you have called allFiles() on somethingthat's not a directory, but your … | |
Re: Did you find this? http://www.capricasoftware.co.uk/projects/vlcj/tutorial1.html | |
Re: It depends on yout layout manager. You may need to call SetPreferredSize, setMinimumSize, setMaximumSize and/or setSize before calling pack. But is does work. | |
Re: No need to code that youself. The *Shape* class has a *Polygon* subclass that allows you to create a Shape from an arbitrary list of x,y coordinates. The Shape class has methods for `contains(Point2D p)` etc, and the *Graphics2D* class knows how to paint/fill Shape objects. | |
Re: 1 depends on how often that will happen, but probably no. 2 how does yopur app terminate? - do you have a method? What event triggers termination? do you call System.exit? Do you have more than one thread? 3 you may be able to get away with that, but it's … | |
Re: murali: Here at DaniWeb we try to help people learn Java and develop their Java skills. We do NOT do people's homework for them. Your post explains and teaches nothing, it just gives the OP a chance to cheat. In future please help by pointing people in the right direction … | |
Re: Your jdk bin folder is a system folder that normally needs an administrator to save new files there. It's a bad place to store your own files, because next time you update your jdk you loose those files. Make a folder for your java programs inside your Documents folder, and … | |
Re: ^ Ditto: 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 You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly … | |
Re: == tests for two expressions representing exactly the same object. Which yours are not! To test if two string objects contain the same sequence of characters, use string1.equals(string2) | |
Re: 1 Create a crosshair cursor 2 Set that cursor as the cursor for the component (JPanel?) that is your game's main content area 3 Use a MouseMotionListener to track the mouse movements in that component 4 Keep updating your game view to match the latest mouse position | |
Re: It's not clear where you are hitting the problem. Do you have the .jar file that NetBeans creates (in the build directory of your NetBeans project). | |
Re: Did you read this thread? It also covers an NPE from listFiles() http://www.daniweb.com/software-development/java/threads/459486/recursive-operation-for-listing-all-files | |
Re: Why not keep it *really* simple and use Oracle'sfully-supported standard JavaDB (a version of Apache Derby) that *you already have* as part of any recent JDK installation? http://www.oracle.com/technetwork/java/javadb/overview/index.html | |
Re: Hi Amrita. I don't know why jwenting wrote what he did - but whatever he wrote is his personal opinion and doesn't necessarily represent DaniWeb official policy. Of course it's OK for you to post your questions here. If that was a question you were asked for "homework", then our … | |
Re: It works just fine in Java 7, but there are a number of calls that are needed. Something like this code from an old project's splash screen (maybe some redundancy - it start life under the temporary transparency support in Java 6.21)... frame.setUndecorated(true); // gets rid of borders title bar … | |
Re: http://www.daniweb.com/software-development/java/threads/430542/java-projects-for-learners | |
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: Your factorial method doesn't initialise the variable "factorial", so each time you call it factorial will keep getting bigger and bigger. That variable should be a local var in the method, initialised at the start of the method. | |
Re: It is not possible for two invocations of synchronized methods on the same object to interleave. When one thread is executing a synchronized method for an object, all other threads that invoke synchronized methods for the same object block (suspend execution) until the first thread is done with the object. … | |
Re: Hello EkDs Basically you are making this near impossible for us to help you. You say "the compiler shows error" but you don't say what error message or which line it refers to. You post a whole load of code which is onbviously incomplete and cannot possibly be compiled, and … | |
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: You can call requestFocus or requestFocusInWindow for the JComponent where you want the focus. See also http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html | |
Re: Those two "Read" classes sound like they should just be methods. Read... could return a Transaction object, and getResults could take a Transaction as a parameter. | |
Re: You init it, and it appears at the start of the output. It won't appear on every line unless you append that string again at the start of every line | |
Re: The delimiter you specify for a Scanner is not just a String, it's a Regex pattern, but $ is a special character in a regex, so maybe your delimiter is being parsed in a way you didn't expect. Have a look at the API doc for Pattern for more details | |
Re: One way is to write the generated data to a *PipedOutputStream* that's connected to a *PipedInputStream* in the other class. This is a very good solution, provided you are happy to mauintain two threads (one writing, one reading). A simpler approach is to write the data to a *ByteArrayOutputStream*, which … | |
Re: Deve - what exactly is your problem here? You have some code to do a calc and display it when a button is pressed - what exactly happens when you try to run it? | |
Re: Are you running the jar with javaw.exe? That doesn't have anywhere to display exceptions. If so, try java.exe which will display any uncaught exceptions or sysout/syserr messages in the window where you started it. |
The End.