7,116 Posted Topics

Member Avatar for DarkLightning7

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", …

Member Avatar for DarkLightning7
0
585
Member Avatar for WolfShield

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 …

Member Avatar for WolfShield
0
158
Member Avatar for jfountai

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.

Member Avatar for jon.kiparsky
0
647
Member Avatar for AnthonyJ

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. …

Member Avatar for JamesCherrill
0
400
Member Avatar for Desi Boy

[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 …

Member Avatar for JamesCherrill
0
72
Member Avatar for gedas

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 …

Member Avatar for mKorbel
0
208
Member Avatar for drogba123

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.

Member Avatar for JamesCherrill
0
285
Member Avatar for kay19

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 …

Member Avatar for kay19
0
453
Member Avatar for Katana24

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 …

Member Avatar for mKorbel
0
94
Member Avatar for rohit2

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

Member Avatar for mKorbel
0
276
Member Avatar for BroonoVilliam

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

Member Avatar for Taywin
0
135
Member Avatar for Jessurider

[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 …

Member Avatar for sourabh17
0
422
Member Avatar for wonder_laptop

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 …

Member Avatar for JamesCherrill
0
116
Member Avatar for liran

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 …

Member Avatar for liran
0
169
Member Avatar for WolfShield

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?

Member Avatar for Taywin
0
395
Member Avatar for Puertorro

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.

Member Avatar for Puertorro
0
124
Member Avatar for Na'Vi

You can use the format method in the String class to convert stuff to String using printf-style formatting codes.

Member Avatar for JamesCherrill
0
115
Member Avatar for wonder_laptop

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 …

Member Avatar for JamesCherrill
0
165
Member Avatar for newbieha

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 …

Member Avatar for newbieha
0
569
Member Avatar for HelloMe

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>");

Member Avatar for HelloMe
0
150
Member Avatar for HelloMe
Member Avatar for HelloMe
0
4K
Member Avatar for titan5

Just setVisible(false) /* temporary */ or dispose() /* permanent */ the first window in the button's ActionListener

Member Avatar for titan5
-1
124
Member Avatar for burningflower

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 …

Member Avatar for JamesCherrill
0
218
Member Avatar for kaneyip

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 …

Member Avatar for JamesCherrill
0
110
Member Avatar for bindhub

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.

Member Avatar for stultuske
-3
1K
Member Avatar for gunjannigam

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() …

Member Avatar for gunjannigam
0
499
Member Avatar for samppb

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 …

Member Avatar for Ezzaral
0
127
Member Avatar for dawnoflife

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 …

Member Avatar for jon.kiparsky
0
190
Member Avatar for nickcolb

[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 …

Member Avatar for JamesCherrill
0
184
Member Avatar for Transcendent

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 …

Member Avatar for JamesCherrill
0
2K
Member Avatar for bharath54321

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 = …

Member Avatar for bharath54321
0
142
Member Avatar for Amillia89

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?

Member Avatar for JamesCherrill
0
266
Member Avatar for imKEN

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 …

Member Avatar for imKEN
0
127
Member Avatar for manish250

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

Member Avatar for JamesCherrill
0
153
Member Avatar for bharath54321

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 …

Member Avatar for JamesCherrill
0
113
Member Avatar for altayar

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 …

Member Avatar for JamesCherrill
0
211
Member Avatar for DDirectJ

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.

Member Avatar for DDirectJ
0
168
Member Avatar for Saint OTB

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 …

Member Avatar for peter_budo
0
2K
Member Avatar for lse123
Member Avatar for Acklox

[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 …

Member Avatar for JamesCherrill
0
194
Member Avatar for Acklox

> 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 …

Member Avatar for Acklox
0
445
Member Avatar for bibiki

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 …

Member Avatar for bibiki
0
129
Member Avatar for techie929

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 …

Member Avatar for JamesCherrill
0
91
Member Avatar for HappyCat123

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.

Member Avatar for JamesCherrill
0
1K
Member Avatar for Shizuo

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 …

Member Avatar for Shizuo
0
95
Member Avatar for axiss

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.)

Member Avatar for HappyCat123
1
488
Member Avatar for iwannalearn

"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).

Member Avatar for JamesCherrill
0
87
Member Avatar for gedas

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.

Member Avatar for JamesCherrill
0
133
Member Avatar for sirkido

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.

Member Avatar for JamesCherrill
0
182
Member Avatar for carlitosway17

[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

Member Avatar for carlitosway17
0
201

The End.