KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jester > RealProgressReporterUI


1 package jester;
2
3 import java.awt.*;
4
5 import javax.swing.*;
6
7 public class RealProgressReporterUI extends JFrame {
8
9     JProgressBar fProgressBar;
10     JTextArea fTextArea;
11
12     public static void main(String JavaDoc[] args)
13     {
14       JFrame f = new RealProgressReporterUI();
15       f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
16     }
17     
18
19     public RealProgressReporterUI() {
20         super();
21         setupFrame();
22     }
23
24     private void setupFrame() {
25         setTitle("Jester Report");
26         fProgressBar = new JProgressBar();
27         fTextArea = new JTextArea();
28         getContentPane().setLayout(new GridBagLayout());
29         add(new JLabel("Progress"), 0,0,1,1,GridBagConstraints.EAST,GridBagConstraints.NONE);
30         add(fProgressBar, 1,0,1,1,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL);
31         add(new JScrollPane(fTextArea), 0,1,2,1,GridBagConstraints.CENTER,GridBagConstraints.BOTH);
32         fTextArea.setEditable(false);
33         pack();
34         setBounds(100, 100, 600, 300);
35         setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
36         setVisible(true);
37     }
38
39     private void add(Component comp, int x, int y, int w, int h, int orientation, int fill)
40     {
41         GridBagConstraints gbc = new GridBagConstraints();
42         gbc.gridx = x;
43         gbc.gridy = y;
44         gbc.gridwidth = w;
45         gbc.gridheight = h;
46         gbc.ipadx = 10;
47         gbc.ipady = 5;
48         
49         if (fill == GridBagConstraints.BOTH)
50         {
51             gbc.weightx = 1.0;
52             gbc.weighty = 1.0;
53         }
54         else if (fill == GridBagConstraints.HORIZONTAL)
55         {
56             gbc.weightx = 1.0;
57         }
58         if (fill == GridBagConstraints.VERTICAL)
59         {
60             gbc.weighty = 1.0;
61         }
62         gbc.anchor = orientation;
63         gbc.fill = fill;
64         ((GridBagLayout)getContentPane().getLayout()).setConstraints(comp, gbc);
65         getContentPane().add(comp);
66     }
67         
68
69 }
70
Popular Tags