7,116 Posted Topics
Re: You don't need the + operators at the start of each expression. The modulo opertaor is %. | |
Re: You stop() before you deal with the pong. Using stop() is a bad idea. It's deprecated. Set your threadcontinue var to false to exit the run cleanly. Anyway - if the first readline isn't ping then you do a second readline to check for pong. That's one readline to many, … | |
Re: Forget the GUI for the moment. Go back to where you should have started, which is the hotel model. You need to design some simple classes for entities such as Room ( attributes: no of beds, sea view etc), Hotel (a collection of Rooms with methods for finding vacant Rooms … | |
Re: On line 166 it expects a } (was that so hard to understand?) It's because you dont have a } to close your method, nor one to close your class definition. | |
Re: Kittens can be male or female. Tomcats are always male, so it makes no sense to require boolean isMale in the constructor - just leave out that parameter and hard wire isMale=true in the constructor. You may also want to override the setMale method for Tomcat to raise an error … | |
Re: I'm a bit confused by this. You seem to be wanting to give people an encrypted file and a decrypter with the key already filled in. Why bother encrypting in the first place? But if that's what you want - just store your keys somewhere - eg a file that's … | |
Re: Whenever you add an element, iterate thru the existing list elements until you find the right place to insert the new element. That way the list will always be in sorted order | |
Re: Is this thread really about trying to optimise the JVM memory setting so as to minimise the allocation of (unused) virtual memory? Why not just set the vm size to large enough for the worst case and leave it at that? This looks like trying to solve a problem that … | |
Re: [QUOTE=anilopo;1105167]i want to add source files that i made in another computer to my project. i want them to be at the same folder as the project. how do i add them to the project? (to copy them into the folder wont help in this case..) thx!![/QUOTE] Right-click the package … | |
Re: Sooner or later you'll get to GridBagLayout - not the easiest to use, but it's the one that gives you the most control. Hang on in thru the learning curve and you'll never regret it. | |
Re: I would use JPanels to organise your window. I'd put the board into one panel, and have another panel next to it where I can place other controls using whatever layout suits me. See: [url]http://java.sun.com/docs/books/tutorial/uiswing/components/panel.html[/url] | |
Re: YOu have a Factory, that makes objects of some specific type. Maybe you want to use a different Factory depending on some run-time consideration. If all your Factories extend an AbstractFactory class then you can create the appropriate Factory once at the beginning, then use it via the abstract superclasses's … | |
Re: IMHO: There's nothing to chose betwen the languages themselves - C# may be slightly richer, but no enough to make any difference, and converting from one to the other is mostly just a question of small syntax differences. But: the language is maybe 5% of what you have to learn … | |
Re: In general, the right way to do this is to create an Item class, with ID, name, location etc as instance variables. When you retrieve an item from the database use the row values to construct a new Item instance and pass that as a simple parameter. You can also … | |
Re: You could use an HTMLDocument as the document model for a JTextPane, then you can easily read/write the formatted content from/to .html files. | |
Re: In the handler for the second button you create a brand new candidate list and show that. Maybe you should show the existing one onstead? Similarly, in the first button handler you create a new list every time the button is pressed. You need to create one candidate list when … | |
Re: Sorry ramjeev, musthafa is right. "this"[B] is[/B] the method's object. See Java Lanmguage ref: [QUOTE]8.4.3.6 synchronized Methods A synchronized method acquires a monitor (§17.1) before it executes. For a class (static) method, the monitor associated with the Class object for the method's class is used. For an instance method, the … | |
Re: [QUOTE=adams161;1099803]your throw should be in a try. [/QUOTE] Not true. You can throw an Exception from anywhere. In your test program you need to have a try/catch to catch that Exception when the called constructor throws it | |
| |
![]() | Re: You need to place the whole menu handing (from line 22) inside a loop. Most easily you would use a while(true) { ... } loop, and add a menu option to exit from the program. ![]() |
Re: A literal is a fixed value declared in the source code such as: 123 true 'A' "A String" {1,2,3} see: [url]http://www.javaying.com/2006/12/whats-java-literal.html[/url] | |
Re: You declared the variables in Tile as static! | |
Re: The class diagram should show only the externally visible characteristics of the class. Attributes (RW/RO/WO) correspond either to non-private variables, or to conventional non-private accessor methods. Private variables would not normally be shown, although you sometimes see one included because it's important to the reader's understanding of how the class … | |
Re: Which loop? The i=1..10 or the baffling counter one on lione 12 (that looks like it will only ever be executed once). If it's the first loop, you need to declare and initialise the varaibles (lines 6 & 8) outside the loop, ie before line 2. | |
Re: setIconImage(myIconImage) on your main JFrame. | |
Re: Easy way is to have a public method in the booking form class, pass the current instance of that class to the constructor of the search form class, then simply call the method on the instance when required. This creates a hard-coded dependency between the search and booking classes which … | |
Re: Can't see where you add the listener to the combo box. Is your itemstatechanged method bei ng called? | |
Re: While that code works, it's nowhere near as readable as the original version. You can fix the concurrent exception by simply iterating on a copy of the hashmap, and keep the clarity of the first version. Ie: [CODE]HashMap<Integer, Integer> temp = new HashMap<Integer, Integer>(numbers); for (int i : temp.keySet()) { … | |
Re: [QUOTE=pac-man;1094303]... would it be correct to say that the object (the balloon) now has 2 references (strings) attached to it, that is, the original reference and the copied reference being passed?[/QUOTE] Yes | |
Re: Can you try this again with the array reduced to (say) 3 elements? That will tell you whether it's a size problem or something else. | |
Re: I.M.H.O. 1. Very tiny programs can go in the main(...) method, but it's far better practice to split programs up into classes and methods and just use main to get them started. 2. Declaring an array like that is absolutely fine. Just check that the following code gets the array … | |
Re: [QUOTE]Can I tell the mouse via Java to go to coordinates x1,y1 (which might be where the Excel application lies) copy, then go to coordinates x2,y2 (say where the 3rd party database window is), then paste?[/QUOTE] See the Java Robot class. [url]http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Robot.html[/url] It's intended for automated testing, but it will … | |
Re: Use [B]java.awt.MouseInfo[/B] That gives you [B]MouseInfo.getPointerInfo().getLocation().x[/B] and [B]MouseInfo.getPointerInfo().getLocation().[/B]y You can use a swing [B]Timer [/B] ( [url]http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html[/url] )to run a method at regular intervals.In that method use [B]MouseInfo [/B]to get the coords, then put them in a String that you use to set the text of the JLabel. | |
Re: You may have a problem with case-sensitivity in your file names. Windows file names are not case sensitive, but when you access the same resources from a jar I think they are case sensitive. | |
Re: [QUOTE=javaman2;875255] the game must be two to four players so if anyone can help me with that i've tried to do that with the deck array would it be better to put a multidimensional array for the two to four players and the cards in the base class(card) or derived … | |
Re: There's too much missing code to tell - but it looks like you may be reading the two objects in two separate threads each of which opens the inputstream? If so, try reading both objects together, just like they were written. I can confirm that ArrayLists of Objects transfer via … | |
Re: [QUOTE]I want to pass all the values from a HashMap to ArrayList[/QUOTE] HashMap has a values() method that returns a Collection of all the values. ArrayList has a constructor that takes a Collection of values to populate the list. So all you need is a single line of code. | |
Re: You have made this a hard as possible for anyone who wants to help - unformatted code, zero comments, no description of the actual error. Anyway, you count in c,v,p,s but then display the unused variables nc, nv, np, ns. | |
Re: Handling menus is well documented all over the web. Opening a URL in the browser is a recent enhancement to Java, but here's the introductory documentation: [url]http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/desktop_api/[/url] | |
Re: Almost certainly you can delete them, but just to be safe, move them to a temporary folder somewhere else and see if anything breaks. | |
Re: Are you sure you have seven double values in the input file? | |
Re: Generally a very bad idea to build a dependency where a data class is dependent on a particular visual representation. Suppose your next project is to display the same info in HTML? Its normal for a GUI class to depend on the underlying data model, but not v.v. Personally I … | |
Re: package has to go before any imports - swap first 2 lines. | |
| |
Re: Your constructor needs 4 parameters (3 doubles, 1 boolean). You are trying to call it with 2 parameters (1 String, 1 int). | |
| |
Re: This is just a guess, but... you have PngEncoder pngenc; that creates a reference variable, but it does NOT give you a PngEncoder object. Y0u probably need something like PngEncoder pngenc = new PngEncoder(); | |
Re: I'll do it for you. $50/hour, OK? | |
Re: Maybe it's this: The arg should be a [][] array - which is what the variable args contains. The invoke method requires an array that contains all the parameters for the method being invoked. The init method has 1 parameter, so the invoke method should pass an array of 1 … |
The End.