7,116 Posted Topics

Member Avatar for sid78669

For re-usability it would be better to return the long value, rather than set a fixed named variable that's declared elsewhere?

Member Avatar for ~s.o.s~
1
467
Member Avatar for reuel3
Member Avatar for utkarshsahu

It would be simpler to convert the position references directly to array indexes - eg `pos.charAt(0) - 'a'` returns 0 if pos starts with 'a', 1 for 'b', 2 for 'c' and `pos.charAt(1) - '1'`similarly for the numeric part. Now you have the i,j values to index the array of …

Member Avatar for JamesCherrill
0
377
Member Avatar for IcyFire

Problem is probably that because you are drawing the panel Java has no idea how big it should be. It's probably showing a preferred size of 0x0. It works in the center position because that gets all the available space after the other components have been positioned.Try setting a preferred …

Member Avatar for IcyFire
0
698
Member Avatar for Aditya_4

OK guys, that's enough repeating each other's posts. Tux4life made it perfectly clear the first time. Please don't just re-post the same answer without adding any new information.

Member Avatar for Aditya_4
0
205
Member Avatar for mukororokudo

That whole approach to solving it is hideously over-complex (and badly coded as Tux points out). The only problem was that the original delimiter string omitted blank. Ie instead of `"!.,"` it needs to be `" !.,"`

Member Avatar for JamesCherrill
0
230
Member Avatar for vishalonne
Member Avatar for Rajshri Patil
0
114
Member Avatar for trishtren

You can't mix object I/O and imageIO in a single file like that. ImageIO writes a single image in the desired format (jpg, png etc). The API doc also says " If there is already a File present, its contents are discarded.", so it's stricly one image per file. ObjectStreams …

Member Avatar for vishalonne
0
148
Member Avatar for sirlink99

> If the readLine() waits for an input what would be the most effective way of avoiding the alternating pattern read-write, and allow the program to function more like a chat room? To do that you need two threads. One loops waiting for the local user's readLine() and sending the …

Member Avatar for JamesCherrill
0
474
Member Avatar for daudiam

DataOutputStream outputs data in its raw binary form - eg always 4 bytes for an int PrintStream outputs data in a human-readable character format - so an int could be anything such as "0" or "-1234567"

Member Avatar for JamesCherrill
0
1K
Member Avatar for mumaga

A log file is incredibly useful when things go wrong, provided it has been written to disk. So for me, waiting until the end to write it is not a good idea because a crash may prevent it being written. I would write all the records ditrectly to the file …

Member Avatar for mumaga
0
152
Member Avatar for Neversleepin

The System.setOut and System.setErr methods redirect all console output to a print stream of your choice.

Member Avatar for subramanya.vl
0
148
Member Avatar for mumaga

> I feel it is a better practice to have only one class where you want to make the changes in No, not really. That will distort the class structure and force data items into one central class regardless of where they logically belong. Focus on words like "has a", …

Member Avatar for mumaga
0
269
Member Avatar for maduxi

You could build a HashMap<string, Integer> with the word as the key and a count as value. For every word in the file, if it's already in the Map add one to the count, if it's not already in the Map add it with a count of one. When you've …

Member Avatar for maduxi
0
345
Member Avatar for kjetyey4

alike234 Welcome to DaniWeb. Although your problem may be urgent to you, screaming for help *help* ***help*** isn't going to make it urgent for anyone here. You will get better results from a calm clear request (eg exactly what help do you need). Anyway - you posted a homework assignment, …

Member Avatar for john.w.austin.39
0
212
Member Avatar for fallen21468

If you move the code lines 12-17 into Skate's constructor then you can simply call `new Skate();` in your button's ActionListener

Member Avatar for fallen21468
0
1K
Member Avatar for mattsearle

Matt Two things you may have misunderstood... 1. This is not a "we do your homework" servce. Somebody may help you learn how to round your results, but nobody will just do it for you. 2. This is the Java forum. Java and JavaScript are not the same thing at …

