7,116 Posted Topics

Member Avatar for Daffodil_Thursday
Member Avatar for ceyesuma
Member Avatar for sivaprakashm

If it's redlined the import then Eclipse can't find that class - check your classpaths and project settings to ensure the class is findable. The "cannot be resolved" error follows on from this one.

Member Avatar for JamesCherrill
0
185
Member Avatar for revenge2
Member Avatar for extemer

You can't do a switch on a char array. The Language Refeence says: The type of the Expression must be char, byte, short, int, Character, Byte, Short, Integer, or an enum type. THere was a recent thread here about doing a switch on String values - look it up. ps: …

Member Avatar for extemer
0
256
Member Avatar for thompsonSensibl

Make each screen an independent JPanel and use a common "data" object to hold all the values that are displayed or entered via the panels. The panels use the data objects get methods to retrieve the info to display in their constructors, and the set methods to update the object …

Member Avatar for thompsonSensibl
0
111
Member Avatar for sharathk60

Your int DAY_OF_WEEK is just the "code" value used in Calendar to refer to the day-of-week field. You then need to get that particular field from your Calendar using the get(int field) method. ps: using a switch like that will work, but it's a pretty horrible way to do it. …

Member Avatar for JamesCherrill
0
118
Member Avatar for xzero_x

[QUOTE=NP-complete;1232739]a Every class implements those two anyway. [/QUOTE] Sorry, but that's wrong. Object, for a start, implements neither. Although many popular classes implement either or both, there are many important classes that don't.

Member Avatar for NP-complete
0
90
Member Avatar for Ajantis

a is a divisor of b iff (b%a == 0) I have no idea how (or why) you would do this recursively - you just need a loop to try all values of a from 1 to sqrt(b)

Member Avatar for Ajantis
0
83
Member Avatar for electricrain

1. Create a class Person with name, phone etc and the associated accessors and validation. 2. Create a class PhoneBook that contains a Collection of Persons, with methods to search / add a new Person etc 3. Create a class Test with a public main(...) method to create some Pesons, …

Member Avatar for JamesCherrill
0
632
Member Avatar for idlackage

I don't have time to spell this out right now, but here's the short version. You need to create your own change Listener - just like the slider defines an interface and allows you to add listeners with that interface, and calls ithem when the slider changes - you do …

Member Avatar for JamesCherrill
0
526
Member Avatar for johndoe444

The "final" keyword is essential here. The compiler knows that the value assigned to the variable can not be changed, so its value can be used in the inner class even after the method has terminated.

Member Avatar for JamesCherrill
0
102
Member Avatar for mani.mani

"Proper" way: Use the GregorianCalendar class (and the methods it inherits from Calendar) to get the year/month/day/hour/minute as required so you can test for equality at whatever level of precision you need. "Quick & dirty" way: get the time in millisecs for each date, subtract one from the other and …

Member Avatar for JamesCherrill
0
83
Member Avatar for adrianniebla

Exactly what error message do you get on exactly which line? Also: you carefully test for temp == null just before attempting temp.info - null pointer perhaps?

Member Avatar for JamesCherrill
0
209
Member Avatar for redZERO

You would typically have mutliple JFrames and chain from one to the other, BUT not pass all the info down the chain. Use the MVC pattern and keep all the info in a "model" class (or classes) that the GUI can call via standard get(...)/set(...) or add(...) methods. Each piece …

Member Avatar for tizon
0
138
Member Avatar for kesh1000

