Matt Fyffe

+ Follow
since Jun 19, 2003
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Matt Fyffe

Well, I'm getting some weird problems in my programs. In the first code example, ALL of the JSpinners work except for stats[3], which when clicked pops up a screen that spams out a million messages. I dont understand why the others work but that one fails to.
In the second code example, everything appears fine except the two jbuttons are nowhere to be seen! Can anyone explain why that is happening? Thanks!

Edited to break long line. - Barry
[ July 20, 2003: Message edited by: Barry Gaunt ]
19 years ago
hah! thanks a lot mate... time to get digging .
19 years ago
Hey, I recently added a save/load feature to my program and because of it... I figured out something odd about my programs. Whenever I use outside stuff in my program (images, sounds) I had to enter the direct address. However, now that I have the save feature, I discovered that my program places all files into the j2sdk1.4.1_03
folder and reads all files from there. So, if I want to read a file without its direct address, I must place it in that folder. Is there a way I can make the compiler (I use bluej) read and load files from my folder elsewhere on the computer? Thanks a lot.
19 years ago
I've added JSpinners to my program and they look beautiful. I used JSpinnerNumberModel to display the value and so it shows an int between 0 and 10. My problem of course as there is always a problem when I make a new topic, is reading the number on the JSpinner when it changes.
In a previous topic, someone suggested using the command:
int i = ((Integer)stats[x].getValue()).intValue();
the value this reads is unknown to me, IF it reads a value as when I create a JOptionPane displaying this value, the JOptionPane isn't created. I tried using .getInt() rather than .intValue() as someone else suggested but I received an error stating cannot resolve symbol.
How is it that I can find out the value? And also, how can I set it's value? I assume I will have the same problem converting an int to an object as I do an object to an int.
Thanks. and PLEASE help me... these things are driving me nuts lol.
19 years ago
Music, the beauty of life (well not really) has expressed a desire to enter into my program. I am going to have a song playing in the background for my program and my question is, how do I make it so it's not the direct address of the file? I managed to finally get it with images using this code:

So how do I have music work with the same simplified address location? I found a way to play my song in the prog in an example in my friends book so here's the code I used if it need's to be referenced to. Also, is there an easier way to make the music play in the background? I hate threads lol. Thanks for all help you guys can and do provide me with everytime i bother you.
19 years ago
Well, I'm not sure if this would cause it or not, but you don't have a constructor in game that has no arguements but that is what you are calling in that line. If that's not it, I'm out of ideas.
19 years ago
o lol, I didn't realize it was that simple . Thanks a lot.
How do I add something to the classpath? If you mean put it in the same folder, I guess I've got that done... Using the code it compiles fine, however when I run it tells me nullPointer Exception and that it is currently null?
[ July 09, 2003: Message edited by: Matt Fyffe ]
19 years ago
nm, I got it to work... thanks a lot for the suggestion!
[ July 10, 2003: Message edited by: Matt Fyffe ]
19 years ago
Ack, binary... I hate that stuff. Well assuming you know the way binary works with powers of 2, let me see if I can word it better. When you have a signed int, it includes both positive and negative values. When written in binary if you have 8 bits (0000 0000) the bit on the far left would be the one that shows whether or not this number is positive or negative. If the number is positive, then the leftmost bit would be 0. If negative, 1.
Because this bit is used to show whether or not the value is positive, you are left with only 7 bits to show the actual value.
I hope that sums everything up, and if not, I'm sure someone else can reprimand me :-D.
19 years ago
Hey, I'm trying to make my program use only one JFrame instead of popping up new windows everytime it changes the screen. To do this I made a control class that would load the JPanel, wait until the JPanel finished what it had to do, then would remove it and place the next JPanel on the screen. Well, my JPanels don't seem to like that as when I try to remove the one JPanel, it simply keeps the button it clicked pressed down and no longer works. If this is not possible, is there a way I can command my JFrame to close? Here's the methods code. Note: It loads up the MainMenu class, and then the user clicks the button newGame. This is the point where it locks up. Is there a problem in my ActionPerformed class?

19 years ago
My next area of intrigue (besides the ever plaguing JSpinners) is closing a window on command. In the program I made (for better or worse) when you click on some buttons, I have the program bring you to an entirely new window. However, when it brings the user to this entirely new window, the one the person just left from is still up. Is there a way I can tell the class to end itself?
Example: User is at the main menu and clicks new game. This loads up a new window where the player can create his character. However, the main menu screen is still up. How can I make it so when the new window is created, the old one closes?
I tried using setDefaultCloseOperation(EXIT_ON_CLOSE); but that closed all my windows, not just the selected one. I have a feeling this is because that closes the program, not just the one part.
Thanks for any help you can give.
19 years ago
I think he wants to use keylistener for it... so then for your class name you have
implements KeyListener
and then you must include the methods
public void keyPressed(keyEvent e)
public void keyTyped(KeyEvent e)
public void keyReleased(KeyEvent e)
The methods can all be blank except keyTyped if you just want to read the key, so in keyTyped you could do e.getKeyCode() which would tell you which key was pressed. If the key pressed was a number, then you could store it into an array. And if the key pressed was enter, it could proccess what was stored in the array.
As for how to check if they key pressed was a number, I think you can find the different variable constants at the sun java class listing.
Here's an example of using keyPressed in one of my progs:

Can anyone confirm if I'm right or not? I want to help other people but I think maybe I should stick to being helped .
[ July 07, 2003: Message edited by: Matt Fyffe ]
19 years ago
sorry to bump this old topic but these JSpinners haven't stopped driving me nuts. How do i read and write to the JSpinner? I tried getValue but that returns an object which I haven't been able to successfully convert to an integer yet. With setValue its the opposite. I have an integer but how can I convert it to an acceptable object? Thanks. Note: This is using SpinnerNumberModel.
19 years ago
I've never heard of ClassLoader before and it's not covered in my book :-\. I figure if I do implement that, I'll save it for the end. I hope you didn't take it as me being an ass lol, just sounded to complicated for me when I looked it up.
19 years ago
Hrmm... When you phrase it like that... I think I'll just leave it as the direct file.
19 years ago