7,116 Posted Topics

Member Avatar for kartik1997

DaniWeb Member Rules include: "Do not hijack old threads by posting a new question as a reply to an old one" [url]http://www.daniweb.com/forums/faq.php?faq=daniweb_policies[/url] Start you own new thread, and post your code in code tags.

Member Avatar for stultuske
0
143
Member Avatar for furqanishaq

To square a number just multiply it by itself - eg 5 squared is 5*5

Member Avatar for JamesCherrill
0
95
Member Avatar for aanders5

[QUOTE=aanders5;1753090]I need to have the bombs in an array for the engine itself, but I also need to make sure the button themselves are set with a bomb object so that GUI lines up with the user.[/QUOTE] That's good - proper separation of GUI and engine/model. You can use JComponent's …

Member Avatar for JamesCherrill
0
152
Member Avatar for scheppy

When debugging never NEVER [I][B]NEVER [/B][/I]have an empty catch block! There are many reasons why the code in your try block may fail, and for most of them you will get an Exception that describes exactly what went wrong, and exactly where in the code. change [CODE]catch (java.io.IOException z) //catching …

Member Avatar for scheppy
0
895
Member Avatar for venomlash

Hi @117 This problem is from 2007, when Ezzaral solved it comprehensively. Do you really think the OP has waited four and a half years just in case you wanted to contribute?

Member Avatar for 117
0
7K
Member Avatar for jehlaipixy

By analogy with interfaces like Comparator, I would interpret this as follows: Create a class (eg "BalanceFilter") that implements Filter, and in its accept(...) method only accepts accounts with balances > some arbitrary threshold value. Then in the DataSet class instantiate a BalanceFilter with threshold value of 1000, and use …

Member Avatar for jehlaipixy
0
451
Member Avatar for long89

After you have filled your array of Circles you can loop through that array and use your getColour() method to get the colour of each Circle. Test if that is red, and increment a counter if it is.

Member Avatar for long89
0
154
Member Avatar for ForceStr

You are responding to keyPressed, which happens when the user presses a key (duh!). But the input to the text field doesn't happen until the key is [I]released [/I] and a valid character has been typed - so that's why you don't see the latest char in the getText. (Ps …

Member Avatar for ForceStr
0
180
Member Avatar for long89

