random « Development « Java Swing Q&A





1. How to generate a random value?    coderanch.com

Hello I was wondering if anyone knows how to gerenerate a raddom variable about a certain number. For example if I wanted to generate a random number about 10 then the numbers 8, 9, and 11 and 12 would be very very common..well much more common that 1 and 2 and 3 and 20 and so on. Any ideas or code? ...

2. How to generate a random value about a value! Enjoy    coderanch.com

Hello, I posted a question ealier about how to generate a random value about a number. Well someone gave me some advice. SO here it is folks. Enjoy. use : import java.util.Random; int value= (int) ((new Random().nextGaussian()*20)+100 ); this code will generate values about 100 plus or minus 20. Hence values will range from 80 to 120. And it will do ...

3. word on random location    coderanch.com

Could anybody tell me how I can make a simple window in which a word appears for 1 second, on a random location, each time the "enter" key is pressed? I tried to do this in JDK 1.3.1, but since I'm new to OOP I'm still messing up the classes and objects a bit. Should be only a few lines, though. ...

4. [SOLVED] How to generate a random number from chi-square    java-forums.org

This isn't exactly a Swing question (this is the Swing forum). Have you had a look at Google first? What have you found there? Likely you'll need to download the chi-square data tables from some source. SourceForge may have some useful public domain code for this, but again, likely you best bet will be Google. Best of luck.

5. Random size of JComponent    java-forums.org

6. Random numbers    java-forums.org

import java.math.Random; import javax.swing.table.AbstractTableModel; public void RandomTableModel extends AbstractTableModel { private int _rows; private int _cols; private Random _random; public RandomTableModel(int numRows, int numCols) { _rows = numRows; _cols = numCols; _rand = new Random(System.currentTimeMillis()); } public int getRowCount() { return _rows; } public int getColumnCount() { return _col; } public Object getObjectAt(int row, int col) { return new Integer(_rand.nextInt(100)); // ...

7. GUI appears grey until resize randomly. Why?    java-forums.org

import javax.swing.*; import java.awt.*; public class Playback extends JFrame { public Playback() { setTitle("Note Trainer"); setSize(370,360); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); FlowLayout flo = new FlowLayout(); setLayout(flo); JLabel pageLabel = new JLabel("Web page address: ", JLabel.LEFT); JTextField pageAddress = new JTextField("He", 20); add(pageLabel); add(pageAddress); JButton A = new JButton("A"); JButton B = new JButton("B"); JButton C = new JButton("C"); JButton D = new JButton("D"); ...