Results 1 to 1 of 1
- 07-06-2013, 12:44 AM #1Member
- Join Date
- Jul 2013
- Rep Power
Need help with netbeans, Jlabel and icons =[
Hows it going folks,
First off I'm very new at this. I've read through a basic online beginners tutorial (Java For Beginners - Contents Page for reference)
and I'm attempting to build a simple enough program that simulates the calculations done at a roulette table. I'm a dealer and it's something I think will be handy and develop my skills.
I'm using netbeans 7.2.1 and no idea about jdk but can find out if need be.
Anyway I've got most of the calculations down, a random number is chose for each bet on the winning number (right now the winning number doesnt change, its more of a training exercise for practising my mental calculations) so for example 3 chips on the top left corner, 4 on the top split etc.
Also have a class to calculate how many chips are owed depending on the amount in play (simple arithmetic) and a method to generate a random amount of cash to be taken out of total.
Now all of that I blundered my way through and got to work as I wanted as long as i had a basic layout of 9 labels in a box shape with one in the middle.
I looked up some info about images and went with the label-icon idea, creating a non-opaque background that looks like a roulette table with a panel on top to hold my bets. 9 seperate labels i want to change the icons on, based on the random number generated when i click the generate button.
Right now the relevant code looks like this:
String randomAddy1 = randomAddys;
String randomAddy2 = randomAddys;
String randomAddy3 = randomAddys;
String randomAddy4 = randomAddys;
String randomAddy5 = randomAddys;
String randomAddy6 = randomAddys;
String randomAddy7 = randomAddys;
String randomAddy8 = randomAddys;
String randomAddy9 = randomAddys;
ImageIcon chipIconNW = new ImageIcon(randomAddy1);
ImageIcon chipIconN = new ImageIcon(randomAddy2);
ImageIcon chipIconNE = new ImageIcon(randomAddy3);
ImageIcon chipIconE = new ImageIcon(randomAddy4);
ImageIcon chipIconSE = new ImageIcon(randomAddy5);
ImageIcon chipIconS = new ImageIcon(randomAddy6);
ImageIcon chipIconSW = new ImageIcon(randomAddy7);
ImageIcon chipIconW = new ImageIcon(randomAddy8);
ImageIcon chipIconC = new ImageIcon(randomAddy9);
Ok so before this I've taken the random numbers (1-5) corresponding to the different bets that were put in an int and placed the appropriate address
ie. 1chip.jpg if the number is 1 into the string.
This code is under the generate button method which initiates most of the calcs in my program.
I wanted the code to stick a picture of a chip with the right number on it where i want it.
Aligning things with gridbaglayout, and when i execute the program the icons do not appear.
I'm sure I'm confusing some pretty basic principles here but I am working without any mentoring or books so im kinda just stumbling round til something works. Thanks in advance for putting it up with me, i can add more code or email it if necessary.
- By ankit_k in forum AWT / SwingReplies: 4Last Post: 06-16-2011, 08:18 PM
- By PR0PHET in forum New To JavaReplies: 15Last Post: 11-15-2010, 09:29 PM
- By Bongeh in forum New To JavaReplies: 17Last Post: 04-06-2010, 11:02 PM
- By Krooger in forum New To JavaReplies: 3Last Post: 12-19-2009, 09:21 PM
- By dbashby in forum New To JavaReplies: 19Last Post: 10-10-2009, 04:27 PM