7,116 Posted Topics
Re: WARNING: To anyone copying code for a homework assignments: Your teacher can probably spot solutions copied from the web. If so you will get 0 marks, and may be penalised for cheating. YOu are also wasting your own time by cheating instead of learning. Write your own code! Szabi: I'm … | |
Re: Look at the Enum.valueOf method - it gives you the enum value from a String. Eg you pass it the String "May" and it it returns the enum value Average.May | |
Re: The exception message tells you which line it happened on. Post that info. | |
Re: Browser is easy, especially in JavaFX, maybe too easy because it doesn't leave a lot of places for you to show your skills. Media player may be better (also in Java FX) because you can add lots of value around the metadata, media library management etc. There's a lot of … | |
Re: mustafaaaltup: Your question is too vague. Please be more specific. How far have you got with this? What, exactly, is stopping you now? | |
Re: This is a good introduction: http://www.makeuseof.com/tag/java-virtual-machine-work-makeuseof-explains/ | |
Re: All that code for the random numbers (lines 16-21) looks seriously over the top and thus error-prone. (It's already broken; it returns numbers 0-11. Even after you fix that it still has a higher chance or returning a 1-4 than a 5-12. Not to mention using Math.pow(10,2) instead of 100.0) … | |
Re: Is that a hex 52 or a decimal 52? LDAP error 52 (hex) is the totally unhelpful "Local error occurred", but if that's 52 decimal (34 hex) it's the self-explanatory "The server is unavailable" http://support.microsoft.com/kb/218185 | |
Re: We are just volunteers here, so nobody will be in a position to give you extended one-on-one training. But if you have specific questions or errors we will be happy to help through these public forums, where everyone can contribute to the solution. | |
Re: That looks OK - maybe the parens are already out of step before that code? Also, I don't know what the data type for tempUnit is, but it's unusual to see a char as parameter for equals. char is an integer primitive type, for which == is appropriate. | |
Re: Looking at that table the most obvious approach is to create a simple class that represents one row, with instance variables for each column. The whole table is then just a one-dimensional array of objects of that class. That array is also then 90% of what you need for a … | |
Re: Your code is almost right - you have the right pieces but the order is a bit messed up. Read each line of the file, split each line into words (ie use `split` with the default separator of a space), then use chatAt to get the first letter of each … | |
Re: See this thread http://www.daniweb.com/software-development/java/threads/475808/how-to-play-mp3-files-in-java-using-eclipse - especially the very last post | |
Re: A JButton with an ImageIcon will automatically set its own preferred size to fit the icon. The problem comes when you use a layout manager that re-sizes the buttons to achieve the desired layout. You need to chose layout managers for your frame and panels that don't resize the buttons. … | |
Re: Exactly what errors? - post the *complete* text of all your error message, don't expect people to guess. [edit] Thank you. You should expect some answers now. | |
Re: The awt GUI classes were superceeded in 1998 by Swing. Yes, 1998 - more that 15 years ago. You are seriously wasting your time learning or using it. Update your code to use Swing (JApplet etc). | |
Re: 1. If you get an error ALWAYS post the complete error message here. Don't exp3ect people to guess. 2. You are using AWT (Frame) rather than Swing (JFrame). AWT has been obsolete for over a decade now. You should update your code to use Swing components - it's not hard. … | |
Re: new ImageIcon(...) is famous for not throwing any exceptions when it fails to find the file; it's just null. JLabel is happy to accept null for its image icon, so the final result is no image and no error messages. We see that quite often in DaniWeb "help!" posts. Use … | |
Re: What exactly is the error message the *compiler* (not the runtime) gives for that line? Is line 21 the System.out.println ? It's absolutely pointless to try to execute a program that has compile errors. *Always* fix *all* the compile errors before trying to run the program. | |
Re: Wazan: Do not hijack old forum threads by posting a new question as a reply to an old one http://www.daniweb.com/community/rules Start your own new thread if you have a question. | |
Re: Looks like it moight be out of scope, but until you fix your indentation it's too hard to see. | |
Re: Have a look at http://docs.oracle.com/javase/tutorial/getStarted/application/index.html#MAIN | |
Re: AFter entering 23 do you enter a space or a carriage return? (If you just type 23 the it will be waiting for the next character in case that will be a digit.) | |
Re: Nice OO thinking - the User class is excellent, but the other class... horrible naming! A method called `OConnexion` in a class called `OConnection` that returns a `Connection` is guaranteed to confuse people. Did you start out with a constructor, then change it when you realised you couldn't return a … | |
Re: It's so easy to re-generate the sequence given the starting number, so I wouldn't bother trying to store sequences. Just write a trivial `displaySequence(int startingNumber)` method - it's just the loop/if from lines 21-30 with a print statement in the loop. Then just call that passing highestNumber. If you are … | |
Re: Hello Susanna Thank you for sharing that with us, but is there any particular point you wanted to make, or question you wanted to ask? | |
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 paintComponent method starts NOTHING else will happen in Swing, including no mouse or keyboard events, until your method … | |
Re: I can't see how that could run without throwing Exceptions - eg line 117, deckPanel is not initialised, so that will throw a null pointer exception. How are you trying to run this? javaw or what? | |
Re: You try to define method1 but you are still inside the main method. You ca't define a method inside another method. | |
Re: Hi milil Please don't EVER do this in code that a learner may read: catch(Exception ex) { } all you are doing is guaranteeing that when it goes wrong they will have no idea why. Always start with an `ex.printStackTrace();` | |
Re: Q_SIZE is 16, which you use to get a value for action. So you get a random action in the range 0 - 15, which you use as an index into the array But the array seems to have 15 elements ie [0] to [14] | |
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 helping you cheat or doing your homework for you. DaniWeb Member Rules (which you agreed to when you signed up) … | |
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 helping you cheat or doing your homework for you. DaniWeb Member Rules (which you agreed to when you signed up) … | |
Re: This one of those "which is best, football or cricket?" kind of questions. People are going to disagree strongly, mopstly based on personal preference and bias. To get things started: my personal preference and bias is Java because you will need a lot of complex data structures and complex processing … | |
Re: Strings in Java are immutable - you cannot change them. Have a look at StringBuilder which is like a String but you can do stuff like inserting blanks into the middle of it... | |
Re: Check out the very first post in the Java forum "Starting Java [Java tutorials / resources / faq]" http://www.daniweb.com/software-development/java/threads/99132/starting-java-java-tutorials-resources-faq There are excellent book recommendations in there | |
Re: The problem is probably in the code you didn't post! Eg: If you don't set a size and/or minimum size for your mypanel then the layout manager for its parent will look at mypanel's children (none) and decide that 0x0 pixels is a big enough size for it. `final Graphics2D … | |
Re: I guess you missed the very first post at the top of the first page of the Java forum? | |
Re: This arraylist is a list of Document objects ArrayList<Document> someStuff = new ArrayList<Document>(); The application prompts the user for lastname, firstname, code and then uses those values to create new Document object, which it then adds to the list. It may be clearer if we break the statement down into … | |
Re: You coded `54. setDefaultCloseOperation(EXIT_ON_CLOSE);` and Java is doing what you told it! That option instructs Java to exit the whole program when the JFrame is closed. I realise that you are practicing with Threads here, but t4 just executes an `addActionListener`, which isn't enough for you to be able to … | |
Re: Sharing the exact complete error message always helps... | |
Re: Date was badly designed in version 1 of Java because it didn't cope with multiple time zones or calendars. For most purposes it was replaced by the abstract Calendar class. That was designed to have concrete subclasses for different calendars (eg Jewish), but you will probably want the subclass GregorianCalendar … | |
Re: You need to decide what you mean by sorting a 2D matrix. The code you have sorts each row individually - which is one passible answer, but it looks like you may want to sort all the values, regardless of rows or columns, in which case I have to ask … | |
Re: How about returning a boolean? // pseudo-code! public boolean passwordIsOK() { get the password if (the password is correct) return true; else return false; } then you can say if (passwordIsOK()) ... do whatever | |
Re: You declare the array variable `som` but you don't initialise it, so som is still null, it doesn't refer to an array yet, the array doesn't exist, it has no members, so you can't use `som[0]` | |
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. DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some … | |
Re: Java will autobox/unbox int<->Integer, double<->Double,etc, so milil's example is OK. | |
Re: I don't know what your overall intention is for how this code should execute, but 1. You have a single block of code synchronised on a single instance of Animal. That's legal but useless - for it to be of any value you need two synchronised blocks or two threads … | |
Re: Nobody here is going to be stupid enough to waste any time trying to debug a program that discards and ignores relevant Exceptions. Given the problem you have described, your commenting out line 75 is a candidate for the DaniWeb all-time greatest mistakes hall of fame. I know there is … |
The End.