• Our Minecraft servers are offline but we will keep this forum online for any community communication. Site permissions for posting could change at a later date but will remain online.

piano program proto1

namespace

Tribute
Joined
Feb 20, 2016
Messages
23
Reaction score
10
That's exactly the question I have. mb it's something with my pc or something but it always says "This variable might not have been initialized. Might re-download it or download another one/update JDK, because I can do it at school but not on my pc for some reason. I'll also what you said in number 2, I know know what you're getting at.

Using arrays will make it easier for other people to help me with my code and while I do plan to use loops I only know now for a fact that this will 100% work with my end product. While a loop very well may work, I just don't want to run into some stupid reason why I can't make what I want to work. Sounds weird but I'd have to write a whole bunch on why. Towards the end if it all goes correctly I'll replace all of my paintComponent method with a loop and also thanks for the help, really do appreciate it :)
Also, if you're actually thinking of developing this further you really should take into account that Java is Object-Oriented. So you should be using objects.

Iteration is a basic principle in most languages, don't be scared of it.
 

mfungamer

Career
Joined
Nov 16, 2013
Messages
901
Reaction score
340
Also since you know java I could use a bit of help: I made the audio file and re-edited the post. For some reason when I hit the key the sound plays but then the program freezes and crashes. Don't know whats going on you mind helping me out?
Is there a stacktrace? Might be because you issue another call of the Thread, while it is still sleeping. Since you pause it, but not the main thread, which may issue another call of the sub-thread then.
Maybe try to create a thread wich will loop over a list, play all included sounds, remove them and then sleeps for a bit.
Also maybe consider drawing on a panel as this allows you to easily reaarange your screen.
 
Joined
Sep 8, 2013
Messages
427
Reaction score
833
Is there a stacktrace? Might be because you issue another call of the Thread, while it is still sleeping. Since you pause it, but not the main thread, which may issue another call of the sub-thread then.
Maybe try to create a thread wich will loop over a list, play all included sounds, remove them and then sleeps for a bit.
Also maybe consider drawing on a panel as this allows you to easily reaarange your screen.

I updated the code a long time ago just never posted bc everything was going just fine. Running into more bugs now so I might start posting again ;)

I made the code a lot shorter as well, I was being stupid earlier.
 

Members online

No members online now.

Forum statistics

Threads
242,193
Messages
2,449,633
Members
523,972
Latest member
Atasci