7,116 Posted Topics

Member Avatar for acplayer

Beware the trap of confusing a reference variable (ob) with the object it happens to refer to at any particular time. How is ob declared? If its declared as type B then you shouldn't need to do anything. ob can refer to an object of class B or C, and …

Member Avatar for JamesCherrill
0
77
Member Avatar for komal_asrani

This info is already on the web. Start with [url]http://java.sun.com/docs/books/tutorial/2d/images/[/url]

Member Avatar for JamesCherrill
0
32
Member Avatar for weblover

Because a Stack can contain any kind of Objects, of unlimited complexity, there's no sensible way to provide a generic "print" method that would work usefully for everything that could be in the stack. Hence all the previous advice saying that you have to loop thru all the elements in …

Member Avatar for weblover
0
206
Member Avatar for titosd

TreeMaps are held sorted by key, so if you want to see the values sorted in some other order you need to get the values as a simple collection teams.values() and then use Collections.sort to sort it using a custom comparator that compares raceTeams by their names.

Member Avatar for titosd
0
88
Member Avatar for kakakon
Member Avatar for KirkPatrick

There's not enough info to be sure, but at first sight it looks like you should have a class Fruit, with name, shape and colour as instance variables. As you read the two files you could create the instances. Displaying the three values together is now trivial - just pass …

Member Avatar for ~s.o.s~
0
97
Member Avatar for exzibit23

[QUOTE]is it possible to use try catch exception inside while loop?[/QUOTE] Yes. You often see this in cases where you want to re-try something that may fail (throw an Exception).

Member Avatar for ~s.o.s~
0
4K
Member Avatar for kimbokasteniv

It depends on why you are displaying the level - if it's to ensure the signal is loud enough, you can just pick a subset of the samples (say 10 / sec) and average them. If you're trying to avoid clipping you need to check every sample and keep the …

Member Avatar for kimbokasteniv
0
215
Member Avatar for grisha83
Member Avatar for grisha83
0
220
Member Avatar for nagachaitanya

Create a parent class Daniweb, with one method "help me with my homework" which takes two parameters: problemDefinition and whatIDidSoFar. If the second parameter is null, throw a NoHelpWithoutEffort Exception

Member Avatar for JamesCherrill
0
115
Member Avatar for Ankita B

If you are going to save session info in the HTML you should also set a timestamp and check for expiry. Otherwize someone could log in, then save a favourite. That favourite would then work weeks later without another login.

Member Avatar for deepak_8917
0
171
Member Avatar for smoore

4. Only real difference is that Vector is synchronized, ie it's automatically safe to use in a multi-threaded app. ArrayList isn't. ps: You may not think you have a multi-threaded app, but if you use Swing, then you do.

Member Avatar for smoore
0
145
Member Avatar for Xessa

Looks like a font issue to me. Unicode is unicode, and there's no way you are going to stop Java using it, but different fonts display different subsets of it, and can be quite inconsistent once you get past 7F

Member Avatar for JamesCherrill
0
71
Member Avatar for brandongood

Despite what what you think, your code is NOT implementing dorien's algorithm. Check your second loop again.

Member Avatar for brandongood
0
93
Member Avatar for brandongood

If the max value required is 2^31 this will fit in an int. 2^31+1 won't.

Member Avatar for brandongood
0
87
Member Avatar for suncica2222

Is the whole idea to avoid having a try/catch? In which case you can just put those around a wait() in a MakePause class and handle the exceptions there. Timers will start another task after a certain time, but not do the pause you want.

Member Avatar for JamesCherrill
0
117
Member Avatar for weblover

You could lat the function set a public boolean when it's called, then you can check that later?

Member Avatar for weblover
0
98
Member Avatar for dev.mena

Are you really sure that this is a problem? Processing buffers at the server will take negligible time compared to the transmission times to the clients. Unless you are using some kind of broadcast technology the data still has to be sent to each client, so where will you reduce …

Member Avatar for JamesCherrill
0
111
Member Avatar for mintsmike

Is your method being called when you resize the component? Just setting the preferred size doesn't necessarily mean that the component [B]will [/B]be resized. Depending on what layout manager you are using you may need to set the minimum, maximum and preferred sizes to get the result you want.

Member Avatar for mintsmike
0
318
Member Avatar for scream2ice

You'll probably have to read the file into the table when the app starts, and re-write the edited data back at the end. You can do direct-access in-place updates of a file, but it's not easy or particularly safe - not recommended. Where does the map come into it?

Member Avatar for JamesCherrill
0
99
Member Avatar for stewie griffin

You can use an anonymous inner class. Something like: [CODE] new Thread(){ public void run() { // some lines of code } }.start();[/CODE]

Member Avatar for stewie griffin
0
103
Member Avatar for Metahuman

Calendar is an abstract class, so it's designed and built to be extended (the concrete sub-class you normally use is GregorianCalendar). You should be able to have some fun extending it for a custom calendar, although the JavaDoc doesn't have enough info to tell if you can safely change things …

Member Avatar for JamesCherrill
0
97
Member Avatar for Mubo

One class for nodes(personName), one class for edges(node1, node2, weight) . Analysis class with methods to traverse the graph to find what you're looking for. Start with a really trivial case and work upwards. Just get stuck in and see how it goes.

Member Avatar for JamesCherrill
0
144
Member Avatar for MasterGoGo

Read every line but ignore every other one - ie read/read/print/read/read/print etc

Member Avatar for Ezzaral
0
110
Member Avatar for mastr924

You shouldn't try to call paintComponent like that, only in the context of overriding paint(...) or somesuch where you already have the Graphics context and Swing knows that you're doing it. If you want to force a repaint call repaint().

Member Avatar for Ezzaral
0
93
Member Avatar for coolbuddy059
Member Avatar for wslatter

Whether you have an array, linked list, or any other kind of collection, you are only talking about the way the [B]references [/B]to the rooms are stored. Java references use no noticeable memory compared to the Objects themselves, so your friend should not worry. Chose your array/list etc based only …

Member Avatar for JamesCherrill
0
86
Member Avatar for lloydsbackyard

Stephen: just a quick aside - how did you get the java tags into your message without them being interpreted as java tags?

Member Avatar for masijade
0
141
Member Avatar for praveenrajmat

If you can render the file into a Java window, then you can also print it. see [url]http://java.sun.com/docs/books/tutorial/2d/printing/[/url] So this come down to asking "what file types can you display on Java?" PDFs can be displayed using Adobe's own free Java pdfviewer. For MS word docs you'll need to search …

Member Avatar for JamesCherrill
0
170
Member Avatar for bharatshivram
Member Avatar for leverin4

What thread does your findNext run on? Is it on the Swing thread (started in reponse to a user input)? Real-time UI updates like this typically fail because the "worker" code is running on the Swing thread and thus blocks Swings normal UI activity until it finishes. Sleeping doesn't help …

Member Avatar for VernonDozier
0
241
Member Avatar for fwso

This may sound trivial, but... write Java programs! Pick areas of Java you are unfamiliar with and develop an app using them. You'll learn an awful lot that way, and it will be 100% useful stuff you're learning.

Member Avatar for peter_budo
0
323
Member Avatar for Logi.

[QUOTE=masijade;883176]P.S. Two full-fledged Frames in an application is [i]usually[/i] a mistake. Especially when one is opened as a result from the other. [i]Usually[/i] that "second" Frame should be a Dialog (i.e. extend JDialog rather than JFrame in the "second" Class).[/QUOTE] Very interesting. Why is that?

Member Avatar for masijade
0
102
Member Avatar for shakeelahmed22

[I]throws [/I]appears as part of the declaration of a method. It tells you that when you call that method the named Exception may be thrown by that method, and that you need to handle it in some way.

Member Avatar for shakeelahmed22
0
111
Member Avatar for freelancelote

Short version: If you refer to a class in a package, the JRE will search all the directories in the current classpath for a folder or jar with the same name as the package, then search in there for the class. So your classpath must reference the folder/directory that immediately …

Member Avatar for JamesCherrill
0
197
Member Avatar for Gman36

Your code looks 100% OK to me. If the magpie gets the right int "before the squirrel has put it", then this implies that things are working OK - otherwize the magpie would just get the previous int twice. Maybe when the magpie gets the int it should reset seq …

Member Avatar for kvprajapati
0
114
Member Avatar for RupeshParajuli

Looks OK to me apart from nextInt being a method, and thus needing a pair of (). You should always try compiling before posting here, most Java error messages are pretty informative, and you should be able to fix many of the problems yourself.

Member Avatar for shantechi
0
491
Member Avatar for redZERO

Small error in your thinking: you don't paint a layer - you just paint the things in the JLayeredPane and the "layers" determine which things get painted on top of which. So, you can simply add three things (eg JLabels) to the JLayeredPane, setting their depths appropriately, then override the …

Member Avatar for JamesCherrill
0
231
Member Avatar for Virux

Also note that resource names in jars are case sensitive, windows file names are not.

Member Avatar for JamesCherrill
0
85
Member Avatar for Majestics

Maybe you can use the java.awt.Robot class. This was intended for automating tests of a GUI, and allows you to post mouse and keyboard events directly onto the host operating system's event queue. [url]http://java.sun.com/j2se/1.6.0/docs/api/java/awt/Robot.html[/url]

Member Avatar for Majestics
0
155
Member Avatar for keppy

Continuing from what Vernon said - to display an object (account) in a GUI you need a reference to that specific object, which typically comes from (a) a prior bit of GUI where you select an account or (b) the object itself if it decides it wants to be displayed. …

Member Avatar for kvprajapati
0
103
Member Avatar for MasterOfDevil

You could use a server application at one end, client at the other. Transfer a load of (random?) data from one to the other and see how long it takes. Java has full support for making connections across a network, start with a look at Sockets and ServerSockets in the …

Member Avatar for Gasper11
0
63
Member Avatar for apocalypshiit

Quite a few people have tackled the same task and discussed various problems and solutions relating to it here. Just look.

Member Avatar for apocalypshiit
-1
77
Member Avatar for cathy dow

A robust program won't break easily. It will check for and handle all kinds of user and other errors without crashing. A simple example: it may prompt the user to enter a number; a non-robust program will fail if the user enters "a", a robust program will diagnose the error …

Member Avatar for JamesCherrill
0
83
Member Avatar for suretd

Apart from all the issues around accesors, the if statement fails because the thing in the brackets ater the "if" must evaluate to a boolean true/false. Your code[icode] if(!student.setCreditHrs(hrs))[/icode] will only work if setCreditHours returns a boolean value.

Member Avatar for BestJewSinceJC
0
271
Member Avatar for brandongood
Member Avatar for brandongood
0
415
Member Avatar for bokz06

In getSubTaught() you loop thru all the members of the array, regardless of how many have actually been populated. You only set element [0], so when the loop hits element [1] you get a null pointer.

Member Avatar for bokz06
0
7K
Member Avatar for javaman2

Post with [code=java] because the colour coding will help. At a quick glance looks like you missed the final } on the main method before starting the next method definition. (ps: getHandValue should be a method in the Hand class, don't you agree?). Please don't try to combine your classes …

Member Avatar for JamesCherrill
0
509
Member Avatar for JamesCherrill

Suns Java style rules specify that accessors should follow the getX/setX pattern, and most Java API mathods follow this... except for some very common exceptions such as: String length() enum name() [NB new to 1.5, not a legacy!] ArrayList size() etc It seems that there is another pattern operating here: …

Member Avatar for JamesCherrill
0
159
Member Avatar for caps_lock

Do you mean prints nothing, or just "c:"? Because your code just seems to print the results of the listRoots. You do call listFiles, but you do nothing with it.

Member Avatar for caps_lock
0
161

The End.