7,116 Posted Topics

Member Avatar for kvass
Member Avatar for kvass
0
97
Member Avatar for whimsical1987

BREAK appears to be a valid label [url]http://java.sun.com/docs/books/jls/second_edition/html/statements.doc.html#78993[/url] and the break with a label also seems valid [url]http://java.sun.com/docs/books/jls/second_edition/html/statements.doc.html#6842[/url] I just ran them thru Eclipse (Java 1.6u20) and they generated no errors, although the label does seem completely redundant in this case. What exactly was the error message and exactly which …

Member Avatar for JamesCherrill
0
89
Member Avatar for IOwnAndPwnU

You don't say what the problem is, exactly, but you are mixing old-style AWT classes (eg Panel) with Swing classes (eg JButton). This is always dodgy. You should replace all the AWT ? classes with the swing J? equivalent. Your buttons should resize to fit the image when you pack …

Member Avatar for JamesCherrill
0
2K
Member Avatar for help_please

It means what it says. addAll requires a parameter that is a Collection of Words, and you have passed a single String.

Member Avatar for JamesCherrill
0
140
Member Avatar for mckrm
Member Avatar for gunjannigam

Google the Java Event Dispatch Thread and read about Swing threads. Your repaint() calls won't do anything until your event method completes, even if it sleeps in the meantime..

Member Avatar for JamesCherrill
0
114
Member Avatar for padmaanand
Member Avatar for javaAddict
0
144
Member Avatar for java=hard

Look at the suggested code. It's calling a method, passing a question, two answers, and a last param showing which answer is correct. You need to create the method with those 4 parameters so it shows the Q and the A's, gets the reply, and finally returns true or false …

Member Avatar for JamesCherrill
0
145
Member Avatar for jjonesmu

Try putting a few print staements to see if: the keylistener is being called the appropriate if test bocks are being executed the new vlue of y is correct the new value of y is being used in the paintPaddle method. My guess? paintPaddle isn't being called - you should …

Member Avatar for Ezzaral
0
1K
Member Avatar for msr

I see no-one has replied to this (wonder why???), so I'll have a go. Is the following the kind of thing you are looking for? [CODE] interface I<T extends Event> { T dosomething(T t); } class Event2 extends Event { public Event2(Object arg0, int arg1, Object arg2) { super(arg0, arg1, …

Member Avatar for msr
0
103
Member Avatar for sam8

Your print is in the merge method, which gets called repeatedly during the sort, so you get repeated prints. You need to move the count variable out of the method so it retains its value from one call to the next, and print it only when the sort has finished.

Member Avatar for sam8
0
3K
Member Avatar for Bobon

Walk thru your loop by hand looking at the values and the result of the while test. What happens when you reach the end of the array?

Member Avatar for JamesCherrill
0
86
Member Avatar for jiraiya

I can't give you all the details, but in short: "yes". When you package your app into a .jar file you can also put any truetype fonts you need in the same jar (subject to copyright etc, of course). You then read the font file and create the font in …

Member Avatar for jiraiya
0
171
Member Avatar for k2k

[QUOTE=k2k;1196184]it was the variable type mismatch thing.. i m surprised that the compiler didn't catch it... still a bit confused but it is fixed. [/QUOTE] Thgere was nothing for the compiler to "catch". Your code is valid, but just didn't do what you wanted. The equals(Object) method is defined on …

Member Avatar for JamesCherrill
0
108
Member Avatar for ttboy04
Member Avatar for ttboy04
1
96
Member Avatar for bbetzel

That's probably as easy as it gets - provided that you created an 8x8 array of panels, and do all the processing in nested loops.

Member Avatar for JamesCherrill
0
35
Member Avatar for anjal_pawar
Member Avatar for Sseeth

1. Check your capitalisation! Java is case sensitive. 2. To make the sort meaningful your CrewMewmber class needs to implement Comparable, otherwize there's no way to know what the correct sort order for CrewMembers is.

Member Avatar for Sseeth
0
4K
Member Avatar for grady-lad

Use client properties. All swing components allow you to associate any number of values with any component. [url]http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JComponent.html#putClientProperty%28java.lang.Object,%20java.lang.Object%29[/url]

Member Avatar for JamesCherrill
0
61
Member Avatar for Alianncox
Member Avatar for johndoe444

BJSJC: You're looking at sql.date. java.util.Date says Date() Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.

Member Avatar for jwenting
0
145
Member Avatar for nikolaos

What excatly do you want to achieve? It looks like you want the two threads to alternate (each method waits for the other method to execute exactly once before it runs, regardless of the threading) - in which case I don't think you'll get a much better solution than your …

Member Avatar for JamesCherrill
0
113
Member Avatar for hell04

Suggest you remove the main(...) in MyArrayList in case you're running that one by mistake?

Member Avatar for tiny7415
0
6K
Member Avatar for wheriz

