7,116 Posted Topics

Member Avatar for Acegikmo

You normally only need an ImageObserver when you are loading an image asynchronously and need to know when it's finished loading (eg in a web page). Once the Image is loaded you just need the Image itself (or a suitable public method in the class that "owns" the Image). ps …

Member Avatar for Ezzaral
0
197
Member Avatar for Majestics

And again. This zombie is 2 weeks old. Majestics is unlikely to be still waiting for an answer, and even less for a poor one like that (ProcessBuilder effectively replaced Runtime.exec). Please do NOT resurrect zombie threads.

Member Avatar for JamesCherrill
0
101
Member Avatar for s.w.a
Member Avatar for mklein

Create a small class to handle the click. Have a constructor for that class that takes an int as parameter and saves its value. Crate a new instance for each JLabel, with the JLabel's index as parameter. Now when you handle the event you have the index of the JLabel …

Member Avatar for JamesCherrill
0
307
Member Avatar for kukuruku

Looks like a suffix to indicate multiple values for something basic values are m and n, second values are m1, n1 (etc) - like an array with the little 1 as the array index.

Member Avatar for JamesCherrill
0
77
Member Avatar for matadori

So what is the requirement? A grid of jThings that can be clicked by the user and can display icons that change as the game progresses? Either JButton or JLabel will do that for you, although the JButton syntax is more natural for something that can be clicked but not …

Member Avatar for JamesCherrill
0
135
Member Avatar for matadori

Are you certain the statement on line 25 is being executed? (it looks OK to me). It may be a problem with your button numbers; you test for 3 and 1, but here's what the API Java|Doc has to say about getButton()... [QUOTE]The values for button range from zero to …

Member Avatar for mKorbel
0
2K
Member Avatar for bhdas1
Member Avatar for man in a can
Member Avatar for JamesCherrill
0
102
Member Avatar for 24x24

What are the symptoms you are getting? - you don't actually describe the problem anywhere. Does your animation loop actually call the method to test for collisions after calling move?

Member Avatar for 24x24
0
326
Member Avatar for tracydo

You are passing the value 4 OK, but that's not the right way to get the returned value. Check out your course notes for an example of calling a method that has a return value.

Member Avatar for SMITA6076
0
512
Member Avatar for pseudorandom21

FWIW I've used Eclipse for quite a few years now and am very happy with it. If I need something that's not in the basic package then there's bound to be a plugin for it. There's a bit of a learning curve over how files in the IDE relate to …

Member Avatar for peter_budo
0
301
Member Avatar for AnkitKumar

All constructors automatically call the immediate superclass's no-args constructor [I]super()[/I] as the first line, unless you code an explicit call to a constructor of the immediate superclass yourself as the first line of your constructor. If no constructor is defined for a class, the compiler creates an empty no-args constructor, …

Member Avatar for stultuske
0
350
Member Avatar for kubiak

Hi kubiac The point you may be missing is that the color isn't associated with the font directly. The font defines shapes that need to be drawn, but they are drawn using the foreground color for the place where they are being drawn. So, for example. if you are using …

Member Avatar for kubiak
0
95
Member Avatar for CrazyPixel

Am I right in thinking that you convert 1 char to a NINE char String (8 1/0s and a blank), but try to parse them back as 8 binary chars / char. Catching an exception and throwing away the exception message is just dumb. At the very least print it …

Member Avatar for NormR1
0
161
Member Avatar for Krazykado

You could concatenate all the names & grades into one String, with \n chars after each line, then display that String names[1]+ " " + grades[1] + "\n" + names[2]+ " " + grades[2] + "\n" + ... etc (but build it in a loop, obviously)

Member Avatar for JamesCherrill
0
137
Member Avatar for persianprez

[CODE]GameBoard b = new GameBoard (); ... frame.getContentPane().add(b);[/CODE] Apart from the anachronism of the getContentPane() - not needed for years now - the driver adds an instance of GameBoard to a JFrame. Check out JFrame's (or content pane's) add method - what kind of objects can you pass as the …

Member Avatar for JamesCherrill
0
137
Member Avatar for tultul

Hi. What kind of info (exactly) do you want to put in your setup file? Suppose it was just a simple text file - give us an example of how a typical file might look.

