7,116 Posted Topics

Member Avatar for gedas

You can use a boolean variable to tell you whether this is the first pass of the loop, eg [CODE] boolean isFirstPass = true; while (... ) { .. if (isFirstPass) { // do stuff that you only want to do on first pass isFirstPass = false; } }[/CODE]

Member Avatar for gedas
0
100
Member Avatar for TheWhite

[url]http://commons.apache.org/lang/api-release/org/apache/commons/lang/StringEscapeUtils.html#unescapeHtml%28java.lang.String%29[/url] [url]http://mindprod.com/products1.html#ENTITIES[/url]

Member Avatar for JamesCherrill
0
202
Member Avatar for Poopster01

1. Your print expression has one correct + operator, but it needs two! 2. You define and create your arrays inside the loop, so each iteration of the loop creates and destroys a new set of arrays. You need to define and create them before starting the loop so that …

Member Avatar for Poopster01
0
335
Member Avatar for mukorera

Lets not give up so soon! Under Vista and Win 7 there is a system API for this which is very easy to access via JavaScript. Under Java 6 it's very easy to embed JavaScript. I'm betting you can call afew lines of JavaScript directly from a Java method to …

Member Avatar for mukorera
0
96
Member Avatar for softswing

Write the new entry as a .reg file to a temp directory then execute it using regedit via ProcessBuilder?

Member Avatar for JamesCherrill
0
72
Member Avatar for manish250

That doesn't look like the exception is thrown until after the System.println on line 6, so maybe it's not the split that is the prolem. What is the [B][I]exact complete [/I][/B] exception message (including the line number)?

Member Avatar for manish250
0
2K
Member Avatar for ahmed_fawzy

The language reference material has all the details [url]http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3[/url]

Member Avatar for JamesCherrill
0
151
Member Avatar for draven07

Just a guess, but... maybe your unhelpful "mentor" is suggesting a 2x3 array to hold your data ie { { first swipe card no, account 1 balance}, { second swipe card no, account 2 balance}, { third swipe card no, account 3 balance} } ... even so a byte array …

Member Avatar for JamesCherrill
0
92
Member Avatar for Amillia89

You can't call a constructor like that - it's implicit in new Main(...). I'm confused about your two constructors (not to mention the initialisation code in the main(...) method). Do you want to execute all the code in both of these when instantiating a new Main? If not, when do …

Member Avatar for JamesCherrill
0
147
Member Avatar for kennyrgz

Sounds reasonable. Maybe an array of chars rather than a String to make it easier to access [B]and update[/B] individual digits? Don't forget that the char '9' is number whose value is not 9! Make a start by writing the class, instance variables, and method signatures. Sketch out how the …

Member Avatar for JamesCherrill
0
142
Member Avatar for Sheena26

You're not asking anyone to do your homework for you, are you? You know that's a no-no.

Member Avatar for peter_budo
0
613
Member Avatar for carlitosway17

"has errors when it runs" is not enough info for anybody to conclude anything. You must be specific. What errors? If an Exception give whole message and line number(s). If incorrect output give expected and actual results. ps mKorbel - I'm assuming that this is a training exercise so SimpleDateFormat …

Member Avatar for mKorbel
0
189
Member Avatar for hanvyj

Just had a quick look at the source code for JComponent and JToolTip... setToolText just records the text as a clientProperty of the JComnponent - it doesn't seem to create or initialise the tooltip at that point. setTipText seems to directly set an instance variable in the tooltip itself. Maybe …

Member Avatar for mKorbel
0
1K
Member Avatar for Sheena26
Member Avatar for gunitwarriors

Looks like you only have half the program. That's a class that implements a [B][I]single [/I][/B]triangle. Somewhere else there should be some code that maintains an array or ArrayList of these Triangles, and creates the GUI element(s) in which the Triangles are to be drawn.

Member Avatar for JamesCherrill
0
79
Member Avatar for ChieftanBill

Probably a typo - should be: for (String arg : args){ It's a "for each" loop, introduced in Java 1.5. You read it as "for each String arg in args" It sets arg to the first element of args and executes the following println code, it then sets it to …

Member Avatar for JamesCherrill
0
109
Member Avatar for efrateshet

[CODE]if (stringExpo(p)==""){ ... else { result= result+stringCoef(p)+stringExpo(p); if (stringExpo(p)==""){[/CODE] Looks like the second if will always be false, since it's in an else clause following an if with the same test? Plus, the old old chestnut, you can't compare Strings with == unless you actually mean "are exactly the same …

Member Avatar for efrateshet
0
336
Member Avatar for andrasitc

You declare and initialise cetvorougao inside your mouseClicked, so every time the mouse is clicked you create a new cetvorougao, which is garbage collected at the end of the method. You need to declare and initialise it inside the class but outside any method so there is just one instance …

Member Avatar for andrasitc
0
174
Member Avatar for Akill10

Dunno if this is relevant, but why do you call checkAge() 3 times in btnClassifyActionPerformed - is it possible that it returns different values after the whatever else happens between the first and second calls (eg clearFields())?

Member Avatar for mKorbel
0
324
Member Avatar for shushi
Member Avatar for JamesCherrill
0
185
Member Avatar for java beans

masijade is right, but I think I can see where yo are going with this, using subclasses of an abstract superclass to implement different methods with the same signatures. Then instead of an array of function pointers yo have an array of objects that implement the appropriate version of the …

Member Avatar for JamesCherrill
0
418
Member Avatar for ajst

Since your method's code doesn't actually use the ActionEvent parameter, you could just call gameEndTurnBtnActionPerformed(null); from anywhere in your class (or anywhere else if you make it public).

Member Avatar for JamesCherrill
0
97
Member Avatar for WolfShield

Each of those lines uses the variable "synth" - so it's highly probable that that variable has not been initialised - which in turn suggests that line 11 (createSynthesiser) has failed at runtime. You can confirm this by printing synth immediately after line 11 to see if it is null.

Member Avatar for JamesCherrill
0
134
Member Avatar for chipsch

You really don't want to put any program logic in a paint(Graphics g) method because you have no way of knowing when or how often it will be called. The actionListener is generally a far better place for it.

Member Avatar for JamesCherrill
0
391
Member Avatar for odiejodie
Member Avatar for HardWorkingMan

1. Passing the array to your Multiples class should be trivial - so must have been some simple mistake. try again? 2. You haven't got the whole picture for using a Thread. The constructor is used to handle any parameters etc, but the actual work needs to be done by …

Member Avatar for JamesCherrill
0
2K
Member Avatar for njmm

You're almost almost there. You have 3 methods to change the colors, you have a method that's called when the button is pressed, which counts the number of presses, so all you need to do is call the appropriate color change method when the button is pressed (1st press, green, …

Member Avatar for JamesCherrill
0
147
Member Avatar for midnightdream

First problem: In main you create an array "temps" and put the data into it, in sort you have a different array "a" that you (try to) sort, but there's no connection between the two arrays! One solution would be to declare and initialise a single array that both methods …

Member Avatar for JamesCherrill
0
129
Member Avatar for techie929

Second version compiles without error for me. Indentation is still useless - here's Eclipse's version. [CODE=JAVA]class HelloWorldApp { public static void main(String[] args) { try { // Open the file that is the first // command line parameter String fname = args[0]; int x = 0; FileInputStream fstream = new …

Member Avatar for mKorbel
0
123
Member Avatar for carinlynchin

From what you describe a javax.swing.Timer would seem the best fit. Start a timer with a 3 minute countdown. When the Timer expires it calls a method of yours that handles "game over". It's as easy as that. Just try it.

Member Avatar for JamesCherrill
0
101
Member Avatar for ajayb

IMHO copy/pasting code is not a good way to start to learn Java. Even if you read it all, you will not understand why it was written that way. I recommend you start with an empty text editor and build the "hello world" app from scratch, then move on to …

Member Avatar for ztini
0
399
Member Avatar for kingofdrew

if(x>330 && x<280 && y>20 && y<20) x cannot be both >300 and <280 at the same time similarly, y cannot be greater than and less than 20 at the same time so this will always evaluate to false, for all possible values of x and y

Member Avatar for JamesCherrill
0
190
Member Avatar for vijaybrar
Member Avatar for peter_budo
0
165
Member Avatar for Barnifericus

The API reference says [QUOTE]public E get(int index) Returns the element at the specified position in this list. [/QUOTE] so it would return just element/node number 1 (which is the second node in the list - indexes start at 0) A quick look at the source code shows how it's …

Member Avatar for JamesCherrill
0
114
Member Avatar for VernonDozier

Hi Vernon I'm curious. In a single-threaded environment, apart from the "swap" method, why is it so important to have a mutable Integer class? I've gone fat dumb and happy in SmallTalk and Java for 20 years without ever feeling the need for one.

Member Avatar for VernonDozier
0
1K
Member Avatar for techie929

When you get an element of that vector, you are getting an array of ints, which prints as an incomprehensible object reference. To print those in a readable way try the arrays.toString method to format the content of each array, eg int[] arr = resultq.get(i); System.out.println(Arrays.toString(arr)); System.out.println(Arrays.toString(resultq.get(i)));

Member Avatar for techie929
0
121
Member Avatar for kukuruku

Each of the 3 cases creates a new Date object. After executing your code you will have 3 Date objects. Because you did not keep any reference to the first two you will not be able to access them again, and they will be garbage collected. The third Date object …

Member Avatar for ~s.o.s~
0
200
Member Avatar for kvass

a++ returns the value a, then adds 1 to it, so a = a++ always leaves a unchanged simply a++ will do, or a = ++a; (increments before using value) [QUOTE]The value of the postfix increment expression is the value of the variable before the new value is stored.[/QUOTE] Java …

Member Avatar for JamesCherrill
0
215
Member Avatar for BioJavaPhobic

Move the messages out of the loop: Initialse failurePoint to false, set it to true if/when you find a failure point (do not set it back to false inside the loop!), the after exiting the loop test the boolean to see which Message to display.

Member Avatar for BioJavaPhobic
0
649
Member Avatar for MrHardRock

Are you required to use BreezySwing? If not I'd forget about it and move on the "real" Swing without wasting any more time. BreezySwing just seems to be a very old set of "training wheels" from when people were still struggling with AWT before/just after Swing was released. I think …

Member Avatar for JamesCherrill
0
225
Member Avatar for alemojarro

You can't use == and != to test whether two Strings have the same sequence of letters. The == and != test whether they are exactly the same Object. Th test you need to use is the equals method... string1.equals(string2)

Member Avatar for JamesCherrill
0
178
Member Avatar for emorjon2

What you have is OK, just one thing missing... you define a "users" variable, but you don't actually create an array, so the variable just contains a null pointer. You need something like user Users = new user[99]; // creates an array with 99 slots for users nb 1 Java …

Member Avatar for JamesCherrill
0
168
Member Avatar for javanoob21
Member Avatar for JamesCherrill
0
127
Member Avatar for musikluver4
Member Avatar for villalandron

your "multiplication" method takes two ints as parameters, but throughout the main method you have just one number, so in line 25 you call multiplication with just one int. Using a program from a book can be a useful way to start, but just copy/pasting code always leads to problems …

Member Avatar for jon.kiparsky
0
184
Member Avatar for TheOnlyNemesis

[QUOTE]I wonder if it wouldn't make more sense to put your state strings into an array, indexed by state, so you don't have to return a String, you just look up the right string in your array, and life's even simpler.[/QUOTE] Looks to me like a perfect time to use …

Member Avatar for jon.kiparsky
0
213
Member Avatar for sj5536

You must supply more information - "it wont convert those text file to pdf" doesn't help. Do you get any error messages or exceptions? Creating an executable jar like that is the right thing to do,you just need to debug it a bit. Maybe it's a path problem that means …

Member Avatar for JamesCherrill
0
184
Member Avatar for Taimoor Rana

If you really want fine control of your layout, while retaining the platform-independence and re-sizing ability, the GridBagLayout layout manager has just about anything you can imagine. There's a bit of a learning curve, but it's well worth the effort. Tutorials and reference materials on the web as usual.

Member Avatar for Taimoor Rana
0
180
Member Avatar for black_berry

Your Help class has a main method that won't get called because that isn't the main method of the application. When you call new Help() that calls the Help() constructor, so you need to put ALL the code for creating and displaying the help window in that method. The only …

Member Avatar for quuba
0
349
Member Avatar for ramanak.24

[url]http://www.javabeat.net/cert/scjp-1-5/scjp-exam-voucher.php[/url]

Member Avatar for ramanak.24
0
83

The End.