7,116 Posted Topics
Re: Without creating new array the best you can do is to compress out the zeros, then fill the unused elements at the end of the array with zeros. Ie 9 7 23 4 0 0 0 0 There is no way to change the size of a Java array after … | |
Re: [QUOTE]another way to specify the current L&F is to use the swing.properties file to set the swing.defaultlaf property. This file, which you may need to create, is located in the lib directory of Sun's Java release (other vendors of Java may use a different location). For example, if you're using … | |
Re: mKorbel - I presume your comment to stultuske is based on the fact that JTextArea handles \n chars properly? It's not helpful or polite just to say someone is wrong - please always explain why they are wrong, and at least point them in the direction of a right answer. | |
Re: You don't give a lot of context for this question, but it looks like you should be using a switch based on the selected index, and in that calling separate methods for each of the possible cases. | |
Re: Drawing shapes in Java has to be done in a very specific way - here's a tutorial that will show you exactly what to do: http://docs.oracle.com/javase/tutorial/uiswing/painting/ You can handle the coordinates in exactly the same way you did the radius. | |
Re: The exception message identifies the exact line where the NPE happened, but we don't have the original file to interpret the line number. What is the code on line 978? | |
Re: There is somewhere on Oracles site a table that shows which components generate which events, but I can't remember where exactly. Otherwise, look at the addXXXListener methods for your component (don't forget to look for inherited methods as well) | |
Re: double tuitiontotal = tuition; Why this initial value? Don't you add all the desired values into tuitiontotal in the following loops? | |
Re: Without seeing your code it's impossible to say what's wrong with it! | |
Re: It's not the enums, they're just like any other object for this purpose. Java has primitives and references. Primitives are int, boolean, char, float etc - all have lower case names. References are used to refer to objects and arrays. When you call a method Java passes a copy of … | |
Re: The key to creating frames in specified formats is to chose the right layout manager. This tutorial is a good start. http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html | |
Re: It's in this thread if you look for it. But you would be far better advised to write your own rather than copy something that can be traced on the internet | |
Re: Hi Please don't hijack other people's threads. Start you own new thread and someone will help | |
Re: Hi Kenton. Welcome to Daniweb. Start a new thread for your question and someone will help. | |
Re: Yes, as soon as it hits the return statemnent it returns, so you only ever get the first Card. Your requirenent seems bizarre - you want to return multiple Cards, but not use an array or Collection? Given that, all I can think of is to return an Iterator or … | |
Re: You try to add two mm.ss as if they were ordinary decimal numbers. Eg 1.40 + 1.40 is 3.20, but added as decimals you get 2.80 which is wrong. Easiest solution is probably to covert the inputs to number of seconds, add those, then convert back to mins & secs | |
Re: > Its strictly for beginners, and can be improved. You are being too modest. I would be perfectly happy to have written that myself. Well done. | |
Re: would like your help on writing this program. There are meny people here who will help you, nobody who will do it for you. Show what you have done so far. | |
Re: The `classpath` should contain a list of all the locations where your .class files may be found. That is completely different from the `path` environment variable that tells the systen where to look for .exe files. If it works with `cp .` then this imples that the .class file is … | |
Re: To sum a diagonal you just need one loop and one counter. You don't want nested loops | |
Re: Hi, welcome to DaniWeb. Lower case letters are 26 consecutive Unicode values starting with 'a', so the cleanest way to generate a random lower case letter is to get a random integer in the range 0-25 and add it to 'a', as in 'a' + randNumlist.nextInt(26) But, that calculation will … | |
Re: You are 99% of the way there. It's really hard as a beginner to think about the logic and the Java code at the same time! Step back from the computer and just run through that on a sheet of paper. You'll soon see why its going wrong, and how … | |
Re: > can you please make a program for me?? 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 helping you cheat or doing your homework for you. | |
Re: "giving me some errors" tells us nothing. If you have a compiler or runtime error message post the complete message plus the actual code it refers to. If your code is giving an incorrect result explain what result you get and what the correct result should be. | |
Re: A word of caution - not all console devices and/or OS's support ANSI escape sequences, so if this works for you that's great, but don't assume it's portable or will work on someone else's computer. In general your chances are much better under Linux than under Windows. | |
Re: "it is not giving correct result" tells us nothing. If you have a compiler or runtime error message post the complete message plus the actual code it refers to. If your code is giving an incorrect result explain what result you get and what the correct result should be. | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: "Do not hijack old threads by posting a new question as a reply to an old one" http://www.daniweb.com/community/rules Please start your own new thread for your question | |
Re: If you need variables to be shared between different methods, then declare them in the class but outside any one method. Variables declared at the class level can be used in any method | |
Re: Install the Java Runtime (JRE) on your linux computer https://java.com/en/download/manual.jsp | |
Re: Interesting bug... in paintComponent you call super.paint, which in turn calls the paint mathods for the various parts of the JFrame, including a call to paintComponent. That's a recursive loop. You should be calling super.paintComponent | |
Re: Calendar's `getTime()` method gives youa `Date` object representring the same date/time, which you can then format exactly as you like with a `SimpleDateFormat` - see the API docs for details You can put Calendars in an array or an ArrayList (or any other Collection) to process multiple Calendars | |
Re: Lost ticket? Car parked but never leaves? Car parked during some kind of emergeny or system failure when the entry barrier was left open? Car exiting but credit card refused/no cash/etc so unable to complete payment but is now blocked in by a line pf cars stck behind it? (I've … | |
Re: [This](http://simplescrape.sourceforge.net/) sourceforge project may help, or [this blog](http://icfun.blogspot.fr/2008/03/write-web-spider-to-scrape-data-using.html) has a simple DIY example. ps: Just because info is on a web page that does not mean that you are free to use it any way you like. Please check that your use does not violate anyone's intellectual property rights. | |
Re: Are you sure you want to use an accessor, or do you just need to know the number associated with whatever button has just been pressed? In that case you can use an event handler. Here's a recent post that shows how (it stores the number in an array, but … | |
Re: With absolutly zero info about the algorithm, and absolutly zero code to look at, I doubt that anyone can explain your results. Can you explain your algorithm, and post all the relevant code? | |
Re: Everything to do with Swing (eg painting the screen, running actionPerformed methods) happens on a single thread - the "Event Dispatch Thread", or "EDT", or "Swing thread". That means that once your mouse click method starts NOTHING else will happen in Swing, including no screen updates, until your method finishes. … | |
Re: That is a very vague question. Please exaplain exactly what you want to do. | |
![]() | 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 … |
Re: Rather than have one big buffer - which limits the file size, you can have smaller buffers (eg 4k) and write/read the file one buffer at a time for unlimited file sizes. Eg for the server... byte[] data = new byte[4096]; int count; while ((count = file.read(data)) != -1) { … | |
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: The compiler isn't smart enough to confirm that your for loop will always be executed, so the return inside it will always be executed. If the values were such that the for loop ran zero times you would drop through to line 9 and get to the end of the … | |
Re: The next 10 years? No. 10 years ago who predicted iOS or Android? But many large companies have huge investments in Java (especially Java/EE) and those systems will be around and being updated for a long time. In the long term there's a massive trend away from low-level low-productivity languages … | |
Re: Hi ZK It's hard to answer your post because we don't understand what your real problem is. Both tasks are really small and simple - maybe you are looking for some complexity or difficulty that's not actually there? Eg. look at 2 again: "Define class SomeClass, which throws an Exception … | |
Re: http://www.daniweb.com/software-development/java/threads/430542/java-projects-for-learners | |
Re: Java is a language and .net is an API (library of code). To compare like with like you should compare (Java plus its API) against (c# plus .net). Java, like C#, is a language. and the Java API, like .net, is a huge library of code for user interface, networking, … | |
Re: Based on what you have posted before, the first version (delete one element) is not yet working - it doesn't check the index and it doesn't maintain the currentIndex variable correctly. Maybe you should be certain that is fixed before moving on? Anyway, I don't want to be discouraging, but … | |
Re: In my opinion that would be hard to impossible in a Java application - it would need to interact with the system at quite a low level and be immune from the user stopping it. There may well be other ways to do it, eg via Group Policies in Windows … | |
Re: update current object - depends on whether it was one of the objects you moved in that loop you can't "compress" an array. If your array has unused space at the end you can copy it to a new smaller array and let the old array get garbage collected | |
Re: Masybe you could use a boolean array or list, same size as the secret word, that shows which letters have been found. As the user guesses a letter correctly you set the corresponding entry to true. You can then use that array to control the printing of the secret word … |
The End.