7,116 Posted Topics

Member Avatar for karthickparthi
Member Avatar for mseck
Member Avatar for javaAddict
0
162
Member Avatar for Olliepop

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, …

Member Avatar for JamesCherrill
0
216
Member Avatar for pucivogel

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 …

Member Avatar for pucivogel
0
1K
Member Avatar for kiroyzki

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.

Member Avatar for musthafa.aj
0
100
Member Avatar for checho

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 …

Member Avatar for JamesCherrill
0
834
Member Avatar for Ashwin1985

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 …

Member Avatar for Ashwin1985
0
185
Member Avatar for alkeshtech

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

Member Avatar for Andreas Hollman
0
114
Member Avatar for valatharv

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 …

Member Avatar for vladimirdlc
0
161
Member Avatar for anilopo

[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 …

Member Avatar for anilopo
0
149
Member Avatar for StarZ

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.

Member Avatar for musthafa.aj
0
104
Member Avatar for adams161

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]

Member Avatar for adams161
0
122
Member Avatar for Waddiwassi

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 …

Member Avatar for Waddiwassi
0
173
Member Avatar for sifounas

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 …

Member Avatar for JamesCherrill
0
131
Member Avatar for valatharv

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 …

Member Avatar for JamesCherrill
0
118
Member Avatar for jogendar

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.

Member Avatar for JamesCherrill
0
104
Member Avatar for Merosansar

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 …

Member Avatar for javaAddict
0
104
Member Avatar for ramjeev

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 …

Member Avatar for ramjeev
0
94
Member Avatar for lardshow

[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

Member Avatar for JamesCherrill
0
109
Member Avatar for JPDobner
Member Avatar for OzY360

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.

Member Avatar for OzY360
0
1K
Member Avatar for beforetheyknew

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]

Member Avatar for darkagn
0
112
Member Avatar for forsan200
Member Avatar for Whilliam

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 …

Member Avatar for peter_budo
0
135
Member Avatar for bobscrazy

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.

Member Avatar for JamesCherrill
0
99
Member Avatar for adams161
Member Avatar for Gary888

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 …

Member Avatar for JamesCherrill
0
64
Member Avatar for wondergal04

Can't see where you add the listener to the combo box. Is your itemstatechanged method bei ng called?

Member Avatar for JamesCherrill
0
116
Member Avatar for checho

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()) { …

Member Avatar for JamesCherrill
0
2K
Member Avatar for pac-man

[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

Member Avatar for JamesCherrill
0
189
Member Avatar for Clawsy

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.

Member Avatar for Clawsy
0
1K
Member Avatar for beforetheyknew

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 …

Member Avatar for Phaelax
0
118
Member Avatar for jorgelex008

[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 …

Member Avatar for JamesCherrill
0
228
Member Avatar for jorgelex008

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.

Member Avatar for MxDev
0
304
Member Avatar for Acegikmo

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.

Member Avatar for MxDev
0
117
Member Avatar for javaman2

[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 …

Member Avatar for JugglerDrummer
0
1K
Member Avatar for mellowmike

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 …

Member Avatar for mellowmike
0
471
Member Avatar for anilopo

[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.

Member Avatar for anilopo
0
103
Member Avatar for girl.java

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.

Member Avatar for tux4life
0
98
Member Avatar for theGem2001

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]

Member Avatar for JamesCherrill
0
88
Member Avatar for jerseycoaster

Almost certainly you can delete them, but just to be safe, move them to a temporary folder somewhere else and see if anything breaks.

Member Avatar for BestJewSinceJC
0
143
Member Avatar for shack99
Member Avatar for shack99
0
119
Member Avatar for HazardTW

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 …

Member Avatar for HazardTW
0
244
Member Avatar for sambafriends
Member Avatar for Son of a gun
Member Avatar for anevins

Your constructor needs 4 parameters (3 doubles, 1 boolean). You are trying to call it with 2 parameters (1 String, 1 int).

Member Avatar for anevins
0
137
Member Avatar for Camzie
Member Avatar for Clawsy

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();

Member Avatar for Clawsy
0
227
Member Avatar for GiRL,IT
Member Avatar for devnar

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 …

Member Avatar for devnar
0
972

The End.