Member Avatar for JamesCherrill
0
233
Member Avatar for Diogo Martinho

Unless I've misunderstood the question here, the only strategy choice is push vs pull, ie do you recalculate the price every time you update the details, or just update the contract details, then recalc the price only when you want to display it. I don't think the Gang of Four …

Member Avatar for JamesCherrill
0
109
Member Avatar for alabn22

RMI involves a big learning curve and quite a lot of code. IMHO it's not appropriate unless you have identified a need that requires that kind of power, flexibility, and client/server integration. If you just have a small number of fixed messages ("I'm employee 1234, can I come in please?" …

Member Avatar for alabn22
1
130
Member Avatar for Dean_Grobler

You can use Reflection to execute a method given its name in a String. Something along the lines of: [CODE]import java.lang.reflect.Method; public void invokeByName(String name) throws Exception { Method method = this.getClass().getDeclaredMethod(name); // throws NoSuchMethodException if method is not found method.invoke(this); // may throw IllegalAccessException,IllegalArgumentException, InvocationTargetException }[/CODE]

Member Avatar for JamesCherrill
0
290
Member Avatar for hfx642

Is this just a theoretical question, or is there some particular problem that you are trying to solve? If so, there may be other better ways to approach it.

Member Avatar for hfx642
0
475
Member Avatar for kanhakv

Post your code (in code tags) and the full text of the error message (including line number) and someone will take alook.

Member Avatar for kanhakv
0
604
Member Avatar for solomon_13000
Member Avatar for MeandJava

What you really need is a switch statement using a String expression. Unfortunately you'll have to wait for Java 7 to get one. Until then you can set up an enum with all the cases, convert the input String to enum with valueOf(...), then switch on the enum. IMHO this …

Member Avatar for JamesCherrill
0
507
Member Avatar for jinglylime

You need to return a variable that holds an array of Rectanges. Rectangle[] isn't a variable. Think now - what is the variable that holds your array of Rectangles?

Member Avatar for jinglylime
0
112
Member Avatar for chad33

String diverName = fileLine.substring(0,fileLine.indexOf("-")); String strScore = fileLine.substring(fileLine.indexOf("-")+2, fileLine.length()); Guess what happens if there is no "-" in any particular line. ;-)

Member Avatar for JamesCherrill
0
248
Member Avatar for sirlink99

Java 1.6 includes the "Desktop API" that includes stuff like opening a web page in the system browser. [url]http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/desktop_api/[/url] So I have to disagree with both previous posters - it's definitely not dead, and the truly horrible 2001 code example is totally obsolete.

Member Avatar for ceyesuma
0
217
Member Avatar for dangari

Since Java 1.5 the preferred way to run external processes is the new ProcessBuilder class. You may find that simple switching to that will improve things [url]http://www.java-tips.org/java-se-tips/java.util/from-runtime.exec-to-processbuilder.html[/url]

Member Avatar for mKorbel
0
1K
Member Avatar for gingerfish

If the things are in any kind of Collection you can use addAll(Collection c), If it''s an array you can use Arrays.toList(...) to convert the array to a List that you can pass to addAll [QUOTE]but is there a way to add things into arraylist iteratively one by one? [/QUOTE] …

Member Avatar for JamesCherrill
0
167
Member Avatar for I<LateNupurGuha

If you provide no explicit initialization to instance variables, they will be given default initial values, which are based only on the type of the variable (zero, false or null as appropriate). Local variables are not given default initial values. They must be initialized explicitly before they are used. The …

Member Avatar for jon.kiparsky
0
155
Member Avatar for gingerfish

Its the same as int except that it holds very much larger numbers For int, from -2147483648 to 2147483647, inclusive For long, from -9223372036854775808 to 9223372036854775807, inclusive You use it whenever you want an integer value that may be bigger than the largest int

Member Avatar for gingerfish
0
151
Member Avatar for \007

Java variables come in 2 flavours, primitives (eg int, char, byte, float, boolean - all lower case names) and reference variables (which you can think of as pointers). All variables of array or Object types are reference variables. So, in your code message_one and message_two are reference variables of type …

Member Avatar for \007
0
121
Member Avatar for Dean_Grobler

