SeederDialog
Wouldn’t it be nice if there were
a modal dialog that used a Seeder to generate a
seed value? And wouldn’t it be nice if the dialog had a
progress bar that showed how far along the generation was? I’ll
develop this nice dialog now.
SeederDialog is designed to make it easy to
integrate Seeder into your application. Create
one, show it, and retrieve the seed value as follows:
SeederDialog sd = new SeederDialog(this, 20); sd.show(); byte[] seed = sd.getSeed();
The dialog itself is shown in Figure 4.1. As the user types characters, the progress bar fills up. When the seed is fully generated, the dialog goes away.
![]() |
SeederDialog is both an
ActionListener and a
KeyListener. It receives an
ActionEvent from its Seeder
when the seed is fully generated. It receives the same
KeyEvents as the Seeder, which
allows it to update the progress bar.
package oreilly.jonathan.awt;
import java.awt.*;
import java.awt.event.*;
import oreilly.jonathan.util.*;
public class SeederDialog
extends Dialog
implements ActionListener, KeyListener {Internally, the dialog contains a Seeder object
and a progress bar. (The progress bar is type
oreilly.jonathan.awt.ProgressBar. I’ll
present the code at the end of this section.)
ProgressBar mProgressBar; Seeder mSeeder;
SeederDialog’s constructor accepts a parent
Frame and a number of seed bytes. It creates itself as a modal dialog ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
