Methods Summary |
---|
private void | initActions()
quitMenuItem.addActionListener (new QuitAction());
BlockingLoadAction blocker = new BlockingLoadAction();
blockButton.addActionListener (blocker);
blockMenuItem.addActionListener (blocker);
NonBlockingLoadAction nonBlocker = new NonBlockingLoadAction();
dontBlockButton.addActionListener (nonBlocker);
dontBlockMenuItem.addActionListener (nonBlocker);
|
private void | initMainLayout()
urlField = new JTextField (DEFAULT_URL, 60);
JPanel topPanel = new JPanel ();
topPanel.setLayout (new BoxLayout (topPanel, BoxLayout.Y_AXIS));
topPanel.add (urlField);
JPanel buttonPanel = new JPanel();
blockButton = new JButton ("Load (blocking)");
dontBlockButton = new JButton ("Load (non-blocking)");
buttonPanel.add (blockButton);
buttonPanel.add (dontBlockButton);
topPanel.add (buttonPanel);
contentArea = new JTextArea (25, 60);
JScrollPane scroller =
new JScrollPane (contentArea,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
getContentPane().setLayout(new BorderLayout());
getContentPane().add (topPanel, BorderLayout.NORTH);
getContentPane().add (scroller, BorderLayout.CENTER);
progressBar = new JProgressBar (0, 100);
getContentPane().add (progressBar, BorderLayout.SOUTH);
|
private void | initMenus()
JMenuBar bar = new JMenuBar();
JMenu fileMenu = new JMenu ("File");
blockMenuItem = new JMenuItem ("Load (blocking)");
dontBlockMenuItem = new JMenuItem ("Load (non-blocking)");
fileMenu.add (blockMenuItem);
fileMenu.add (dontBlockMenuItem);
fileMenu.addSeparator();
quitMenuItem = new JMenuItem ("Quit");
fileMenu.add (quitMenuItem);
bar.add (fileMenu);
setJMenuBar (bar);
|
public static void | main(java.lang.String[] args)
AWTBlockModels awtbm = new AWTBlockModels();
awtbm.pack();
awtbm.setVisible (true);
|
private void | makeProgressBarUpdaterFor(AWTBlockModels$NonBlockingURLDocument nbud)
final NonBlockingURLDocument updatingDoc = nbud;
updateProgressBar (0);
ActionListener callback = new ActionListener() {
public void actionPerformed (ActionEvent ev) {
progressBar.setEnabled (true);
int progress = (int) (updatingDoc.getProgress() * 100);
updateProgressBar (progress);
if (! updatingDoc.isAlive())
progressBarUpdater.stop();
}
};
progressBarUpdater = new javax.swing.Timer (2000, callback);
progressBarUpdater.start();
|
private void | updateProgressBar(int progress)
// System.out.println ("update progress bar: " + progress);
if (progress > 0) {
progressBar.setValue (progress);
}
else
progressBar.setEnabled (false);
|