2 import java
.awt
.event
.*;
4 import javax
.swing
.border
.*;
6 public class StatusWindow
extends JFrame
9 private JProgressBar progressBar
= null;
10 private JTextField statusLabel
= null;
11 private JButton cancelButton
= null;
12 private JFrame statusWindow
= null;
13 private PostNewsgroup mainWindow
= null;
15 private final int MAXPROGRESS
= 13;
16 private final int MINPROGRESS
= 0;
19 public StatusWindow( PostNewsgroup mw
, String title
, int parentX
, int parentY
)
21 this.setTitle( title
);
22 this.setLocation( parentX
+ 100, parentY
+ 100 );
26 mainWindow
.enableButtons( false );
28 statusWindow
.addWindowListener( new WindowAdapter()
30 public void windowClosing( WindowEvent event
) {
31 mainWindow
.enableButtons( true );
35 progressBar
= new JProgressBar();
36 progressBar
.setStringPainted( true );
37 progressBar
.setMaximum( MAXPROGRESS
);
38 progressBar
.setMinimum( MINPROGRESS
);
39 progressBar
.setSize( 30, 400 );
41 JLabel progLabel
= new JLabel( "Progress:" );
43 JPanel progressPanel
= new JPanel();
44 progressPanel
.setLayout( new BorderLayout( 10, 0 ) );
45 progressPanel
.add( progLabel
, "West" );
46 progressPanel
.add( progressBar
, "East" );
48 statusLabel
= new JTextField();
49 statusLabel
.setColumns( 25 );
50 statusLabel
.setEditable( false );
51 statusLabel
.setBorder( null );
52 //statusLabel.setBorder( LineBorder.createGrayLineBorder() );
53 JPanel statusPanel
= new JPanel();
54 //statusPanel.setBorder( LineBorder.createBlackLineBorder() );
55 statusPanel
.setLayout( new BorderLayout() );
56 statusPanel
.add( statusLabel
, "West" );
58 cancelButton
= new JButton( "Cancel" );
59 cancelButton
.setSize( 30, 100 );
60 cancelButton
.setEnabled( false );
61 cancelButton
.addActionListener( new ActionListener()
63 public void actionPerformed( ActionEvent event
) {
65 mainWindow
.enableButtons( true );
66 statusWindow
.dispose();
70 JPanel buttonPanel
= new JPanel();
71 buttonPanel
.setLayout( new BorderLayout( 0, 5 ) );
72 buttonPanel
.add( cancelButton
, "East" );
73 buttonPanel
.add( new JSeparator( SwingConstants
.HORIZONTAL
), "North" );
75 Container container
= getContentPane();
76 container
.setLayout( new GridBagLayout() );
77 GridBagConstraints constraints
= new GridBagConstraints();
78 constraints
.fill
= GridBagConstraints
.BOTH
;
80 constraints
.gridx
= 0;
81 constraints
.gridy
= 0;
82 constraints
.gridwidth
= 1;
83 constraints
.gridheight
= 1;
84 constraints
.insets
= new Insets( 15, 15, 10, 15 );
85 container
.add( progressPanel
, constraints
);
87 constraints
.gridx
= 0;
88 constraints
.gridy
= 1;
89 constraints
.gridwidth
= 1;
90 constraints
.gridheight
= 1;
91 constraints
.insets
= new Insets( 10, 15, 10, 15 );
92 container
.add( statusPanel
, constraints
);
94 constraints
.gridx
= 0;
95 constraints
.gridy
= 2;
96 constraints
.gridwidth
= 1;
97 constraints
.gridheight
= 1;
98 constraints
.insets
= new Insets( 10, 15, 5, 15 );
99 container
.add( buttonPanel
, constraints
);
102 this.setResizable( false );
103 //this.setVisible( true );
108 public void setStatus( int progress
, String status
)
110 progressBar
.setValue( progress
);
111 statusLabel
.setText( status
);
112 statusLabel
.setToolTipText( status
);
113 if( progress
== MAXPROGRESS
)
115 cancelButton
.setEnabled( true );
116 cancelButton
.setText( "Close" );
118 update( getGraphics() );
119 mainWindow
.update( mainWindow
.getGraphics() );
123 public void enableCancelButton( boolean enable
)
127 cancelButton
.setEnabled( true );
128 cancelButton
.setText( "Finish" );
132 cancelButton
.setEnabled( false );
133 cancelButton
.setText( "Cancel" );