7,116 Posted Topics
Re: Me too, I'm baffled. Do you really want to convert a method name (System.out.println) to an int??? You need to explain exactly what it is you are trying to do! | |
Re: That's way too much code to try to analyse just for fun. Start to load you code with lots of System.out.println statements working backwards from the point where you get the unexpected null output - sooner or later you will find the point where it all goes wrong and then … | |
Re: Even at the pseudocode level that's not going to work: firstStep = console.nextLine(); eg "ooxxx" secondStep = firstStep.replaceAll(o, x); "xxxxx" thirdStep = thirdStep.replace(x, o); "ooooo" System.out.println(thirdStep); "ooooo" This needs an extra step: replace all the o with some temp char replace all the x with o replace all the temp … | |
Re: Would be useful to know which file caused the refused access - especially if it was the output file. A few debugging print statements would help. | |
Re: @toko What you wrote applies only to versions of Java before 1.5 (apart from the bit about primitives which was just wrong). It's very misleading to post that now. @mbouster: You should ignore that, and stay with the 1.5 syntax as shown by pbl. There is normally no need to … | |
Re: Here are a few: You can use it to hack into methods that are declared private. Eg there's a popular hack to give access to the Windows registry by gaining access to the private methods used by the Preferences class to read/write the registry for its own purposes. (NB I'm … | |
Re: [QUOTE]I have a problem with this code and I do not know what is causing it.[/QUOTE] This is a joke, yes? Do you understand what a "problem description" is? If it's an NPE you could give us just the tinyest little clue to work on - like which line? | |
Re: Create a String constant "*********************************************" then use substring(0,numAster) to pick the right numbert of *s from the fromt of it. | |
Re: AFAIK BigInteger will handle as many digits as you have memory for, certainly 600 is OK. | |
Re: Each time you call your method test you create a new ArrayList. Just declare and initialise it outside that method. | |
Re: Where are the form and the label? Where do you make them visible? We need the rest of your code. | |
Re: Have a look at the PixelGrabber class for getting pixels from images in general | |
Re: See this recent post [url]http://www.daniweb.com/forums/thread334990.html[/url] | |
Re: Don't have time to cehck this now, but don't you need a default constructor for a Serialisable class to be restored? | |
![]() | Re: First split the String into words (see the split(...) method in String class), process each word using charAt etc, the put all the words back together into a sentence. ![]() |
Re: With the commented line in you read the whole file into the buffer. Then in the while you start by reading again - but the file has now been read so you get an immediate end-of-file and the var is et to -1. read(byte[]) works just fine. | |
Re: Drawing over a line to delete it doesn't work too well because you will end up with gaps in the other lines where the deleted line overlapped them. Each time a button is clicked update a list of which lines should be visible, then clear the whole drawing area and … | |
Re: This is (IMHO) a horrible design omission in Swing - AFAIK there's no simple method to get the selected JRadioButton in a ButtonGroup. Most people just loop thru the buttons using their inherited isSelected() method to find the one (if any) that's selected OR they have a Listener for the … | |
Re: There's no such thing as a .exe for a Java program (unless you use an unsupported dodgy system-dependent utility to try to create one). A .jar file is just a zip file with some metadata. Just like any other zip you can put whatever files or directories you want into … | |
Re: That looks like a mistake - the Rentals (Java classes conventionally begin with an upper case letter) class should have an instance of Client, not just a clientID (ie like the 3 DVD members). | |
Re: So put some System.out.println statements into the relevant parts of the code to see which code is being executed and whether the variables have the values you expect. (It's called "debugging"). | |
Re: Account newAcc is defined inside buttonCreateActionPerformed so it can't be accessed from outside that method. You haven't explained the overall logic of your app, so I can't suggest the best way to fix this. But deposit is an instance method of Account, so you should just be able to call … | |
Re: I can't understand what you are trying to do with all the Reflection methods here! What do you need to do that is different from the standard pattern: [CODE]ArrayList<CountListener> listeners = new ... ... void fireCountEvent(int count) { for (CountListener cl : listeners) { cl . countEvent(count); } } ... … | |
Re: I don't have experience with your particular problem area, but I just want to assure you that there are quite a number of people around here who would help if they could. Also, you've chosen a bad week to get help - many people have not been at their desks. … | |
Re: A blank final var must be initialised in all constructors - ie it must have a value by the time the containing instance has been initialised. | |
Re: Don't worry blur, I got it, and I laughed. Thanks for the giggle. Merry Xmas | |
Re: Have you tried the waitFor method in the Process class? | |
Re: Is the content length being returned as zero? Does the if on line 61 evaluate to false? Is stream.available on line 70 zero? Just a gut feel - but the whole loop starting line 74 seems insanely complex - why not just create buf of the right length and read … | |
Re: That's [I][B]really [/B][/I]interesting. I too can assign a String too what should be an Integer and it works. The real answer is to declare nn1 fully, as in R2<Integer> nn1 = new R2<Integer>(); ij which case the compiler correctly rejects (1) | |
Re: I'm not familiar with WS, but what's the connection between displayNames() that you call on the client and openFile that you define on the server? | |
Re: "move data with large size from one object to another"? Move or just get access to? How large? Objects in the same JVM? Different JVMs on the same machine? Two machines in the same network? In general trying to optimise code before its working ("premature optimisation") is a waste of … | |
Re: IF your class extends Thread the it inherits the start() method, and you can start it. Otherwize you need a new Thread(yourRunnableInstance) and start that. | |
![]() | Re: Without a server you may have a problem getting the IP addresses of the two machines that need to communicate. JmDNS [url]http://sourceforge.net/projects/jmdns/[/url] can be useful in that case. |
Re: implements ... need an interface name here. ps post iin code tags and indent code properly | |
Re: Serializable [QUOTE]The serialization interface has no methods or fields and serves only to identify the semantics of being serializable. [/QUOTE] | |
Re: AFAIK it's no problem if you handle KEY_PRESSED and KEY_RELEASED KeyEvents. | |
Re: Like it says at the top of ther Java forum main page...[QUOTE]to keep DaniWeb a student-friendly place to learn, don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well.[/QUOTE] | |
Re: Did you notice this at the top of the Java forum listing? [QUOTE]don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well[/QUOTE] | |
Re: java.io.IOException; must be caught or declared to be thrown Means what it says. All the statements relating to the IO must be in a try block with a catch that catches IOException Unreachable while statement Means what it says. The previous statement is a return, so there's no way for … | |
Re: I see you are using ImageIcons in JLabels to show the images. Here's how I would think of this: I'd create a subclass of JLabel that has an Image and a zoom ratio as instance variables. I'd use getScaledInstance to scale the Image according to the zoom ratio in a … | |
Re: It's not easy. To move the ball you just lock the main method into a one-line while loop. All that will do is burn CPU cycles. You need to start a javax.swing.Timer to trigger regularly (a few times a second)to update the position and re-draw the screen. s.RestoreScreen() s is … | |
Re: I don't see why this is a problem! You fire the bullet. It has an initial position and velocity that depends on the position and velocity of the ship at that time. The bullet's position and veocity should have no connection with the ship once they are initialised - after … | |
Re: You may have a problem because all these methods read the input file, so after the first method has read it all the subsequent methods will just see end-of-file. May be better to have a method that reads the file just once into an array then pass that array to … | |
| |
Re: To execute custom code of your own on JFrame closing use a WindowListener. [url]http://download.oracle.com/javase/tutorial/uiswing/events/windowlistener.html[/url] | |
Re: The usual form of that expression is Sum(n) = n(n+1)/2 but that's not a loop. How about recursion: [CODE]int sum(int n) { return (n==1)?1:n+sum(n-1); }[/CODE] Does that count as a loop? | |
Re: The idea is that if your method may have errors it can't deal with it should throw some kind of Exception. There's nothing to stop you throwing one of the Exceptions that are defined in the Java API, but it's far more helpful to define a new Exception type of … | |
Re: Exactly what problems are you having in running this? All you need is a one-line main method. What did you try? ps 2147483647 is the largest valid value for an int. |
The End.