[QUOTE]Do you think that if I upgrade my JDK/JRE to the latest release it might solve the issue? [/QUOTE] It certainly can't do any harm, and you'll get the latest security and bug fixes. So yes, update.

Member Avatar for mKorbel
0
270
Member Avatar for tultul

Where's the code that updates the data from the database? Your structure should be: timer actionPerformed updates data objects and calls repaint() for the GUI paintComponent(...) does the minimum needed to keep the GUI in step with the data objects.

Member Avatar for tultul
0
130
Member Avatar for Buffalo101

As a general rule of OO design, you shouldn't have one class getting involved with the internals of another. It entangles them to the point where you dare not change one for fear of breaking the other - exactly the opposite of how it should be. Without details of your …

Member Avatar for mKorbel
0
2K
Member Avatar for kris0r

There's a standard way to do this: 1. Change the WebCrawler constructor to take an instance of CrawlAnalyseGUI as a parameter - so line 15 will read [B]final WebCrawler crawler = new WebCrawler(this);[/B] Now the webcrawler has a reference to the GUI. 2. Add a public method to CrawlAnalyseGUI that …

Member Avatar for JamesCherrill
0
160
Member Avatar for Buffalo101

Normally, as each client connects, you start a new Thread to handle I/O from that one client. You end up with one thread waiting for new connections, plus 1 thread per client waiting for I/O (plus threads for GUI etc).

Member Avatar for JamesCherrill
0
240
Member Avatar for sirlink99

@Mattox. Sorry, but both your suggestions are poorly thought out. move++ in the paintComponent method means that the box will move every time paintComponent is called. You have no control over how often that is, so the moves are unpredictable, and certainly have nothing to do with the space bar. …

Member Avatar for JamesCherrill
0
991
Member Avatar for MWE_QUE

AFAICS you have a text area in which you put the complete text of a menu. You then get that complete text back into a String, then try to parse the whole thing as a single integer. Obviously it's not just an integer, so Exception. This is more than just …

Member Avatar for MWE_QUE
0
319
Member Avatar for thebigbroski
Member Avatar for Nirmeen Ased

Assuming that a b and c are all the same length... you want every element of c to be the sum of the corresponding elements in and b. Is that right? Here's a hint. you need exactly one loop.

Member Avatar for Nirmeen Ased
0
103
Member Avatar for tracydo
Member Avatar for cretaros

java.util.Calendar allows you to add days, or months, or years, just like you asked. But if you have to do this yourself, then yes, just add 5 to the year part and leave the month and day alone* * unless, of course, the start date is 2012-02-29

Member Avatar for mKorbel
0
291
Member Avatar for NewOrder

The "buffer" is a byte array that is allocated like any other Object in the Java VM's memory. Because all the methods are accessing data in memory, they are fast.

Member Avatar for JamesCherrill
0
108
Member Avatar for bharath54321

Use a JDialog for the subframe - you can control its modality to block all input to other windows in your app while its open (and other variants)

Member Avatar for mKorbel
0
107
Member Avatar for qweewq22

Problem is: You declare [I]DefaultListModel dmodd2=new DefaultListModel();[/I] inside your ActionPeformed. This creates a new dmodd2 that exists only for the duration of your method, and "hides" the dmodd2 that you defined earlier. So your [I]dmodd2.remove(index);[/I] applies to the new temporary dmodd2, not the "real" one. Just remove the incorrect declaration.

Member Avatar for JamesCherrill
0
163
Member Avatar for jackmaverick1

Maybe: Create a dummy/stub version of a user created extension(ie with all the right class name & method signatures, but empty methods). You'll need this to compile your own program anyway (unless you get into heavy lifting with Reflection). When you build your distribution package, keep the .class file for …

Member Avatar for jackmaverick1
0
223
Member Avatar for NPDA

Chesk the JavaDoc.. What type does readLine() return? What type is your variable num? That's why you get the error message. Which method in the same class as readLine() returns an integer? That's the one you need.

Member Avatar for JamesCherrill
0
91
Member Avatar for Devildawgg

Line 38 you increment examScores, but line 42 you print count. I don't understand what line 38 is supposed to be doing anyway, but incrementing count here would be as good idea

Member Avatar for Tarkenfire
0
373

The End.