[CODE]class MyClass { public MyClass() { // default constructor defined explicitly } public MyClass (int i) { // parametised constructor } }[/CODE]

Member Avatar for JamesCherrill
0
84
Member Avatar for firebugg

Read the API for Thread's constructor - your parameter should be an object that implements Runnable, which MergeSorter doesn't.

Member Avatar for firebugg
0
2K
Member Avatar for David22

Yes, Observer is the way to go. Java API uses it all the time - just look at all the "Listener" interfaces and methods in Swing for a start. You'll find loads of details and samples on the web.

Member Avatar for JamesCherrill
0
134
Member Avatar for hightech2

[QUOTE=dickersonka;737879][code] public boolean isEmply(){ if(top == -1){ return true; } else { return false; } } [/code] [/QUOTE] or even... [CODE]public boolean isEmpty { return top == -1; }[/CODE]

Member Avatar for coderGh
0
1K
Member Avatar for javitis

It's often done that way, but ideally the constructor should also use the set() methods to store the parameter values, thus ensuring that any side effects are properly handled.

Member Avatar for javitis
0
64
Member Avatar for the_fool

Looks like you should use index and value parameters to set the appropriate element of the projects array to the appropriate value, as in projects[index] = value;

Member Avatar for JamesCherrill
0
108
Member Avatar for litchi
Member Avatar for PhiberOptik

I presume both pix are in the jar? Check the file name case - they are case-sensitive in jars but not in the windows file system.

Member Avatar for JamesCherrill
0
95
Member Avatar for TheWhite

You should create a variable just to use as a synch object then if two pieces of code should not run concurrently, explicity synch them on that same variable. If there are two different situations where that applies you can have two variables (etc). Avoid having to synch on two …

Member Avatar for TheWhite
1
166
Member Avatar for tjsail

When your teacher said "introspection " the Java word is "Reflection", which you can Google if you want. Having said that, you do NOT want to use Reflection for this. What Ezzaral says is exactly right - use a HashMap<String><Player>

Member Avatar for JamesCherrill
0
5K
Member Avatar for iamsmooth

You can redirect System.out to a PrintStream of your own choice, so you could redirect to a byte array output stream from which you can check everything.

Member Avatar for jwenting
0
1K
Member Avatar for eldhoksuresh

The File class is "An abstract representation of file and directory pathnames." (Java API ref). Just because you have an an abstract representation of a file name, that doesn't mean you necessarily have an actual file on disk. The actual file will appear when you open some kind of output …

Member Avatar for eldhoksuresh
0
85
Member Avatar for qariella

Looks like raise is intended to be a % value, so you shouldn't just add that to the salary - you're only adding 1.5 to 6 cents in your current code.

Member Avatar for JamesCherrill
0
160
Member Avatar for FotG2

MouseListener is a interface in the Java API, so it's not a good name to use for yours. It's worth changing it, just in case.

Member Avatar for FotG2
0
939
Member Avatar for houlahan

Here's the root of your problem: [CODE]class HeathProblem extends Patient [/CODE] A Health Problem is NOT a kind of patient. A health problem does not have a home address or a phone number! It's a thing that a patient an have zero or more of. So I would expect to …

Member Avatar for JamesCherrill
0
148
Member Avatar for Clawsy

Somebody somewhere is going to have to loop thru the pixels to find differences. Are you sure it's too time consuming? If you haven't tried it, I would not jump to conclusions about performance. You'll simply be comparing two arrays of ints in a tiny loop - that's about as …

Member Avatar for Clawsy
2
4K
Member Avatar for sujithy15

The question seems ambiguous to me. Any Java interface can contain many methods. What this more probably refers to is illustrated in this example: You have an interface Vehicle that declares a void drive(int speed) method. class Car implements Vehicle { void drive.... etc so does class Speedboat implements Vehicle …

Member Avatar for verruckt24
0
116
Member Avatar for sujithy15

[url]http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html[/url] (What an amazing thing Google is)

Member Avatar for sujithy15
0
247
Member Avatar for Clawsy

I used the following standard solution: [CODE]ims = new MemoryImageSource(width,height, pixels, 0, width);[/CODE] (where the width/height vars define the image size and pixels is a simple int array of PixelGrabber-type data then: [CODE]Image im = Toolkit.getDefaultToolkit().createImage(ims);[/CODE] It seemed to me that this was fast enough to be be negligeable compared …

Member Avatar for JamesCherrill
0
2K
Member Avatar for kaushalya_uom

All you would need to do is loop thru all the files in the dir, then, in that loop, read thru each file until either you match the text or reach EOF. What data structures would you need?

Member Avatar for javaAddict
0
131
Member Avatar for Moonrise_state
Member Avatar for Ashwin Vasnai

This is a very common thing to want to do. You will have no problem finding example solutions on the web (if you look).

Member Avatar for lanhlung696
0
363
Member Avatar for anevins
Member Avatar for thekashyap
0
160
Member Avatar for checho

A few quick observations: Class names: should begin with a capital letter and shouldn't be plural when they represent a single instance of something. Eg use Account rather than accounts. An Account is not a kind of Customer, so it shouldn't extend that class. Do you need personName and companyName? …

Member Avatar for checho
0
166
Member Avatar for guravharsha

Easy. Just open a PrintStream to the .txt file and use print(...) to print the details and the lines one at a time. [url]http://java.sun.com/j2se/1.5.0/docs/api/java/io/PrintStream.html[/url]

Member Avatar for JamesCherrill
0
195
Member Avatar for kendaop

[QUOTE=BestJewSinceJC;1113793]To force a singleton I suppose you could simply use a getInstance method and refuse to return an instance if one already exists. I *think* you could enforce this by instantiating a private constructor [/QUOTE] Yes, that's the standard solution. The static getInstance method uses the private constructor to create …

Member Avatar for JamesCherrill
0
155
Member Avatar for Stefano Mtangoo
Member Avatar for jwenting
0
151

The End.