7,116 Posted Topics
Re: It depends on what kind of anti-virus. If you are just scanning files for suspicious content on demand, then Java is perfectly suitable. If, on the other hand, you want a useful anti-virus that automatically scans all downloaded files, and monitors the system for suspicious behaviours, then Stuktuske said it … | |
Re: Then write one, and read the Daniweb member rules before posting again | |
Re: Line 30 is an import statement that comes after a class def. that's an error, imports must come at the beginning of the file. | |
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 "Do provide evidence of having done some work yourself if posting … | |
Re: if you use a classic model/view pattern then this is straighforward. Your "model" classes encapsulate the current state of the game (who has which cards, whose turn is it next etc) in a purely logical form (no user interface artifacts). Your "view" classes display the current state as a GUI … | |
Re: If there are only 256 possible keys, just try each one in a loop until you get one that works. | |
Re: It looks like you draw all the strings at the same position. You need to draw each string at increasing y coordinates so they appear one below another | |
Re: Line 39, l2 is uninitialised, so its value is `null` - you create the scroll pane with null as its content Lines 42,43 you initialise l2, but it's too late. | |
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: The target "client" has to be listening on ServerSocket for the other client to connect, but that's the same as the code in our existing server. The problem is usually to find the target client's IP. Having a registered domain name is one way, or a dynamic DNS solution like … ![]() |
Re: Those are the first bytes in the file, yes? Just open a FileInputStream with that file and read the first 4 bytes into a 4 byte array where you can check the values. Then close the stream. https://docs.oracle.com/javase/8/docs/api/java/io/FileInputStream.html ps: Although those bytes correspond to "%PDF" in ASCII, don't be tempted … | |
Re: Is the rest of the file just text? If so, just read the file using a Scanner with your D2A7 bytes as the delimiter https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html | |
Re: English is not your first language? OK. But that sentence does not make sense. Please try to explain with more detail. | |
Re: Look at line 33. As soon as you test a name that's not in the very first element of the array you break from the loop and stop looking. You probably intended to break after finding a match. | |
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: Write down a brief description of what the game is - its rules etc. Write down a few examples of how it would look when a user uses it. (Use any format or medium that suits you - pencil & paper, blackboard etc) Then (and not before) think about what … | |
Re: I simplu doesn't work like that. If you want a reference to an object, use a reference variable of the right kind. Java references are "opaque" - you can use them but you can't manipulate them. There's no way to turn a String into an object reference. If you want … | |
Re: Take a look at the InetAddress class. You can use it to parse your text into an internal-form inet address InetAddress.getByName("10.4.23.16") then extract it as a byte array byte[] bytes = InetAddress.getByName("10.4.23.16").getAddress(); It will then be easy to write the comparator using those four numeric bytes (four nested tests OR … | |
Re: That's not enough information for anyone to help. You need to post the whole code, and the complete text of any error messages. If there are no error messages but it's not working right, explain what it should do and what it actually does. | |
Re: The game "Scrabble" needs a list of valid English words. If you search the web you will find downloadable files with suitable word lists. | |
Although layout managers usually scale text properly, with the spread of "retina" Macs with screen resolutions over 200 d.p.i. we can't just keep ignoring pixel size for grahics or animation. Toolbox has a method for getting the screen resolution, but I don't have access to enough varied machines to see … | |
Re: Java will call your paint method when necessary. You can use the repaint() method to let Java know that a new paint is needed. Instead of the literal on line 9, use a String variable. Then you can update that variable in your mouse clicked method, and call repaint() | |
Re: That code looks OK. What help do you need? | |
Re: [CODE]public void AccelerateSpeed (int speed) { speed = speed + 5; }[/CODE] This code takes the value of the parameter "speed",adds 5 to it, and returns. It has no effect on the "speed" defined in the class because the parameter has the same name and "masks" the class variable. What … | |
Re: This is nothing to do with the compiler. The compiler has no way to know whether the array reference will be valid at run time. It's the Java runtime that checks every actual array index and throws the exception if it finds one out of range. What is the value … | |
Re: You use a loop when you want to do something a number of times. You use an `if` if you want to do something only under some circumstances. Reading the description of step 5, there's nothing repetitive there, but there is something you have to do only when all the … | |
Re: ... and your question is...? | |
Re: Did you really write that code? It displays a wide knowledge of Java syntax, including some of the latest language enhancements. Someone with that kind of programming skill would surely know how to handle parts 2-4. | |
Re: "But token in my opinion works better" Obviously not. If the input can be multiple words separated by blanks then either you have to loop reading all the tokens on the line then concatenate them again, or just read the whole line. | |
Re: You will need to test for incorrect input and throw an Exception if it's incorrect. If one of the existing Exceptions in the Java API correctly describes your situation (maybe DataFormatException ?) then use that. If not, define your own Exception. There's no right or wrong here, just do whatever … | |
Re: Your code is the solution to a different problem (count the number of odd numbers in an arbitrary list of numbers entered b the user). Looks like you copied from the wrong source. | |
| |
Re: OK stultuske has given you excellent advice, but all you need to do now is to use tha `append` method instead of the `setText` method so that your strings are appended into the text area, not overwritten. | |
Re: Put that code in a public method and call that method from your main class | |
Re: Start by indenting your code properly and fixing the compile errors. | |
Re: Line 6 of the error message tells you that it was trying to parse the user input on line 47, and failed to parse it as an int. Did the input dialog appear OK? What did you enter in it? | |
Re: See the very first topic at the start of the Java forum main page https://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 helping you cheat or doing your homework for you. DaniWeb Member Rules (which you agreed to when you signed up) … | |
Re: No, it's not Vector. Vector has *not* been formally deprecated (just look at the current API doc). The nearest it gets is the following quote from nthe Java 8 API JavaDoc: "If a thread-safe implementation is not needed, it is recommended to use ArrayList in place of Vector." | |
Re: I don't know anything about PdfPCell, but it looks odd that you create new instance of it on line 7, but you don't do anything with it. Similarly you add a `table` on each pass of the loop, but I don't see any code to change `table`'s value in the … | |
![]() | Re: I doubt very much that the HTML support in Swing will ever be updated for HTML 5. The future of rich graphical GUIs in Java is JavaFX, so maybe you should be doing this in JavaFX not Swing. The JavaFX docs do refer explicitly to HTML 5. |
Re: You are stopping and starting to switch between two timers, so the timing keeps changing. One solution: Have 1 Timer that just moves block 1. Start this and leave it running Have another Timer that just moves block 2. Stop and start it however you like because that won't affect … | |
Re: Your catches will catch exceptions thrown inside the corresponding try block (lines 35-47). The nextInt method (line 32) can throw the IMM exception, but that's outside your try. | |
Re: Do you override equals for your User class and use that for all "equals" tests? That woud be the normal approach, == is never going to work all the time if objects are being re-created. | |
Re: First pass through the loop you `add` and `close`, so on the secand pass through the loop the document is already closed, so the `add` fails | |
Re: The JDK comes with [JavaDB](http://www.oracle.com/technetwork/java/javadb/overview/index.html) (a fully Oracle-supported version of Apache Derby) as standard. If you use that in embedded mode you just need to add one 2.6 MB jar to your application, and the user doesn't have to install anything else. Unless you plan an enterprise-scale roll-out I can't … | |
Re: Nobody is going to give you the answer. That destroys the whole point of giving you this to do as part of your education. Here's some info that may help you do this yourself... The String class has a method that converts to String into an array of characters You … | |
Re: the array student is created on line 8 but you have no code to inialise it, so it is just full of zeros. So on line 20 when you print student[i] that's always zero. | |
Re: Why the duplicated code in the two BattleShipX classes? At a quick look it looks like you should have an abstract superclass with all the common code, and have those 2 classes as subclasses, with pnly the methods that are different. (Or if the differences are just in data values, … | |
Re: If you don't put them in an array (or some other container eg ArrayList) then you would have to re-read the file for each user input, which would be a messy and inefficient solution. |
The End.