7,116 Posted Topics
Re: Nobody else has answered so, despite the fact that I've never actually done this myself, there's nothing to lose by having a go! The doc says that JavaFX can use Java classes, so in theory you should just be able to call the Java [ICODE]System.getProperty(p); // where p is "os.name", … | |
Re: What's normally done here is to have all the methods & variables non-static (unless there is a good reason otherwize) then in your main method create a new instance of the class. The main method must be static to be recognised. The code you have in the [B]static Conv()[/B] method … | |
Re: Print the whole of the out-of-bounds exception ( e.printStackTrace(); ) in your catch block - that will tell you the exact line of your program on which it happened. | |
Re: Without the whole assignment who can tell if these are complete? But part of the joy of OO programming is that its easy to add stuff to your classes later. Try writing a tiny test program ([ICODE]public main[/ICODE]... method) that constructs a simple polynomial and see how well it works. … | |
Re: [CODE]System.out.print ("Enter the service type:") + "R or r (regular), " + "P or p (premium): ";[/CODE] You have your brackets all naffed up. The ) on the first line matches the ( before it and ends that expression, so the compiler is baffled when the next thing it sees … | |
Re: This looks like a case of unclear spec to me. "what i want is to find out at what speed the coordinates are traveling" is that average speed from the start until now? the instantaneous speed (speed of latest jump)?, smoothed average recent speed? Even if it's all three cases … | |
Re: Not exactly a clear statement of requirements, but if you want to link that list of words to the substring you could use a HashSet with the substring as the Key and the ArrayList of words as its Value. | |
Re: One thing jumps out at me: You get the lower & upper bounds in num1 and num2, but then you keep changing the value of num1 in your loops. This seems very dangerous to me. I suggest you add another variable or two for use as temporary values in your … | |
Re: You can use getWidth() and getHeight() on the component where you are painting to see how high/wide it is, then have two nested loops: one for x, one for y, painting and incrementing until x>=width and y>=height respectively (or stop at 5 if that happens first). ps Recommended practice is … | |
Re: I don't know about notepad++, but the behaviour you describe (type a tab and it replaces the currently-selected text) is standard behaviour all the way from notepad to Word. If you want non-standard behaviour, implement a DocumentFilter (see the API doc and/or Google) for your JTextPane | |
Re: Usual way is to add a [ICODE]compareTo [/ICODE]method to your class. Inside that method you code whatever logic you want to compare two instances (eg compare name fields). Have a look at the [ICODE]Comparable [/ICODE]interface in the Java API | |
Re: [CODE]catch (IOException e) {}[/CODE] That is a big mistake. If there is any problem locating or reading the file, you have opted for Java to do nothing and tell you nothing. How can you debug that? [CODE]catch (IOException e) {e.printStackTrace()}[/CODE] will ensure that you have a proper full explanation of … | |
Re: There doesn't seem to have been any release with a number like that. Do you mean 1.5, or release 5.0u5? Here are the downloads for JDK 5 [url]http://www.oracle.com/technetwork/java/javase/downloads/index-jdk5-jsp-142662.html[/url] ps: why does it have to be that exact version? - it's end-of-lifed, contains known bugs and security problems, and later versions … | |
Re: A thread will continue executing until its run() method terminates, at which point it dies and cannot be restarted. I think the GC issue is a red herring - although you may have freed all your explicit references to it, the JVM scheduler surely has one. This [url]http://www.janeg.ca/scjp/threads/state.html[/url] useful summary … | |
Re: Compiles and runs OK for me in Eclipse - I just omitted the package statement and changed the class name to match the name of the .java file I was using. Maybe a file/directory vs class/package naming thing? | |
Re: Just get a text editor and start typing! But seriously, you have a detailed blow-by-blow description of what you have to do. It's detailed enough that you don't have any room for cleverness, so just do what it says. | |
Re: You can use the format method in the String class to convert stuff to String using printf-style formatting codes. | |
Re: When Java needs to load a class it gets the variable "CLASSPATH", which should contain a list of directories and/or jar files, and searches all those locations to find the .class file(s). Line 4 appends %AGLET_HOME%\lib\myJarFile.jar to the CLASSPATH variable. AGLET_HOME was set to C:\Users\MARIA\Desktop\aglets, so line 4 appends the … | |
Re: When you get a Java error it comes with a complete description and a stack of line numbers. Please post the full details of your error(s). Also post the full source code - you post identifies the error as being on lines 161/166, but the code you posted only goes … | |
Re: The only way I know is HTML, but that's really easy - eg myJLabel.setText("<HTML><This is a test<BR>on two lines</HTML>"); | |
Re: Missing } at end of previous method ps NEVER leave empty catch blocks like 187-191 | |
Re: Just setVisible(false) /* temporary */ or dispose() /* permanent */ the first window in the button's ActionListener | |
Re: ArrayIndexOutOfBoundsException happens when you run the program, not when you compile. The message tells you which line it happens on - this is important info! It [B][I]may [/I][/B]be line 37 where you reference args[0] (the first arg passed when your program is run) - if you supply no args then … | |
Re: You have two challenges - first to think through the logical process you need, second to translate that into Java code. You can't start the second until you've completed the first. So the best thing you can do is to set the PC aside, grab a pencil and pad of … | |
Re: 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. | |
Re: Move as much code as possible out of paint(...) - eg read the image file or create the new Font just once at startup, not on every call to paint(...). How and how often are you updating? You should be using a javax.swing.Timer to call update the heading then repaint() … | |
Re: Just an idea... your run() method appends to buffer, but buffer is only initialised in start(). You start the Thread from the class constructor, so maybe there is a race condition over whether run() gets called before or after start() ? Maybe worth trying initialising buffer when it's declared? StringBuffer … | |
Re: InputMismatchException on line 92 implies your scan.nextInt() is finding in the file something that cannot be parsed as an int. ps throwing any IOExceptions all the way out of your program is just dumb. Catch it as quickly as possible and execute an e.printStackTrace() to get the maximum info on … | |
Re: [QUOTE] //this would make change to be 0 because 4/1000 * 1000 is 4. (original value of change). 4-4 is 0.[/QUOTE] Just to avoid any possible confusion here... 4/1000*1000 is not 4. Evaluation is all integer, left to right, ie (4/1000)*1000 4/1000 in integer arithmetic is 0, so the intermediate … | |
Re: I assume you are supposed to code this yourself, and you can't use SimpleDateFormat? DDD is the number of days into the year. If it's <=31 then its a day in January. If its >31 and <=28 then (DDD-31) is a day in February. Etc. You already have a daysInMonth … | |
Re: You can't explicitly "delete" a whole array in Java. Just like any other Java Object it will be thrown away ("garbage collected") when you have finished with it. Java knows you have finished with it when you no longer have any variables that refer to that array. [CODE]int[][] myArray = … | |
Re: What's the point of this code? [CODE]for (int i=1;i<col;i++) test[a] = rs.getString(i);[/CODE] Isn't that just the same as [CODE] test[a] = rs.getString(col-1);[/CODE] but without all the overwriting of previous entries? | |
Re: Here a few hints: You have two classes, both called Profile, so the first thing is to rename one of them - eg change the first one to Logon. Move all the code (except the first line) in the main methods into the appropriate constructors so that you can just … | |
Re: You may have multiple subclasses, but in this particular piece of code you don't care which one it is. Animal a = new Cat(); (or) new Dog(); (or) new Horse(); // etc a.makeNoise(); // don't care what kind of animal it is | |
Re: A "two dimensional array" in Java is really just an array of arrays, so if you have int[][]c = new int[2][5]; then c[0] is an array of 5 ints and c[1] is another array of 5 ints. The following code is valid, and relevant to your question... [CODE=JAVA] int[] a … | |
Re: There's a sneaky way to do this... append a copy of your characterset string to it self - ie have a string that has the letters twice "ABC ... XYZABC ... XYZ" now you can simply take a 26-long substring starting at 0, 1, 2, ... 25 to get the … | |
Re: You can iterate through all the children of the JPanel removing them one at a time... but it's probably easier to remove the old JPanel from your window and replace it with a new empty one. | |
Re: if (month == 1 || month == 3 || ... or you could do an array of months holding the number of days... int[] daysInMonth = (31, 29, 31, 30 ... then look up the number of days using the month number as index. Either way, you'll have to special-case … | |
Re: @Ise123: they are only equivalent if printLCS(i-1, j-1) returns zero. Which seems unlikely... | |
Re: [QUOTE]1) You should remove the static count from the book class. The Book class is singular, one instance of it literally represents 1 book. One book does not know how many other books there are; only containers like book shelves, libraries, and arrayList know this information. Therefore, it should reside … | |
Re: > class ButtonFrame is public, should be declared in a file named ButtonFrame.java means what it says > cannot find symbol : class Jlabel > cannot find symbol : variable plainJbutton check your capitalisation - all Java names are case sensitive After that it doesn't help that the code you … | |
Re: Going back to the original MVC question, which seems to have got submerged in all these issues about waits and repaints... A simple way to do this as MVC goes as follows: 1. Model class - has 8x8 array modelling the logic of the chessboard and populating it with the … | |
Re: The <int[]> syntax was new in Java 1.5, so it won't compile on earlier JDKs. You can compile using 1.5/1.6 compilers, but the generated .class files will also need JRE 1.5/1.6 unless you specify that the generated class files must be compatible with earlier JREs. In Eclipse go to Project … | |
Re: You can create an Image object from your jpeg file, then overide the paintComponent method for your JPanel and draw your Image into it. It's a standard technique, so you'll have no problems Googling for details. | |
Re: By creating a small public method in the first class to do that eg public void makeButtonVisible() { myButton.setVisible(true); } then calling that public method from the other class. This keeps the implementation of the GUI private to the first class, and just exposes a public method that can be … | |
Re: Do you want to have the image as just one of the components in the panel, or do you want the image to fill the panel as the background for all the components in the panel? (Because these two have different solutions.) | |
Re: "Fields" is just another name for all the variables and constants belonging to a class (both static and instance variables, but excluding local variables in methods). | |
Re: The trig function tangent (AKA tan) gives you the x vs y slope of a line from its angle - so for example the tan of 45 degrees is 1, so a line from 0,0 to 1,1 will be at 45 degrees. The Math class has a tan method. | |
Re: Is that a carriage return between the : and the " You can't have a carriage return inside a string like that. The similar line ~5 lines above shows the right way to do it - finish the string first, then put the cr. | |
Re: [QUOTE]so far I have three errors ...[/QUOTE] What errors exactly, on which lines? Please post full error messages and the source code lines where the error happens |
The End.