[CODE]try { // your code that could cause an exception to be thrown } catch (Exception e) { // catch any Exception that may be thrown // your code to display an error message }[/CODE]

Member Avatar for rushikesh jadha
0
429
Member Avatar for Kjeks

Two more things to check: is the class file in a folder called "src" in the jar? is all the capitalisation correct (file names in a jar are case-sensitive)?

Member Avatar for JamesCherrill
0
386
Member Avatar for riahc3

You can run batch jobs as at the command prompt frim Java by using ProcessBuilder (Google for examples and details), but you may get a far better solution all round by embedding a JavaScript script in your Java program. Check out scripting language support in Java (Java 1.6 or later).

Member Avatar for riahc3
0
445
Member Avatar for ilovejava

In a classic array list (eg java.util.ArrayList) you have a [I]size [/I]which is the number of objects actually stored in the list at any time (initial value 0), and a [I]capacity[/I], which is the length of the private array that's used to hold the list (initial value is an arbitrary …

Member Avatar for ilovejava
0
207
Member Avatar for steven8579

[QUOTE=steven8579;1752096]i get what you're saying. This is what i'm trying to do. The first while loop should read all nums in the array from the left to the right and stop where the element is supposed to be inserted. The condition should be that index < numElements and number is …

Member Avatar for JamesCherrill
0
382
Member Avatar for Torf

If you want to use classes like JOptionPane from the javax.swing package then either 1. Use its fully qualified name javax.swing.JOptionPane or 2. import the class (or package) at the beginning of your program so you can use the class name without qualification

Member Avatar for JamesCherrill
0
967
Member Avatar for androidf

^ that's right. I've done quite a lot of that to provide remote interfaces to what would otherwize be just local Swing applications. You can simply write an HTML file like you would write any other text file, taking care with Java escape chars. What's a bit more interesting is …

Member Avatar for JamesCherrill
0
1K
Member Avatar for kalcio

[CODE]void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { while (... ... Thread.sleep(...[/CODE] You simply can't do that in Swing, or rather you can, but it doesn't work. Everything to do with Swing (eg painting the screen, running actionPerformed methods) happens on a single thread - the "Event Dispatch Thread", or "EDT", or "Swing thread". …

Member Avatar for kalcio
0
140
Member Avatar for jackbauer24

Quick answer: an instance variable is any variable declared in a class but not inside any block (eg method), and not declared static. I don't understand your second question - what did you want the main to do?

Member Avatar for DavidKroukamp
0
231
Member Avatar for 47pirates

Are you certain that you are using matching streams and encoding for the read and the write? Is the user name the very first thing sent over the socket?

Member Avatar for JamesCherrill
0
105
Member Avatar for harinath_2007

Do you have any exceptions thrown? Do 100% of your catch blocks printStackTrace()?

Member Avatar for DavidKroukamp
0
784
Member Avatar for rushikesh jadha

Hi Norm. Watch out for this OP - already in trouble with Peter Budo for not showing any effort, and is starting to troll other people's posts. J

Member Avatar for rushikesh jadha
0
313
Member Avatar for dennysimon

You would normally use the classloader's [ICODE]getResourceAsStream [/ICODE]method - which has the advantage of immediately giving you an open InputStream on the file in the current jar. You'll find the doc in the usual places, but briefly: in the code of a class that was loaded from the same jar... …

Member Avatar for dennysimon
0
337
Member Avatar for Goldfinch

Around lines 60 and 228 the initialisation loops stop one short, and leave the last element of each array null. [CODE]for(int i=0; i < 12; i++) { // initialises the first 12 elements of 13 rankArray[i] = new Rank(i); for(int i=0; i < 3; i++) { // initialises the first …

Member Avatar for Goldfinch
0
181
Member Avatar for 3nrichedd

new GroceryList(); looks for a constructor with no parameters, but the only constructor you have defined is public GroceryList(String name, int quantity, double unitPrice)

Member Avatar for stultuske
0
211
Member Avatar for scheppy

You just need to cast the Object that's returned. String isn't a primitive so there's no boxing involved String s = (String) btn.getClientProperty ("myString");

Member Avatar for JamesCherrill
0
257
Member Avatar for mallikaalokam

Methods declared in an interface are automatically public and abstract, so the method definition in the class that implements must be declared public, as default access is more restricted

Member Avatar for JamesCherrill
0
296
Member Avatar for rushikesh jadha

I didn't trace thru all that code, but I notice you've ported a file name from Windows to Linux. Apart from the obvious working directory differences, you are also moving from a case-insensitive environment to a case-sensitive one. Maybe that's a problem? ps [CODE]boolean exists = file.exists(); if (!exists) { …

Member Avatar for JamesCherrill
0
350
Member Avatar for Skeldave

You may need to let the layout manager know that you need it to update the layout after you have added the buttons - try calling invalidate() on your panel after adding the buttons. The other thing is that icons on jLables and jButtons are notorious because if there is …

Member Avatar for JamesCherrill
0
285
Member Avatar for rushikesh jadha

That depends on the bank, but in general: A savings account pays interest, and can never have a negative balance A current account may or may not pay some interest, and may allow negative balances. A current account is used for day-to-day transactions using cheques or debit cards or on-line …

Member Avatar for rushikesh jadha
0
101
Member Avatar for laklaker

Small suggestion re cOrRuPtG3n3t!x's code posted above: in both catch blocks add an [ICODE]e.printStackTrace();[/ICODE] so that if something goes wrong you will know what the problem was.

Member Avatar for JamesCherrill
0
471
Member Avatar for dineshswamy

Do you mean the text field didn't show up, or it did show up but the image was missing? If you paint a small colored rectangle instead of the image does that work?

Member Avatar for JamesCherrill
0
166
Member Avatar for FUTURECompEng

I looked at your files, now I don't understand your question! [QUOTE]how do I create a file with a list of all the words that can be accessed by an user input to verify if the word exists?[/QUOTE] You already have that file [QUOTE]I dont know how to create or …

Member Avatar for JamesCherrill
0
947
Member Avatar for jmace

I hate to rain on your parade, but there's no such thing as an ASCII value of 147. The ANSI ASCII standard code is a 7 bit code, covering values 0 - 127. There are many many variants on 8 bit codes (code pages in DOS terms), which are consistent …

Member Avatar for JamesCherrill
0
3K
Member Avatar for srikanth2321

What do lines 51/52 really look like? ".. results nothing as an output" Nothing as in "", or null, or absolutely nothing happens (in which case is the CPU busy or idle)?

Member Avatar for srikanth2321
0
380
Member Avatar for bloodbender

Math.power ends up in a native method to do the actual calculation, so its a reasonable bet that's its very efficient indeed. Either way. memory really doesn't come into it. Unless your idea of "a lot" runs into millions in this case, I wouldn't waste another millisec worrying about speed …

Member Avatar for bloodbender
0
107
Member Avatar for ghada ali

"http:\\www.google.com" In Java \ is a special character, used to start escape sequences in string literals. "\\" in a string literal is only a single \ character in the String itself.

Member Avatar for ghada ali
0
359
Member Avatar for dineshswamy

The inherited paint method from JTextField is where the actual text is painted into the field. Because you have setOpaque(false) the inherited paint will not attempt to draw any background, so it will just paint the text over the image you painted in your code. If you didn't call super.paint …

Member Avatar for JamesCherrill
0
1K
Member Avatar for Goldfinch

[CODE]static String test=null; public Card() { setValue();//if we dont call this our value wont be set } public static void setValue() {//set value test="of"; }[/CODE] Why such ridiculous contortions? Why not just [CODE]static String test="of";[/CODE]

Member Avatar for DavidKroukamp
0
134
Member Avatar for 3nrichedd

GroceryList extends ArrayList<GroceryItemOrder> so super(name,quantity,unitPrice); tries to find a constructor in the superclass (ie ArrayList) that takes those 3 params, and there isn't one.

Member Avatar for hiddepolen
0
255
Member Avatar for Hypnos_16

You need to create three objects to represent the three moving shapes (using a new class that you have to define). Each object must implement the Animate interface. Your main animation class can then call each object's [I]move [/I]method to move it (eg on a Timer), and your main paintComponent …

Member Avatar for NormR1
0
2K
Member Avatar for jkembo

"NOT ( ( b ) AND ( a )) ... This formula is terminated has AND is the root" Are you sure? I would expect the resulting tree to look like this: [ICODE] NOT / \ / \ (null) AND / \ / \ a b[/ICODE]

Member Avatar for jkembo
0
290
Member Avatar for raj.mscking

I think he's talking about Steganography [URL="http://en.wikipedia.org/wiki/Steganography"]http://en.wikipedia.org/wiki/Steganography[/URL]

Member Avatar for JamesCherrill
0
150
Member Avatar for abhishekwaichal

For general data you could use an ordinary zip file [url]http://java.sun.com/developer/technicalArticles/Programming/compression/[/url]

Member Avatar for JamesCherrill
0
37
Member Avatar for jackbauer24

By matching the number and types of the parameters in the call to those in the constructor's definition (just like any overloaded method call)

Member Avatar for jackbauer24
0
174
Member Avatar for jackbauer24

An abstract class can declare ordinary variables. An interface can only declare final static "variables" (AKA constants)

Member Avatar for JamesCherrill
0
173
Member Avatar for 47pirates

Use a javax,swing.Timer to run the necessary code at the appropriate intervals?

Member Avatar for 47pirates
0
278
Member Avatar for araib

It means the application and/or its databases are somewhere on the Internet ("in the cloud"), and all you have on your computer is some kind of front-end to access it (maybe even just a web browser).

Member Avatar for JamesCherrill
0
109
Member Avatar for FALL3N

Yes, the param for split is Regex, and $ is a special char in regular expressions. You have to escape it with a backslash to use it as a literal $

Member Avatar for FALL3N
0
171
Member Avatar for deathmagnetix

This seems a stupidly designed Java exercise to me - let's do some cunning logic but no if tests? - but hey ho. There must be mathematical formulae (using the ceil function) that evaluate to 1 if a variable is larger/smaller than some reference variable, and zero otherwise. So if …

Member Avatar for deathmagnetix
0
1K
Member Avatar for kalz

[CODE]b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { if(table.getSelectedRow()<0) // help required to implement this logic!! { JOptionPane.showInternalMessageDialog(rootPane, "Please select a row from the table first!"); ...[/CODE] At a quick look what you've got seems OK. What exactly is the problem with the code you posted?

Member Avatar for kalz
0
459
Member Avatar for Vampiricx3

JComboBox allows you to pass a list of objects to its constructor, and uses those for its data values (calling their toString methods to display them). But for historical reasons the list has to be in a Vector, not an ArrayList. If you change your ArrayList to a Vector (no …

Member Avatar for Philippe.Lahaie
0
3K

The End.