7,116 Posted Topics
Re: Possibly it's a lock problem. This may be completely wrong, but... BannerP has a wait loop that's synched on "this". You try to exit the loop with a notify in Banner, but that's enclosed in a synch on the same object, so the notify will never be executed as long … | |
Re: What an interesting idea! I haven't tried this, but some questions need answering: Ability is abstract, so you can't instantiate it. The inner classes are not static, so they need an instance of Ability. ? Since each of the inner classes extend Ability, they each inherit the inner classes, so … | |
| |
Re: masijade is exactly right. You are looping and waiting in the Swing event thread, which blocks all GUI activity (including repainting the progress bar) until your method finishes. You'll find lots of info on this here at Daniweb, and via Google (search for Java event dispatch thread) | |
Re: You declare the method as returning a value of type ClassB public Class B getComputerPart() { ( I assume the blank between Class and B is a typo) The value you actually return is an Integer return Integer.parseInt(conString); So either return an instance of ClassB, or change the method declaration … | |
Re: [QUOTE=NewToThis;943334]sure, I am getting the error on this line code: while([] counter <= 10); [/QUOTE] What are you trying to achieve with the [] ? | |
Re: Static initialisers are run "when the class is initialised", which is (some time) before any reference to it is used, so the behaviour you observed is required by the language definition, and should be consistent in its results across all JREs. You may find that the first class to be … | |
Re: You may find the following useful - in summary: when threads of equal priority are scheduled the order is arbitrary (although round-robin scheduling gives them all a chance). Time slicing and multiple CPUs make this a lot less deterministic. In summary summary - you can't assume anything about the order … | |
Re: Shouldn't be too hard, and you don't need JAI if you don't want to go there. You can use the Image class to get the image, then the PixelGrabber class to get an array of all the pixel values. Once you've got that you can shuffle it using simple array … | |
Re: Why do your Nodes have names? What will you use the name for? | |
Re: I pasted your 3 lines of code into a main(...) method in Eclipse. It required me to remove the "public modifiers, then compiled OK. Also runs without throwing any exceptions. Java 1.6.0.14 Looks like something in the context where your code is placed. "Public" is wrong in a method, "System.setOut" … | |
Re: Use a sort(...) method from the Arrays class. You want the one that allows you to specify a Comparator - that's a little interface where you specify the exact comparison criteria to use in the sort. [url]http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arrays.html#sort%28T[/url][],%20java.util.Comparator%29 | |
Re: Java is no harder than any other language of comparable power. What really affects understandability is how you code it; if all the class and member names are really descriptive and the comments are helpful, then the code will be a lot clearer. | |
Re: Scanner line = new Scanner(line); This looks wrong. There is no constructor for Scanner that takes a Scanner as a parameter. | |
Re: You could try the clone() method that all Java objects have. BufferedImage img2 = img.clone(); This isn't always implemented for all classes, but if that's the case you'll get a CloneNotSupportedException thrown immediately, so at least you'll know! | |
| |
Re: Sorry adatapost, but I have the jmf mp3 plugin installed and working on my Windows system. [url]http://java.sun.com/javase/technologies/desktop/media/jmf/mp3/download.html[/url] Jmf should be capable of doing all the stuff specified in the OP's first post, but I have found it to be erratic and unreliable. I have had really good solid results from … | |
Re: This depends on what kind of Objects the Tree is composed of. If they're Strings this isn't too hard, but if they are some complex class that doesn't have a simple string representation... TreePath is Serializable (provided its constituent Objects are Serlializable), so you just want to do I/O on … | |
Re: I guess you wanted to name the class midquiz 2 You can't have a blank in a class name. ps By convention, class names begin with a capital letter | |
![]() | Re: You'll need to pass the item to delete as a parameter. Loop thru the array until you hit that item, then continue thru the rest of the array moving each item down by 1 position. But, as stephen84 says, there are classes in theAPI that already do all that stuff, … ![]() |
Re: Your paint method needs to be in the GUI class MyMouse, not in the listener class MyMouseAdapter. It's the GUI that gets painted, not the listener. | |
Re: [I]treeInsert(BinaryTree t, int newItem)[/I] is a method that requires two parameters [I]treeInsert(arrNum[i]);[/I] is a method call that has only one parameter. Error! Plus: this doesn't do anything [CODE]if ( t.root == 0 ) { // The tree is empty. Set root to point to a new node containing // the … | |
Re: Does the error message correspond to the code you posted? | |
Re: You should at least try to compile this coded and fix any compile errors. | |
Re: Have a look at Java Object persistence.With a few tiny changes you can write your entire colleaction of "Storage" objects to a file (using ObjectOutputStream's writeObject method) in one simple call, and read it all back in just as easily. [url]http://www.javaworld.com/javaworld/jw-05-1997/jw-05-persistence.html?page=3[/url] Why re-invent the wheel? | |
Re: your sort needs to return the whole sorted array, not just one element. (Remember the problem with the constructor earlier?) | |
Re: When you say "crashes", what exactly happens - do you get an Exception thrown, does it just stop responding, does it disappear, does NetBeans stop responding or disappear, (etc)? Does it crash when you press the exit" button? If it's really an insufficient memory problem you should see a different … | |
Re: What help do you need? If it's not working properly, tell us what's wrong with the output. If it gives an error message, tell us what it is. | |
Re: getResource searches (unless you are doing clever stuff with class loaders) your classpath, so I'd try putting the data file alongside the class file (or specify its location as a path starting from the folder where the class file is) (modified as necessary if you have specified a package name). | |
Re: com.csvreader.CsvWriter writer = new ... seems to be inside your innermost loop, so you re-open (and thus overwrite) the file contents every time you go thru the loop. I think you should open the stream just once, at the beginning. | |
Re: Are you comparing on the file size? If so, you convert it to String, and do a String compareTo so, for example "1000000"sorts lower than "2". ps Any special reason why you use a 2D array? Why not just keep the array of Files and use File's accessor methods when … | |
![]() | Re: TestBooks myFrame = new TestBooks(bookArray[numBooks]); So if numBooks is (say) 2, you populate elements [0] and [1] in the array, but you pass element [2] to the GUI ![]() |
Re: board[row][col]=temp[row][col]; shouldn't this be in a row/col loop? and, FYI... if (expr == true) is just long way to say if (expr) and if (expr == false) is just long way to say if (!expr) | |
Re: [url]http://articles.techrepublic.com.com/5100-10878_11-5144546.html[/url] | |
Re: 1. Is it exactly a NumberFormatException that still displays, or something similar? 2. When the Exception displays, is the line number within the try clause that you think it should be? | |
Re: Can't see any obvious error - what [I][B]exactly [/B][/I]goes wrong when you run it? | |
Re: Maybe set a FileFilter that only accepts the file name you want. (ps Why do yiou want to use a filechooser and not allow the user to specify the file name???) | |
Re: As far as I can see you use a highly tortuous loop to inspect each value in the hashmap then, if it is null, you set the variable pNode (whatever that may be!) to null. It seems equivalent to: [code] for (TreeNode t : pHash.values()) { if (t == null) … | |
Re: Maybe I missed it, but there's no code to display the contents, just to read it and display any errors. edit: parallel post with previous - I was referring to code in post 4. | |
Re: [url]http://www.daniweb.com/forums/announcement9-2.html[/url] | |
Re: Don't know why it fails, but you catch IOException and just return null - so if there is an IO problem you will get no error messages or any other clues as to what happened. Put a e.printStackTrace(); in the catch and see if there's a problem there. | |
Re: If you have a class X in a package y, the JRE will look for X.class in a directory called y. ie the class files must be in a directory structure that corresponds to your package structure. So try creating a sub-dir with the same name as the package, put … | |
Re: private static variable to hold the instance. public static method getInstance() that creates an instance if necessary, and returns the instance. Should be synchronized if it's a multi-threaded app. private constructor, so you can't call the constructor from outside. This is called the "singleton" pattern, you'll find lots of info … | |
Re: JavaMail gives you a full email client in Java that you could use, or the Desktop class lets you control your usual email client to do the job. Either way you can use a Java prog to query the database at regular intervals and generate/send the email using either interface. … | |
Re: Don't understand why you need to write something new. There are loads of excellent version control systems available, many free. | |
Re: At line 15, instead of converting the input to int, just leave it as a String. In lines 17, 26 etc just test if the String is equal to "M" or "m" etc. ps: You can't compare Strings with ==. You need the equals("M") method, or, even better, equalsIgnoreCase("M") which … | |
Re: [url]http://www.javafx.com/samples/PuzzlePieces/index.html[/url] | |
Re: Min bitsizes: 0-5 : 4 bits 0.00 - 30.00 : 12 bits 0-100 : 7 bits so 20 isn't enough, theoretical min is 35 bits Sensible compromise may be to store the int values in byte variables, and the floats as short variables (held in units of 1/100 - eg … |
The End.