
-----------------------------------
hemin92
Wed Jan 14, 2009 6:21 pm

Random Output
-----------------------------------
i trying to make a program that gives a list of tv manufacturers and their price range. I have another box that says in stock and out of stock and  gives the stores to get it from. I want to be able to click on a tv type and the stock box will randomly say in stock or out of stock how do i do this? Here is my code so far:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;        
import java.util.*;

public class TvManufacturer implements ActionListener {
 JFrame frame;
 JPanel contentPane;
 JComboBox tvNames;
 JComboBox Stock;
 JLabel tvListPrompt, Price,Store;
 
    public TvManufacturer(){
        /* Create and set up the frame */
        frame = new JFrame("TV Manufacturer (EDITION 10.0)");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        /* Create a content pane with a BoxLayout and empty borders */
        contentPane = new JPanel();
        contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
        contentPane.setBorder(BorderFactory.createEmptyBorder(9, 0, 100, 100));
        
     /* Create a combo box and a descriptive label */
     tvListPrompt = new JLabel("Select a Manufacturer:");
    tvListPrompt.setAlignmentX(JLabel.RIGHT_ALIGNMENT);
     contentPane.add(tvListPrompt);
      
     /* Create a combo box and a descriptive label */
     tvListPrompt = new JLabel("Stock Check: ");
     tvListPrompt.setAlignmentX(JLabel.LEFT_ALIGNMENT);
     contentPane.add(tvListPrompt);
      
    String

The code with the arrow is  what i  want to randomly show when a tv brand is selected



Mod Edit: Remember to use syntax tags! Thanks :) [syntax="java"]Code Here[/syntax]

-----------------------------------
hemin92
Thu Jan 15, 2009 8:15 pm

Re: Random Output
-----------------------------------
I need help!! Can someone please tell me how to do random out?

-----------------------------------
Insectoid
Thu Jan 15, 2009 8:56 pm

RE:Random Output
-----------------------------------
Math.random()

-----------------------------------
HeavenAgain
Thu Jan 15, 2009 9:11 pm

RE:Random Output
-----------------------------------
basically have a look at the following 2 methods.
import java.util.Random;

public class RandomNumber
{
	public static void main(String
take a look at the API on these 2 approaches
http://java.sun.com/javase/6/docs/api/java/lang/Math.html#random()http://java.sun.com/javase/6/docs/api/java/util/Random.html

-----------------------------------
hemin92
Fri Jan 16, 2009 10:23 am

Re: Random Output
-----------------------------------
How do i incorporate random into my program i don't know how to