Member Avatar for Taywin
0
193
Member Avatar for ibthevivin
Member Avatar for tux4life
0
208
Member Avatar for jalpesh_007

In this case the answer is trivial. Version 1 works, and version 2 doesn't. Your compiler will tell you the same thing. You can't cast from a String to an int. Check out the Java Language Spec section on casting to see the rules on what you can or cannot …

Member Avatar for JamesCherrill
0
113
Member Avatar for sofien.fkih

Have a look at the Calendar API - there's a method that tells you the day of the week.

Member Avatar for tux4life
0
100
Member Avatar for Noopit

In pseudo code it looks like: for i = 0 to 2 for j = 0 to 2 array[i][j] = the next character You have a number of ways to do "the next character", eg have a counter that tracks which is the next character, and increment it each time …

Member Avatar for tux4life
0
3K
Member Avatar for zlloyd1

exit(), not Exit(). Java is case-sensitive actionlisteners are for buttons etc, you seem to be trying to add one to a JFrame

Member Avatar for JamesCherrill
0
928
Member Avatar for durrat

> converting date and time into milliseconds doesnt seem the solution Why not? Just get the time now and the time when you want the reminder, convert both to mSec, then take the difference between them - that's how many mSec you need to wait for the reminder.

Member Avatar for durrat
0
143
Member Avatar for kedxu

Is that a java.util.Timer or a javax.swing.Timer? Some timers run from the previous execution, others run from the previous scheduled time even if the execution was delayed. You want the second type. The way to get a fixed-rate animation when the CPU loading is high (eg slow computer) is to …

Member Avatar for JamesCherrill
0
901
Member Avatar for patrick.ooi.96

Easiest way is to read the image file ito an ImageIcon, then simply use that in a JLabel http://docs.oracle.com/javase/tutorial/uiswing/components/icon.html

Member Avatar for Rajshri Patil
0
229
Member Avatar for runlevel3nut

There were significant changes in Jav at version 1.5, so anything older than that is not a good idea. The changes from 1.5 to the current 1.7 are useful, but not earth-shattering. But for reasonsof security fixes you should download/install only the latest version form Oracle. The tutorials on the …

Member Avatar for runlevel3nut
0
290
Member Avatar for jakubee

All anyone can tell from what you've posted is that you try to access element 13 in an ArrayList (client) that has 12 elements. The reason for that lies somewhere in all the other code that we haven't seen. First, decide whether the index is wrong, or the client list …

Member Avatar for JamesCherrill
0
251
Member Avatar for beep

Current Java is 1.7 (also called Java 7, just to confuse everybody). What exactly are you referring to with Java 9 or 10?

Member Avatar for JamesCherrill
-1
167
Member Avatar for tnimblett

It woiuld be nice if uou could use that syntax in Java, but you can't. It's not part of thelanguage. `-13683360 <= rgb` evaluates to a boolean (true/false) and then `(true/false) <= -13683381` is a bad operand because you cant't use <= with a boolean. You need to break it …

Member Avatar for tnimblett
0
108
Member Avatar for LALITVYAS

