|
Snake X
|
 |
« on: 26 May, 2011, 02:34:53 » |
0
|
My friend saved his project to my computer so that I could try to get help for him. He is working on a slot machine and however.. The only button added fills the whole entire screen  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
| import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Random; import java.util.*;
public class cactus extends JApplet implements ActionListener {
Image s = getImage(getCodeBase(), "spin.jpg"); ImageIcon spin = new ImageIcon(s);
Random r = new Random();
Container contentArea;
String x = ("spin");
JButton FIRE = new JButton("spin");
JLabel slot11,slot12,slot13,slot21,slot22,slot23,slot31,slot32,slot33;
JLabel win = new JLabel("you have won congratz");
JLabel lose = new JLabel("hahahahahahahahahahaha you lose. GLaDos won. have a nice day =3");
Graphics g;
public void init() { contentArea = getContentPane(); contentArea.setBackground(Color.PINK); FlowLayout manager = new FlowLayout(); contentArea.setLayout(manager); FIRE.addActionListener(this); FIRE.setEnabled(true); contentArea.add(FIRE); setContentPane(contentArea); } public void actionPerformed(ActionEvent event) { Image Lemon = getImage(getCodeBase(), "a.jpg"); ImageIcon pica = new ImageIcon(Lemon); Image Cherry = getImage(getCodeBase(), "b.jpg"); ImageIcon picb = new ImageIcon(Lemon); Image randomCelebrity = getImage(getCodeBase(), "c.jpg"); ImageIcon picc = new ImageIcon(randomCelebrity);
if(event.getSource()==FIRE) { int random1 = r.nextInt(3)+1; int random2 = r.nextInt(3)+1; int random3 = r.nextInt(3)+1;
slot11 = new JLabel(pica); slot12 = new JLabel(picb); slot13 = new JLabel(picc);
slot21 = new JLabel(pica); slot22 = new JLabel(picb); slot23 = new JLabel(picc);
slot31 = new JLabel(pica); slot32 = new JLabel(picb); slot33 = new JLabel(picc);
contentArea.removeAll(); setContentPane(contentArea);
//random1 if(random1==1){ contentArea.add(slot11); contentArea.add(FIRE);
setContentPane(contentArea); } if(random1==2){ contentArea.add(slot12); contentArea.add(FIRE); } if(random1==3){ contentArea.add(slot13); contentArea.add(FIRE); } //random2 if(random2==1){ contentArea.add(slot21); contentArea.add(FIRE);
setContentPane(contentArea); } if(random2==2){ contentArea.add(slot22); contentArea.add(FIRE);
setContentPane(contentArea); } if(random2==3){ contentArea.add(slot23); contentArea.add(FIRE);
setContentPane(contentArea); } //random3 if(random3==1){ contentArea.add(slot31); contentArea.add(FIRE);
setContentPane(contentArea); } if(random3==2){ contentArea.add(slot32); contentArea.add(FIRE);
setContentPane(contentArea); } if(random3==3){ contentArea.add(slot33); contentArea.add(FIRE);
setContentPane(contentArea); }
if ((random1 == 1 && random2 == 1 && random3 == 1) || (random1 == 2 && random2 == 2 && random3 == 2) /*|| (random1 == 3 && random2 == 3 && random3 == 3))*/) { win.setFont(new Font("wingdings2", Font.BOLD, 42)); win.setForeground(Color.red); contentArea.remove(win); contentArea.add(win); setContentPane(contentArea); } else { contentArea.add(lose); setContentPane(contentArea); } } } }
|
|
|
|
|
|
Logged
|
There's a Zombie for that™
|
|
|
|
|
|