Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Need assistant in placing random number generator for my codes. Help...please..

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assistant on my codes. SOS!!
Hi,

I've already created the layout. I am creating a game call "Toto". User will click on the Button Winning Numbers and a random winning number will appear above the button "Winning Numbers". The problem is Im stuck in creating the random number generator. The random number can only generates till 45. Need help please..

Thank You.

Here is my codes which I have done.


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.awt.Color;
import java.util.Random; // For random number generator
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Toto extends JApplet
{
JTextField tf1, tf2, tf3, tf4, tf5, tf6; // User to place his bet numbers.
JLabel lbl1, lbl2, lbl3, lbl4, lbl5, lbl6, lbl7, lbl8, lbl9, lbl10, lbl11;
JButton bWinningNumbers, bBet, bReset;
JPanel p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, pp1;
JCheckBox jcbPopcorn, jcbDrinks;


Vector v = new Vector();

public void init()
{
//p1 = new JPanel(new GridLayout(8,1));
p1 = new JPanel();
p1.setLayout(new FlowLayout());
lbl1 = new JLabel("********************************");

p2 = new JPanel();
lbl2 = new JLabel("***** TOTO BETTING MACHINE *****");
lbl2.setFont(new Font("TimesRoman", Font.BOLD, 12));

// lbl2.setForeGround(Color.BLUE);

p3 = new JPanel();
lbl3 = new JLabel("********************************");

p1.add(lbl1);
p2.add(lbl2);
p3.add(lbl3);

p5 = new JPanel();
p5.setLayout(new FlowLayout());
bWinningNumbers = new JButton("WINNING NUMBER!!!");
// bWinningNumbers.addActionListener(new Select());
p5.add(bWinningNumbers);




p6 = new JPanel();
p6.setLayout(new FlowLayout());
lbl5 = new JLabel("===== Each Bet Cost $5 =====");
lbl5.setFont(new Font("TimesRoman", Font.ITALIC, 12));

p6.add(lbl5);

p7 = new JPanel();
p7.setLayout(new FlowLayout());
lbl6 = new JLabel("- Please Input Numbers Between 1 to 45 -");
lbl6.setFont(new Font("TimesRoman", Font.ITALIC, 13));

p7.add(lbl6);

p8 = new JPanel(); p8.setLayout(new FlowLayout());


tf1 = new JTextField(3);
tf1.setBackground(Color.RED);
tf1.setForeground(Color.CYAN);

tf2 = new JTextField(3);
tf2.setBackground(Color.YELLOW);
tf2.setForeground(Color.RED);

tf3 = new JTextField(3);
tf3.setBackground(Color.GREEN);
tf3.setForeground(Color.BLACK);

tf4 = new JTextField(3); tf4.setBackground(Color.RED);
tf4.setForeground(Color.CYAN);

tf5 = new JTextField(3); //User place betting number
tf5.setBackground(Color.YELLOW);
tf5.setForeground(Color.RED);


tf6 = new JTextField(3); //User place betting number
tf6.setBackground(Color.GREEN);
tf6.setForeground(Color.BLACK);


p8.add(tf1); //Textfield is added in the panel(p8)
p8.add(tf2); //Textfield is added in the panel(p8)
p8.add(tf3); //Textfield is added in the panel(p8)
p8.add(tf4); //Textfield is added in the panel(p8)
p8.add(tf5); //Textfield is added in the panel(p8)
p8.add(tf6); //Textfield is added in the panel(p8)




p9 = new JPanel();
p9.setLayout(new FlowLayout());
bBet = new JButton("BET"); //For button "BET"
lbl7 = new JLabel("Click On Winning Numbers"); //Between Button Bet and Rest
bReset = new JButton("RESET"); //For button "RESET"
p9.add(bBet);
p9.add(lbl7);
p9.add(bReset);


p10 = new JPanel();
p10.setLayout(new FlowLayout(FlowLayout.LEFT));
lbl8 = new JLabel("Money available: $ ");
p10.add(lbl8);
//lbl10 = new JLabel("");
//p10.add(lbl10);

p11 = new JPanel();
p11.setLayout(new FlowLayout(FlowLayout.LEFT));
lbl9 = new JLabel("Accumulated Bet Amount: $ ");
p11.add(lbl9);
//lbl11 = new JLabel();
//p11.add(lbl11);

pp1 = new JPanel(); // The main Panel for the programme.
pp1.add(p1); // Individual panel in the main panel.
pp1.add(p2); // Individual panel in the main panel.
pp1.add(p3); // Individual panel in the main panel.
pp1.add(p5); // Individual panel in the main panel.
pp1.add(p6); // Individual panel in the main panel.
pp1.add(p7); // Individual panel in the main panel.
pp1.add(p8); // Individual panel in the main panel.
pp1.add(p9); // Individual panel in the main panel.
pp1.add(p10); // Individual panel in the main panel.
pp1.add(p11); // Individual panel in the main panel.

add(pp1);

setVisible(true); //Add pp1 for the main panel.

}
}// end of programme
[originally posted on jforum.net by sya1912]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic