7,116 Posted Topics
Re: "When I click the save button it shows an error." What is the exact complete error message? | |
Re: What's the relationship between the `address` and `addressList` Lists? Are you sure that addressList contains all the entries you expect? Is the size() of address as large as you expect? | |
Re: Use a `javax.swing.Timer` to call a method that updates the info every 60,000 milliseconds. See the API doc for details | |
Re: As far as I know there are little or no changes to how Sockets or the NIO SocketChannel etc work from Java 7 to Java 8. | |
Re: Line 62 is a terrible mistake. You have a problem related to a file being written In the code that writes the file you go out of your way to supress any exceptions and hide/discard any exception messages. You are saying "if anything goes wrong just pretend it didn't and … | |
Re: You could try combining all those arcs into a single shape that will then fill properly. A `Path2D.Double` may be the best option. | |
Re: If you split the para by white space you will get an array of al the words, so each word will have its own array index (ignoring puncuation for the moment!). You may have problems with the subsequent index numbers changing when you split add or remove words | |
Re: "does anyone know of a loop that could be repeated so that the players can enter the correct age. I need to created a loop so that when, let say if player one enter the wrong age it can loop back to the started where they can reenter the correct … | |
Re: JLabel does not display multi-line simple text. You could use a JTextArea or somesuch, or you can use simple HTML formatting to display multi-line text in a JLabel | |
![]() | Re: Hey! He's entitled to his opinion. (Although his post would have been better if he had supplied some justification for his opinion.) |
Re: You cannot mix Data streams and Readers/Writers - they use completely different data formats. Data sttreams send (binary) data, readers/writers send text. Either use a DataOutputStream to send data to a DataInputStream, or use a PrintWriter to send text to a BufferedReader | |
Re: You are trying to define a method withiout finishing the previous method defintion. You canno define one method inside another method like that. | |
Re: There's a topic for project ideas in the Java section - but the language is irrelevant https://www.daniweb.com/software-development/java/threads/430542/java-projects-for-learners | |
Re: An abstract class is a class with one or more methods declared abstract (ie the signature is declared, but there is no implementation. Becuase one or more methods are not implemented, it is not possible to create an instance of an abstract class. An abstract class can be extended by … | |
Re: You can now use aTask to do anything that's valid for a Task. Later you coiuld change the PracticeTest ofr a FinalTest or any other subclass of Task without breaking any code. A better example: List myList = new ArrayList(); myList has to be a List because of the logic … | |
Re: Looking at the next line in the stack dump, the parseInt was called from line 111, so it is the "Year" tag that has a null value | |
Re: Why re-invent the wheel? Why not use ObjectOutputStream and ObjectInputStream to write your meeting data as Java objects and read them in the same way? If there's a top-level object that holds the whole list of meetings then you can just write/read that as a single object. Alternatively, if your … | |
Re: That toggled loop looks to me like you are trying to go "procedural" where you should be event driven. Normally in both client and server you would have a loop that waits for an inbound messages and handles them (updates game state and/or GIU). In the client, GUI events (OK … | |
Re: Ahhhhh APL what memories! I used APL in IBM in 1969 on an 1130 mini with a golfball typewriter terminal. I had to have my own personal APL character set golfball. I used it to write an assembler for the System 7 real-time mini so we could start to develop … | |
Re: If you need to add events, then the obvious way to start is to create an Event class. It would have start date/time, and date/time, title, location etc as instance variables, with the usual getters and setters and a constructors. You can use GregorianCalendar instances for the start and end … | |
Re: I think you will have to create a Shape using multiple arcs, quad curves, maybe even cubic curves. Although cubic curves have the potential to construct this with fewer segments, you may find that it's a lot easier to use simpler curves. You may also be able to simplify the … | |
Re: The Character class has a load of methods for dealing with complicated UniCode characters - maybe that's what you need? | |
Re: Sorry, but that code is completely unreadable. Can you try to split it down into some sensible methods... try to divide it so that no if/else block or loop spans more than about a dozen lines. Then indent it all according to normal Java standards. | |
Re: It's just like counting words, except simpler. Instead of splitting the String into words, you just take each char from the String and count those. | |
Re: startRunning creates an infinite nuber of concurrent server threads, each of which tries to open the same server socket. That's the wrong threading strategy. To make things worse, you have that startRunning infinite loop exceuting on the Swing event dispatch thread, so it blocks all GUI activity for ever. You … | |
Re: Yes, absolutely. Use the `ProcessBuilder` class - Google for API details and tutorials | |
Re: public void paintComponent(Graphics g) { super.paintComponent(g); g = graphic.getGraphics(); g.drawImage(graphic,0,0,null); } You re-use the `g` variable on the third line here, thus losing your reference to the component's Graphics, so you draw the imge back onto iteself on the fourth line. | |
Re: I guess your ChartFrame is a kind of JFrame - ie a top-level container or window, so you cannot place that inside a lower-level container like JPanel. If you are usimg JFreeChart then you can replace your ChartFrame with a ChartPanel. ChartPanel is a kind of JPanel, and can be … | |
Re: Line 13 you print the Scanner object `a` The output you see is the description of your scanner object. I guess you wanted to print the user's input, `kakdo`? | |
Re: What is the .exe file? Simply re-installing the latest version usually fixes any out-of-date or incorrect registry settings. Java 1.6 is years out of date, no longer supported, and riddled with un-fixed security problems. Unless you have some very specific requirement for some obsolete Java application, you should update to … | |
Re: You get the input from the user, but you parse it as an int. Why is that? You have code (lines 14 - 46) that remove a given string from a given file. You can re-package that code as a method, passing the string and the file name as parameters. … | |
Re: I see 20 threads there - is that expected? If it's a problem with your code (as opposed to a bug in the lib itself) the it probably relates to your not closing/freeing/terminating something properly (maybe) | |
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: No need for the Strings or the switch, classes are Classes in their own right! Class[] carTypes = {Van.class, Cab.class ... }; for ( int i = 0; i < x; i++) { newArray[i] = (Car) carTypes[getRandomIndex()].newInstance(); } | |
Re: What about zeros? Zero isn't positive or negative? | |
Re: If you have an index out of bounds error then the error message will tell you the exact line where the error happened. No need to guess. I have to disagree with Tekkno. Novices may go 10%/90%, but sucessful programmers go more like 40% design, 30% coding, 20% unit/integration testing, … | |
Re: Line 31 you declare the parsedUserGuess variable, OK, but you also give it its value by parsing the text field at that point. This happens before the user has been able to type anything, so the result is just 1. You need to perform the parseInt and assign that to … | |
Re: I agree. You will need to create a user interface, create a IP server and an IP client, make a network connection, send data by using streams, and do all that in multiple threads. If you are new to Java this is far too much to tackle in one go. … | |
Re: Sorry man, the first version looks right to me. Maybe it's OK but there's some other problem that makes it look like its not working? If you post a runnable test program I can check it out on my Macs. | |
Re: There's something deeply suspicious about the data redundancy here that makes me unsurprised that your swap method has problems. As I understand it theres a Tile[][] array that says what Tile is in what position, and each Tile has its x,y position as instance variables. Change one and you must … | |
Re: You seem very confused. Do you want someone to give you some code? If so, this is the wrong place. Do you want help to write your own code? If so, what have you done so far and what help do you need? Why did you mark this solved? | |
Re: Do you just want to shuffle all the Tiles? Put them all in a `List` and call `shuffle()` Then simply re-populate your x,y grid with the Tiles in their shuffled order. | |
Re: I can't read all that code, but it sounds like you should be using Key Bindings. http://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html | |
Re: That's just a copy of your assignment. Surely you didn't expect anyone to give you the solution? What help EXACTLY do you need? What have you done so far? Read the rules before continuing https://www.daniweb.com/community/rules ps: Spec implies program will NOT stop if total score > 50. And the two … | |
Re: That message does not correspond to the code you posted, so that's useless. Anyway - check your capitalisation... the method name is random not Random ps: You will get a faster resonse by posting Java questions in the Java forum. | |
Re: When you declare a variable its scope is from the immediately preceeding `{` to the immediately following `}`. So your `excel` variable is in scope from line 211 to 213 only. Outside that scope the variable cannot be used. You have to declare variables somewhere where their scope includes all … | |
Re: Rather than have a single String that contains the whole dictionary, you need to store and process each dictionary phrase separately. Eg if the phrases are on separate lines you could use Files.readAllLines to get a List of phrases. | |
Re: Have you tried redirecting the new process's output stream? There are various options for that (see the API doc). This one looks particularly interesting... public ProcessBuilder inheritIO() Sets the source and destination for subprocess standard I/O to be the same as those of the current Java process. | |
Re: Hi kavitadc - welcome to DaniWeb. Many of our members have English as their second or third language, so we insist that you post in clear complete English, no "text-speak" or funny abbreviations. It's not clear from your post exactly what help you need. Please start again and explain it … | |
Re: I agree. Plus: Java isn't the language to do it in. C and C++ would be better. |
The End.