jwenting is right, and you are wrong about not being able to use it in your dialogbox. But anyway, you can check if something is null like this: [CODE]if (resultset == null) { System.out.println("No records found"); } else { // do whatever it is you wanted to do with the …

Member Avatar for kesh1000
0
338
Member Avatar for zigana91

Looks like you have an extra dot between import and java. "Identifier means a name, such as java.text or String, or i "Identifier expected" means you have some piece of punctuation such as ;{(. etc where you should have an identifier.

Member Avatar for naziatarannum
0
98
Member Avatar for gymangel812

Just put them in a new class : [CODE]public class Serialiser { public static byte[] serializeObj(Object obj) // etc [/CODE] then call them from any other class like this: [CODE] byte[] bytes = Serialiser.serialiseObj(myObject);[/CODE]

Member Avatar for JamesCherrill
0
109
Member Avatar for GökhanBarış
Member Avatar for Adhoc82

Did you import the movie (ps should be Movie) class in the second .java file? Update: parallel post with javaAddict - he's right!

Member Avatar for Adhoc82
0
9K
Member Avatar for lich

[QUOTE=lich;1226799]can you please provide me a sample code. about the timer and the timer runs out[/QUOTE] There's lots of examples on the web. Why do you think someone should write a new one just for you? Google is your friend.

Member Avatar for JamesCherrill
0
163
Member Avatar for lich

I guess you've seen this? [url]http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_java.html[/url]

Member Avatar for JamesCherrill
0
168
Member Avatar for Mr. Blank

Have a look at the methods that JButton inherits, such as setHorizontalAlignment(...)

Member Avatar for Mr. Blank
0
94
Member Avatar for becdudek

Is the error message referring to this method's code or the method that calls it?

Member Avatar for becdudek
0
106
Member Avatar for Monzers

You create a new instance with something like: Circle c = new Circle(2.0);

Member Avatar for JamesCherrill
0
272
Member Avatar for jephthah

Sorry guys - I may be a bit geriatric but I don't need 1/2 inch high lettering just to compensate for the garish colours. And please reinstate the poster's reputation and solved thread count info on posts - it's the only easy way to see whether that person knows what …

Member Avatar for Dani
8
2K
Member Avatar for regg

When reading files from a jar the file name is case-sensitive, "sentence" != "Sentence". You could double check that.

Member Avatar for regg
0
1K
Member Avatar for pradeep_09

quuba's suggestion is OK, it will work, but it ties the external representation of the button text to the internal functions of the code, which is not ideal as a programming technique. (What happens when you do the Japanese version?) If you want to do this the "professional" way, all …

Member Avatar for n88y
0
198
Member Avatar for OffbeatPatriot

Yoiu may find these useful: [url]http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#getPackage%28%29[/url] [url]http://www.javaworld.com/javaworld/javatips/jw-javatip113.html[/url]

Member Avatar for ~s.o.s~
0
179
Member Avatar for garnier4i

Your processWindowEvents won't be called because you have not enabled window events nor registered a listener. See: [url]http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Window.html#processWindowEvent%28java.awt.event.WindowEvent%29[/url]

Member Avatar for JamesCherrill
-1
110
Member Avatar for evak77
Member Avatar for JamesCherrill
0
50
Member Avatar for gymangel812

[QUOTE=moutanna;1215788]This is olso wrong: [CODE] SecurityAlarm[] alarm = (new FireAlarm("kitchen", 120.0), new EntryAlarm("rear entrance",10), new COAlarm("furnace room", 130) ); [/CODE] the is no constructur in the SecurityAlarm superclass. Hope it helps.[/QUOTE] moutanna: why do you think the SecurityAlarm class needs an explicit constructor?

Member Avatar for JamesCherrill
0
114
Member Avatar for pankajagar2002

Before asking here you could have looked up "Creation of New Class Instances" in the Java Language Specification.

Member Avatar for pankajagar2002
0
141
Member Avatar for softdev

In principal: yes, although the absence/presence of a "throws" declaration in the method signatures determines whether the Exception is propogated.

Member Avatar for JamesCherrill
0
98
Member Avatar for lilpinay

Instead of the tortuous [CODE] return Double.longBitsToDouble(0x7ff8000000000000L); //0x7ff8000000000000L is the Java constant for NaN (Not-a-Number[/CODE]) why not use the simple and clear [CODE]return Double.NaN;[/CODE]

Member Avatar for JamesCherrill
0
173
Member Avatar for handrews3583

You are heading in a decent enough direction (there's too much code (eg collection of student names) in main that should be in the Grades class, but don't worry about that yet) - have you tried executing your code? There's enough here to try a run and (probably) generate some …

Member Avatar for otherdummy
0
3K
Member Avatar for Bemani_lover

The superclass is Bird, which doesn't have a constructor that just takes a name as the only parameter. (it's public Bird(String aName, String aBreed))

Member Avatar for Bemani_lover
0
112
Member Avatar for Protoroll

Line 12 you are looking for a String "Song 1" in the ArrayList, but the ArrayList contains Track objects. (Ditto line 7 of final code). ps Java 1.5 enhanced for-each loop: [CODE]int i = 0; while (i < tracks.size()) { if (tracks.get(i).getRating() == Track.MAXIMUM_RATING) maxRatingTracks.add(tracks.get(i)); i++; }[/CODE] becomes: [CODE] for …

Member Avatar for Protoroll
0
233
Member Avatar for rogue005
Member Avatar for JamesCherrill
0
77
Member Avatar for CF019

Without access to the source of that class (see above) you can still just try coding a for-each on it and see if it compiles!

Member Avatar for JamesCherrill
0
123
Member Avatar for pankajagar2002

You should assume that all API methods are not thread safe unless the javadoc explicitly says they are. (Although in this particular case it's difficult to see what thread problems there could possibly be - the method has no side effects and doesn't update anything.)

Member Avatar for ~s.o.s~
0
1K
Member Avatar for sunillakhiyani

You could try Googling "type object pattern". I did, and got a load of hits (of which the fifth was this very thread!).

Member Avatar for sunillakhiyani
0
81
Member Avatar for cherryduck

Which line generates the array index exception? ps: line 22 should read <= 255 (althought new int arrays are initialised to all zeros anyway) pps Shouldn't you re-initialise count around line 42?

Member Avatar for cherryduck
0
184
Member Avatar for fuser

The setText method replaces any existing text, so you only see the result of your very last setText. Try append(...) instead.

Member Avatar for JamesCherrill
0
116
Member Avatar for jaredleo999

Interesting conversation, may I join in please? BJSJC: your statement about "only one thread" in posts #4 and #6 is wrong, there's also the EDT, as you note later. moutanna's post #7 is very misleading. The listener method is NOT called "inside the button"; the method is running on the …

Member Avatar for BestJewSinceJC
0
4K
Member Avatar for m1dnight

You could use instanceOf to see which subclass each Question is, then cast the Question to that subclass. after which you can access the subclass methods

Member Avatar for JamesCherrill
0
96
Member Avatar for 05026652

Maybe bad naming? safeOpen seems to mean safeLocked in some of the methods, but is used redundantly for the inherited open variable in others. (And the unlock method needs to check the combination before unlocking.)

Member Avatar for JamesCherrill
0
171
Member Avatar for tones1986

You often get "stream corrupted" during debugging when a previous test crashes part way thru and the socket/stream is left open and part-written or part-read. It's worth checking that there are no instances of the JVM still running from failed tests before starting the next test. ps: You shouldn't have …

Member Avatar for JamesCherrill
0
354
Member Avatar for tyson.crouch

I agree. Define an oject that corresponds to a single row of the data table (with instance variables of the appropriate type for each field) the read the table into an ArrayList of those objects.

Member Avatar for javaAddict
-1
345
Member Avatar for elSifa

elSifa: please share your solution with us - I for one would certainly like to know the answer!

Member Avatar for quuba
0
2K

The End.