KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > memoire > vainstall > builder > gui > ShowRequirementsFrame


1 /*
2  * $RCSfile: ShowRequirementsFrame.java,v $
3  * @modification $Date: 2001/09/28 19:35:30 $
4  * @version $Id: ShowRequirementsFrame.java,v 1.1 2001/09/28 19:35:30 hfalk Exp $
5  *
6  */

7
8 package com.memoire.vainstall.builder.gui;
9
10 import com.memoire.vainstall.VAGlobals;
11
12 import java.awt.*;
13 import java.awt.event.*;
14
15 import javax.swing.*;
16 import javax.swing.border.*;
17 import javax.swing.event.*;
18 import javax.swing.tree.*;
19
20 /**
21  * This is the builde main window
22  *
23  * @see javax.swing.JFrame
24  *
25  * @author Henrik Falk
26  * @version $Id: ShowRequirementsFrame.java,v 1.1 2001/09/28 19:35:30 hfalk Exp $
27  */

28 public class ShowRequirementsFrame extends JFrame implements ActionListener, WindowListener {
29
30     private final static Border loweredBorder = new SoftBevelBorder(BevelBorder.LOWERED);
31     private final static Border raisedBorder = new SoftBevelBorder(BevelBorder.RAISED);
32
33     JPanel allPanel;
34
35     JButton okButton;
36
37     JEditorPane editorPane;
38     JList list;
39
40     public ShowRequirementsFrame() {
41         super("Show Requirements");
42
43         setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
44
45         // create the all panel
46
allPanel = new JPanel(new BorderLayout());
47
48         // create the center panels
49
GridBagLayout nLayout = new GridBagLayout();
50         GridBagConstraints nConstraint = new GridBagConstraints();
51         JPanel nPanel = new JPanel();
52         nPanel.setLayout(nLayout);
53         nConstraint.fill = GridBagConstraints.BOTH;
54         nConstraint.insets = new Insets(4,4,4,4);
55         nConstraint.anchor = GridBagConstraints.CENTER;
56         nConstraint.gridx = 0;
57         nConstraint.gridy = 0;
58         nConstraint.gridwidth = 1;
59         nConstraint.gridheight = 1;
60         nConstraint.weightx = 1;
61         nConstraint.weighty = 1;
62         JScrollPane listPane = new JScrollPane();
63         nPanel.add(listPane);
64         nLayout.setConstraints(listPane,nConstraint);
65
66         list = new JList();
67         list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
68         listPane.getViewport().add(list);
69
70         JScrollPane detailsPane = new JScrollPane();
71         editorPane = new JEditorPane();
72         editorPane.setContentType("text/html");
73         editorPane.setEditable(false);
74         detailsPane.getViewport().add(editorPane);
75
76         JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,nPanel, detailsPane);
77         splitPane.setContinuousLayout(true);
78     splitPane.setOneTouchExpandable(true);
79
80         splitPane.setDividerLocation(180);
81
82         allPanel.add(splitPane, BorderLayout.CENTER);
83
84         // create to bottom panel
85
GridBagLayout sLayout = new GridBagLayout();
86         GridBagConstraints sConstraint = new GridBagConstraints();
87
88         JPanel sPanel = new JPanel();
89         sPanel.setLayout(sLayout);
90         sPanel.setBorder(raisedBorder);
91
92         JPanel fillPanel = new JPanel();
93         sConstraint.fill = GridBagConstraints.NONE;
94         sConstraint.insets = new Insets(4,4,4,4);
95         sConstraint.anchor = GridBagConstraints.CENTER;
96         sConstraint.gridx = 0;
97         sConstraint.gridy = 0;
98         sConstraint.gridwidth = 1;
99         sConstraint.gridheight = 1;
100         sConstraint.weightx = 1;
101         sConstraint.weighty = 0;
102         sLayout.setConstraints(fillPanel,sConstraint);
103         sPanel.add(fillPanel);
104
105         okButton = new JButton();
106         okButton.setText("OK");
107         okButton.addActionListener(this);
108         sConstraint.fill = GridBagConstraints.BOTH;
109         sConstraint.insets = new Insets(4,4,4,4);
110         sConstraint.anchor = GridBagConstraints.CENTER;
111         sConstraint.gridx = 1;
112         sConstraint.gridy = 0;
113         sConstraint.gridwidth = 1;
114         sConstraint.gridheight = 1;
115         sConstraint.weightx = 0;
116         sConstraint.weighty = 0;
117         sLayout.setConstraints(okButton,sConstraint);
118         sPanel.add(okButton);
119       
120         // add to main panel
121
allPanel.add(sPanel, BorderLayout.SOUTH);
122
123         // insert the all panel into the application frame window
124
this.getContentPane().add("Center",allPanel);
125
126         this.getRootPane().registerKeyboardAction(this,"VK_ESCAPE",
127               KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0,false),
128               JComponent.WHEN_IN_FOCUSED_WINDOW);
129
130         addWindowListener(this);
131     }
132
133     public void center() {
134         Dimension dimScreen = Toolkit.getDefaultToolkit().getScreenSize();
135         setLocation((dimScreen.width - this.getSize().width) / 2,
136                     (dimScreen.height - this.getSize().height) / 2);
137     }
138
139     /**
140      * Method to handle events for the WindowListener interface.
141      * @param e java.awt.event.WindowEvent
142      */

143     public void windowActivated(java.awt.event.WindowEvent JavaDoc e) {
144     }
145
146     /**
147      * Method to handle events for the WindowListener interface.
148      * @param e java.awt.event.WindowEvent
149      */

150     public void windowClosed(java.awt.event.WindowEvent JavaDoc e) {
151     }
152
153     /**
154      * Method to handle events for the WindowListener interface.
155      * @param e java.awt.event.WindowEvent
156      */

157     public void windowClosing(java.awt.event.WindowEvent JavaDoc e) {
158     }
159
160     /**
161      * Method to handle events for the WindowListener interface.
162      * @param e java.awt.event.WindowEvent
163      */

164     public void windowDeactivated(java.awt.event.WindowEvent JavaDoc e) {
165     }
166
167     /**
168      * Method to handle events for the WindowListener interface.
169      * @param e java.awt.event.WindowEvent
170      */

171     public void windowDeiconified(java.awt.event.WindowEvent JavaDoc e) {
172     }
173
174     /**
175      * Method to handle events for the WindowListener interface.
176      * @param e java.awt.event.WindowEvent
177      */

178     public void windowIconified(java.awt.event.WindowEvent JavaDoc e) {
179     }
180
181     /**
182      * Method to handle events for the WindowListener interface.
183      * @param e java.awt.event.WindowEvent
184      */

185     public void windowOpened(java.awt.event.WindowEvent JavaDoc e) {
186         okButton.requestFocus();
187     }
188
189     public void actionPerformed(ActionEvent evt) {
190
191         // extract the control that sends the event
192
Object JavaDoc source = evt.getSource();
193         String JavaDoc actionCommand = evt.getActionCommand();
194
195         if (actionCommand != null && actionCommand.equals("VK_ESCAPE") == true) {
196             setVisible(false);
197         }
198
199         if (source == okButton) {
200             setVisible(false);
201         }
202     }
203
204     public JEditorPane getEditorPane() {
205         return editorPane;
206     }
207
208     public JList getList() {
209         return list;
210     }
211
212 }
213
Popular Tags