7,116 Posted Topics
Re: 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] | |
Re: [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] | |
Re: 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 … | |
Re: 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 … | |
Re: Write the new entry as a .reg file to a temp directory then execute it using regedit via ProcessBuilder? | |
Re: 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)? | |
Re: 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] | |
![]() | Re: 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 … |
Re: 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 … | |
Re: 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 … | |
Re: You're not asking anyone to do your homework for you, are you? You know that's a no-no. | |
Re: "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 … | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: [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 … | |
Re: 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 … | |
Re: 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())? | |
Re: [url]http://www.java-samples.com/showtutorial.php?tutorialid=236[/url] | |
Re: 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 … | |
Re: 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). | |
Re: 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. | |
Re: 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. | |
Re: Get their positions and use Pythagorus' theorem. | |
Re: 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 … | |
Re: 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, … | |
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: 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 … ![]() | |
Re: 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 | |
Re: [url]http://www.daniweb.com/forums/announcement8-2.html[/url] | |
Re: 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 … | |
Re: 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. | |
Re: 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))); | |
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: 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) | |
Re: 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 … | |
Re: Beware, Java characters like 'U' are 16 bits; they are not bytes. | |
Re: 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 … | |
Re: [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 … | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: [url]http://www.javabeat.net/cert/scjp-1-5/scjp-exam-voucher.php[/url] |
The End.