7,116 Posted Topics

Member Avatar for P00dle

* is a meta-char in a regex (matches 0 or more repetitions). To use it literally you must precede it with a backslash. To use a backslash as a literal in a Java String literal you need to enter 2 backslashes. So you regex should be "\\*.txt". (Probabaly, I didn't …

Member Avatar for P00dle
0
4K
Member Avatar for Katana24
Member Avatar for Katana24
0
2K
Member Avatar for titan5

Yes (There are cleverer ways of structuring it, epecially when the number of dice is variable, but they still all come dowm to n nested loops).

Member Avatar for JamesCherrill
0
1K
Member Avatar for gibson.nathan

Are grades really just a Double precision number - ie (a) why Double - how precise are they? and (b) don't you care what the subject was, when the grade was awarded etc? If there is more to it than just a vastly-precise number, then maybe a Grade class that …

Member Avatar for coil
0
676
Member Avatar for DeadSoul

Not sure exactly what you mean by "add flash content", but the DJ Project includes a Swing flash player component that you can embed in your app. [url]http://djproject.sourceforge.net/ns/index.html[/url]

Member Avatar for JamesCherrill
0
83
Member Avatar for jiraiya

The SwingWorker class [url]http://download.oracle.com/javase/tutorial/uiswing/concurrency/worker.html[/url] is designed to run long tasks in the background and to report back to the caller when finished [I]"SwingWorker implements java.util.concurrent.Future. This interface allows the background task to provide a return value to the other thread. Other methods in this interface allow cancellation of the background …

Member Avatar for JamesCherrill
0
148
Member Avatar for cik ain

[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] I guess you missed this at the top of the forum main page?

Member Avatar for JamesCherrill
0
37
Member Avatar for sumeetdesaeee

This is a good explanation: [url]http://download.oracle.com/javase/tutorial/java/javaOO/nested.html[/url] This is a good example of one use for static classes: [url]http://www.javaworld.com/javaworld/javatips/jw-javatip106.html[/url]

Member Avatar for JamesCherrill
0
78
Member Avatar for TahoeSands

Beware the array "solution". It can be made to work, but its as un-Java as you can imagine. Youcan stuff anything into an array of Objects, but then you have to do unchecked casts to get them back and use them. There's no opportunity to hide the data behind a …

Member Avatar for JamesCherrill
0
957
Member Avatar for Megha SR

I guess you missed this on the main forum page: [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]

Member Avatar for Megha SR
0
105
Member Avatar for gretty

Small point: although both forms are legal, most Java coding standards prefer [CODE]int[] numArray[/CODE] rather than [CODE]int numArray[][/CODE] the logic being that its an array of ints, not an array of numArrays

Member Avatar for tong1
0
214
Member Avatar for developer@india

It has two possible values: [B]true [/B]and [B]false[/B]. What exactly do you want to know? eg: If I add a single boolean variable to my class how much bigger is each instance I create? or If I write a single boolean to a file how big is the file? or …

Member Avatar for ~s.o.s~
0
223
Member Avatar for emcyroyale

Looking at your code there seems to be an asymmetry between the encode and the decode. The encode stores an 8 bit value from an int into the red pixel. There's no messing about with individual bits. The decode gets an 8 bit value from the red pixel, but then …

Member Avatar for NormR1
0
144
Member Avatar for nagajyothi

It's very unlikely to be a problem with IE. It's almost certainly your code and/or the way you deployed it. Without the code and the exact error message there's nothing anyone here can do to diagnose it.

Member Avatar for javaAddict
0
99
Member Avatar for cac186

Absolutely yes. Read the values from the file (depends on how the file is formatted, but you know that already) and put them into the text fields. After that it's exactly the same as the program you've already got - ie user changes the values in the text fields and …

Member Avatar for NormR1
0
291
Member Avatar for tedtdu
Member Avatar for tedtdu

You can use Regex "lookarounds" to split at the <> delimiters while retaining the delimiters. For example: [CODE]String s = "<A><B>cde</B></A"; String[] a = s.split("(?=[<>])");[/CODE] gives the following array elements [CODE]<A > <B >cde </B > </A[/CODE] Which is 90% of the way there (ie you have <tag, </tag, or …

Member Avatar for JamesCherrill
0
126
Member Avatar for glenak

I want to suggest a different answer - I really don't like the repeated logical expression, and overall I don't think its any easier to understand. IMHO a major reason why it's hard to understand is the silly choice of variable name, and the use of the EOF code value …

Member Avatar for JamesCherrill
0
119
Member Avatar for vgd

Where is the { to match the } on line 9? Presumably its before line 1 somewhere, in which case the declaration of m in line 1 will go out of scope on line 9, which means there is no "m" defined at line 10.

Member Avatar for JamesCherrill
0
75
Member Avatar for ciali

Norm is right - that's a C-based language, probably just raw C. ciali: You have posted this in the worng forum - this one is for Java

Member Avatar for Adak
0
132
Member Avatar for anz2050

You can use the Runtime and Process classes in Java 6. You will find tutorials and code on the web.

Member Avatar for anz2050
0
248
Member Avatar for Sunshineserene

1. THis is an old thread, July 5th - 7th. 2. Most of the thread is a discussion about why you should not post solutions to other people's homework. So why did you post a solution? It's not even a good example of Java code.

Member Avatar for jon.kiparsky
1
526
Member Avatar for NewOrder

You can find the answers to many of these questions if you use Google and a bit of intelligent work. But here's the answer to two that are not so easy to find... System.out is the Java console, which is the window where you ran the program if you're using …

Member Avatar for NewOrder
0
237
Member Avatar for junichiro90

No, it's not the only way, but it's the way that people use 99% of the time. You will find some excellent tutorials on the web for using Java with a database. I recommend this one: [url]http://download.oracle.com/javase/tutorial/jdbc/index.html[/url] It's quite a lot to understand and learn, but its an essential basic …

Member Avatar for JamesCherrill
0
126
Member Avatar for prem2

Static methods can access staic members of the same class, or instance members via an instance of the class. Instance methods can access static members of the class, instance members of the same instance, or instance members of another instance via that instance. Where "member" is a variable or a …

Member Avatar for jon.kiparsky
0
1K
Member Avatar for DARK_BYTE

"its doesn't work as it should" gives us absolutely nothing to work with! How/why/where doesn't it "work"? Put more System.out.println statements at strategic points in your code so you can see exactly what is being executed and what isn't, and what values the variables have.

Member Avatar for JamesCherrill
0
103
Member Avatar for toferdagofer

do you mean something like: [CODE]public int askUserForChoice() { // do all the stuff with the dialog box as above return choice; } ... int chosenOption = askUserForChoice(); switch (chosenOption); // etc[/CODE]

Member Avatar for toferdagofer
0
139
Member Avatar for Nitu Khanna

[QUOTE]Check your XML to make sure it is correct. The markup in the document following the root element must be well-formed.[/QUOTE] Did you?

Member Avatar for JamesCherrill
0
644
Member Avatar for Megha SR

I assume your Google and Wikipedia are both broken at the moment? If you tell me what search you would like done I can Google it for you and post the results back here.

Member Avatar for JamesCherrill
0
98
Member Avatar for Xufyan

If you absolutely must use a switch then you can code this with 26 cases each for upper & lower case chars: case 'a': case 'b': ... case 'z': // convert to upper case; break; case 'A': case 'B': ... case 'Z': // convert to lowercase; break;

Member Avatar for Xufyan
0
260
Member Avatar for anushri

Yo nick, norm is right. the O/P needs tough love; teach him, don't just fix this one problem.

Member Avatar for nickguletskii
0
171
Member Avatar for Melow

Sorry Norm, it looks OK to me. There is a constructor that takes an Image, and ImageIcon is appropriate.

Member Avatar for tong1
0
164
Member Avatar for pallavigupta117

When the user clicks the button you call init() (with a flag set), which always creates a new window from scratch. Rather than keep on adding & removing buttons, why not add panop2, but set its visibility to false. Then in the button handler you just have to make panop2 …

Member Avatar for JamesCherrill
0
166
Member Avatar for vhea

this [url]http://download.oracle.com/javase/tutorial/uiswing/components/icon.html[/url] explains how to do it.

Member Avatar for JamesCherrill
-1
105
Member Avatar for Aanchal89
Member Avatar for JamesCherrill

I have a problem involving Generics. Here's a simplified version: Suppose I have a generic method to add a new element to a (possibly empty) ArrayList, like this: [CODE]<T> void addNewTo(ArrayList<T> list)[/CODE] What I need to do is to determine the correct class for the ArrayList elements so as to …

Member Avatar for JamesCherrill
0
192
Member Avatar for NT.

Both classes need to be in the same package, OR you have to import class A at the start of B.java

Member Avatar for JamesCherrill
0
90
Member Avatar for erogol

Sounds like you should use a Collection (eg ArrayList) of textfields. OR maybe a HashMap to link the textfields to the corresponding "stuffs". Either way, these classes are more flexible and easier to work with than arrays.

Member Avatar for JamesCherrill
0
203
Member Avatar for dinkpwns

If you ensure that you have no remaining references to the "old" data, then it will definitely be garbage collected before the JVM runs out of memory and throws an "out of memory". (In a complex program it's all too easy to leave an object in a List somewhere which …

Member Avatar for dinkpwns
0
166
Member Avatar for SeanC

If a variable is null, you can't test its length - it hasn't got a length!. Use var == null

Member Avatar for SeanC
0
153
Member Avatar for Member 784374

[QUOTE]StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.[/QUOTE] Source: JDK 6 API [url]http://download.oracle.com/javase/6/docs/api/java/util/StringTokenizer.html[/url] String's split method will return what you …

Member Avatar for Member 784374
0
69
Member Avatar for aditya027

The reason for this is that when you instantiate a subclass its constructor automatically calls the constructor(s) of it superclasses, so all the variables etc associated with the superclasses are initialised properly. However, when you instantiate the superclass none of the subclass contructors are called, so none of the subclasses …

Member Avatar for aditya027
0
113
Member Avatar for surk23

JButtons, kike all JComponents have a really useful but much neglected property called "clientProperty", which is a hashtable into which you can put whatever key/vlaue pairs you want with putClientProperty(key, value), and retrieve the values with getClientProperty(key). Depending on how your buttons are supposed to behave you can use this …

Member Avatar for tong1
0
1K
Member Avatar for java_programmer

Specifying a full path guarantees that your app won't run on another machine, and using the class path won't work if multiple users are running the same app. Much better to use [CODE]System.getProperty("user.home")[/CODE] to get a reference to the user's home directory, and put the file there, eg [CODE]new File(System.getProperty("user.home") …

Member Avatar for ~s.o.s~
0
1K
Member Avatar for Mirage'

Why are you getting the values from System.in when you have an InputDialog? JOptionPane.showInputDialog returns a String (the user's input), but you are ignoring it.

Member Avatar for Mirage'
0
234
Member Avatar for sitajaf

1/2 If they are all on the same subnet youy may be able to use UDP broadcasts, otherwize you will need a shared server of some sort.

Member Avatar for NormR1
0
109
Member Avatar for spadusca

It just creates a File object that refers to the file with that path & name, but it doesn't actually do anything with it (not even check if the file exists!). You can then call methods on that File object to test if it exists, open it and read it …

Member Avatar for JamesCherrill
0
150
Member Avatar for prem2

^ like he said. But remember that the map actually contains references to the key and value objects, not the objects themselves, so even if your key or value objects are enormous, you can still create a hashmap with millions of references to them. In practice you will nromally run …

Member Avatar for JamesCherrill
0
92
Member Avatar for $harmi

[QUOTE]Recompile with -Xlint:deprecation for details. [/QUOTE] did you?

Member Avatar for JamesCherrill
0
85
Member Avatar for Sunshineserene

HashMap (look it up in the API). Add the 3 letter codes as keys and the 1 letter codes as values. HashMap then does the lookup for you, value = map.get(key).

Member Avatar for java_programmer
0
185

The End.