001: /*
002: * $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/utils/gui/WorkingDialog.java,v 1.1 2005/04/20 21:05:01 paulby Exp $
003: *
004: * Sun Public License Notice
005: *
006: * The contents of this file are subject to the Sun Public License Version
007: * 1.0 (the "License"). You may not use this file except in compliance with
008: * the License. A copy of the License is available at http://www.sun.com/
009: *
010: * The Original Code is Java 3D(tm) Fly Through.
011: * The Initial Developer of the Original Code is Paul Byrne.
012: * Portions created by Paul Byrne are Copyright (C) 2002.
013: * All Rights Reserved.
014: *
015: * Contributor(s): Paul Byrne.
016: *
017: **/
018: package org.jdesktop.j3dfly.utils.gui;
019:
020: /**
021: * @author Paul Byrne
022: * @version 1.10, 01/18/02
023: */
024: public class WorkingDialog extends javax.swing.JDialog implements
025: WorkMonitor {
026:
027: private int maxProgress = -1;
028: private int currentProgress = 0;
029:
030: /** Creates new form WorkMonitor */
031: public WorkingDialog(java.awt.Frame parent) {
032: super (parent, false);
033: initComponents();
034: pack();
035:
036: if (parent != null)
037: setLocation(parent.getWidth() / 2 - getWidth() / 2, parent
038: .getHeight()
039: / 2 - getHeight() / 2);
040: }
041:
042: /** This method is called from within the constructor to
043: * initialize the form.
044: * WARNING: Do NOT modify this code. The content of this method is
045: * always regenerated by the FormEditor.
046: */
047: private void initComponents() {//GEN-BEGIN:initComponents
048: jPanel1 = new javax.swing.JPanel();
049: titleLabel = new javax.swing.JLabel();
050: progressTF = new javax.swing.JTextField();
051: jLabel1 = new javax.swing.JLabel();
052: setTitle("Loading....");
053: addWindowListener(new java.awt.event.WindowAdapter() {
054: public void windowClosing(java.awt.event.WindowEvent evt) {
055: closeDialog(evt);
056: }
057: });
058:
059: jPanel1.setLayout(new java.awt.GridBagLayout());
060: java.awt.GridBagConstraints gridBagConstraints1;
061: jPanel1.setPreferredSize(new java.awt.Dimension(250, 80));
062: jPanel1.setBorder(new javax.swing.border.EtchedBorder());
063: jPanel1.setMinimumSize(new java.awt.Dimension(250, 80));
064:
065: titleLabel.setText("Loading, Please Wait...");
066: gridBagConstraints1 = new java.awt.GridBagConstraints();
067: gridBagConstraints1.insets = new java.awt.Insets(0, 6, 8, 0);
068: jPanel1.add(titleLabel, gridBagConstraints1);
069:
070: progressTF.setColumns(5);
071: progressTF.setText("jTextField1");
072: progressTF.setMinimumSize(new java.awt.Dimension(57, 21));
073: gridBagConstraints1 = new java.awt.GridBagConstraints();
074: gridBagConstraints1.gridx = 0;
075: gridBagConstraints1.gridy = 1;
076: gridBagConstraints1.insets = new java.awt.Insets(0, 0, 0, 4);
077: gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST;
078: jPanel1.add(progressTF, gridBagConstraints1);
079:
080: jLabel1.setText("Elapsed time");
081: gridBagConstraints1 = new java.awt.GridBagConstraints();
082: gridBagConstraints1.gridx = 1;
083: gridBagConstraints1.gridy = 1;
084: gridBagConstraints1.insets = new java.awt.Insets(0, 0, 0, 6);
085: jPanel1.add(jLabel1, gridBagConstraints1);
086:
087: getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
088:
089: }//GEN-END:initComponents
090:
091: /** Closes the dialog */
092: private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
093: setVisible(false);
094: dispose();
095: }//GEN-LAST:event_closeDialog
096:
097: /**
098: * Display a note about the current activity
099: */
100: public void setNote(String note) {
101: }
102:
103: /**
104: * Indicate progress is being made
105: */
106: public void setProgress(int progress) {
107: progressTF.setText(Integer.toString(progress));
108: currentProgress = progress;
109: toFront();
110: if (currentProgress == maxProgress || currentProgress == -1) {
111: setVisible(false);
112: dispose();
113: }
114: }
115:
116: /**
117: * Set the maximum size of the progress.
118: *
119: * When maxProgress is reached the dialog will be close
120: */
121: public void setMaxProgress(int maxProgress) {
122: this .maxProgress = maxProgress;
123: }
124:
125: // Variables declaration - do not modify//GEN-BEGIN:variables
126: private javax.swing.JPanel jPanel1;
127: private javax.swing.JLabel titleLabel;
128: private javax.swing.JTextField progressTF;
129: private javax.swing.JLabel jLabel1;
130: // End of variables declaration//GEN-END:variables
131:
132: }
|