Start [here](http://docs.oracle.com/javase/tutorial/2d/images/index.html).

Member Avatar for JamesCherrill
0
86
Member Avatar for mumaga

Two possible approaches: 1. Make the currentRoom variable static and public, so other code can reference it as Game.currentRoom. - easy to do, but horrible misuse of O.O. practice. Not recommended! 2. Presumably there's some code in the Game class that creates new Inventory and Room instances. At that point …

Member Avatar for JamesCherrill
0
96
Member Avatar for tingwong

No 3.. interface A {void x();} interface B extends A {void y();} just try it. No 4. Depends on whether the class is defined as abstract or not (question is not clear) No 8. Java Language Spec says "This (multiple) interface inheritance allows objects to support (multiple) common behaviors without …

Member Avatar for stultuske
0
299
Member Avatar for tiggermesho
Member Avatar for sofien.fkih

There are a few ways to do this, but the easiest is probably the contains method: String s = "Hello from DaniWeb"; if (s.contains("from")) ...

Member Avatar for sofien.fkih
0
229
Member Avatar for meowmonkey

Hi Stultuske I think the OP's problem is a bit more interesting than that. Your solution only works if the desired length is a multiple of 3. As I understand it the requirement is y output - ------ 1 m 2 m/ 3 m// 4 m//m . ... 9 m//m//m// …

Member Avatar for NP-complete
0
242
Member Avatar for hamidvosugh

It's called an anonymous inner class, it defines a new subclass of Handler and creates an instance of it. Google *Java anonymous inner class* for tutorials etc.

Member Avatar for JamesCherrill
0
256
Member Avatar for trishtren

Perhasps use Regex instances to define each of the variants/replacements you are looking for? You could place all the current Regex's in an ArrayList and loop thru them regardless of how nany there are.

Member Avatar for JamesCherrill
0
175
Member Avatar for iamlaw

You haven't provided enough info for anyone to say what is the most appropriate solution - eg when and any are instances of A,B and C created and allowed to die? Maybe if you described what the problem really is that will help. [Here's](http://www.daniweb.com/software-development/java/threads/374909/inputoutput-with-multiple-forms) a discussion of one such real-life …

Member Avatar for RockJake28
0
189
Member Avatar for crash bash

Yet another post from crash bash that ignores the DaniWeb Member Rules, specifically "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Start following the rules, or I'll start deleting your offending posts.

Member Avatar for JamesCherrill
-1
45
Member Avatar for Ahmad93

I recently built a colliding multiple ball app to use in my tutorials, and found [this](http://www.gamedev.net/topic/627978-need-tips-on-collision-response-for-a-2d-ball-hitting-another-2d-ball-that-is-controlled-by-an-accelerometer/) web site. I adapted the code from there, and it looks pretty realistic to me.

Member Avatar for JamesCherrill
0
153
Member Avatar for laguardian

The "OO" way is to create a class for whatever it is you are entering and displaying. This class represents the data and logic for whatever it is, and is the true core of the application. Such classes are generally referred to as a "model". In your input form you …

Member Avatar for JamesCherrill
0
325
Member Avatar for riahc3

Apparently Intel processors from Ivy Bridge onwards have a hardware random number generator instruction that is as near quantum-mechanical noise random as you can be... http://software.intel.com/sites/default/files/m/d/4/1/d/8/441_Intel_R__DRNG_Software_Implementation_Guide_final_Aug7.pdf

Member Avatar for jalpesh_007
0
415
Member Avatar for crash bash

Add a node to what? The answer depends on what kind of data structure you are adding to. What have you tried so far?

Member Avatar for Taywin
0
85
Member Avatar for rachelmorg

Your double(a) method isn't going to work without a return value. All java method parameters are passed by value - the parameter in the method is a copy of the original value. The "a" that you are manipulating in your method is just a copy of the "a" reference that …

Member Avatar for JamesCherrill
0
142
Member Avatar for amit.hak50

DaniWeb Member Rules (which you agreed to when you signed up) include: "Do not hijack old threads by posting a new question as a reply to an old one" http://www.daniweb.com/community/rules Please start your own new thread for your question

Member Avatar for JamesCherrill
0
837
Member Avatar for Violet_82

Thta's not a whole program, it's just one class. That class will be combined with other classes to make a useful program. The other classes will then use the getters to access the Employee info.

Member Avatar for Violet_82
0
3K
Member Avatar for norsalwani.shasa

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you. DaniWeb Member Rules (which you agreed to when you signed up) …

Member Avatar for JamesCherrill
0
198
Member Avatar for subramanya.vl

Yes, keeping the variable private is a good idea, but stultuske's version is not thread safe, whereas the original version and the enum version are both thread safe.

Member Avatar for stultuske
0
167
Member Avatar for nickecarlo
Member Avatar for harinath_2007

The End.