001: /*
002: * $RCSfile: ShowRequirementsFrame.java,v $
003: * @modification $Date: 2001/09/28 19:35:30 $
004: * @version $Id: ShowRequirementsFrame.java,v 1.1 2001/09/28 19:35:30 hfalk Exp $
005: *
006: */
007:
008: package com.memoire.vainstall.builder.gui;
009:
010: import com.memoire.vainstall.VAGlobals;
011:
012: import java.awt.*;
013: import java.awt.event.*;
014:
015: import javax.swing.*;
016: import javax.swing.border.*;
017: import javax.swing.event.*;
018: import javax.swing.tree.*;
019:
020: /**
021: * This is the builde main window
022: *
023: * @see javax.swing.JFrame
024: *
025: * @author Henrik Falk
026: * @version $Id: ShowRequirementsFrame.java,v 1.1 2001/09/28 19:35:30 hfalk Exp $
027: */
028: public class ShowRequirementsFrame extends JFrame implements
029: ActionListener, WindowListener {
030:
031: private final static Border loweredBorder = new SoftBevelBorder(
032: BevelBorder.LOWERED);
033: private final static Border raisedBorder = new SoftBevelBorder(
034: BevelBorder.RAISED);
035:
036: JPanel allPanel;
037:
038: JButton okButton;
039:
040: JEditorPane editorPane;
041: JList list;
042:
043: public ShowRequirementsFrame() {
044: super ("Show Requirements");
045:
046: setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
047:
048: // create the all panel
049: allPanel = new JPanel(new BorderLayout());
050:
051: // create the center panels
052: GridBagLayout nLayout = new GridBagLayout();
053: GridBagConstraints nConstraint = new GridBagConstraints();
054: JPanel nPanel = new JPanel();
055: nPanel.setLayout(nLayout);
056: nConstraint.fill = GridBagConstraints.BOTH;
057: nConstraint.insets = new Insets(4, 4, 4, 4);
058: nConstraint.anchor = GridBagConstraints.CENTER;
059: nConstraint.gridx = 0;
060: nConstraint.gridy = 0;
061: nConstraint.gridwidth = 1;
062: nConstraint.gridheight = 1;
063: nConstraint.weightx = 1;
064: nConstraint.weighty = 1;
065: JScrollPane listPane = new JScrollPane();
066: nPanel.add(listPane);
067: nLayout.setConstraints(listPane, nConstraint);
068:
069: list = new JList();
070: list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
071: listPane.getViewport().add(list);
072:
073: JScrollPane detailsPane = new JScrollPane();
074: editorPane = new JEditorPane();
075: editorPane.setContentType("text/html");
076: editorPane.setEditable(false);
077: detailsPane.getViewport().add(editorPane);
078:
079: JSplitPane splitPane = new JSplitPane(
080: JSplitPane.HORIZONTAL_SPLIT, nPanel, detailsPane);
081: splitPane.setContinuousLayout(true);
082: splitPane.setOneTouchExpandable(true);
083:
084: splitPane.setDividerLocation(180);
085:
086: allPanel.add(splitPane, BorderLayout.CENTER);
087:
088: // create to bottom panel
089: GridBagLayout sLayout = new GridBagLayout();
090: GridBagConstraints sConstraint = new GridBagConstraints();
091:
092: JPanel sPanel = new JPanel();
093: sPanel.setLayout(sLayout);
094: sPanel.setBorder(raisedBorder);
095:
096: JPanel fillPanel = new JPanel();
097: sConstraint.fill = GridBagConstraints.NONE;
098: sConstraint.insets = new Insets(4, 4, 4, 4);
099: sConstraint.anchor = GridBagConstraints.CENTER;
100: sConstraint.gridx = 0;
101: sConstraint.gridy = 0;
102: sConstraint.gridwidth = 1;
103: sConstraint.gridheight = 1;
104: sConstraint.weightx = 1;
105: sConstraint.weighty = 0;
106: sLayout.setConstraints(fillPanel, sConstraint);
107: sPanel.add(fillPanel);
108:
109: okButton = new JButton();
110: okButton.setText("OK");
111: okButton.addActionListener(this );
112: sConstraint.fill = GridBagConstraints.BOTH;
113: sConstraint.insets = new Insets(4, 4, 4, 4);
114: sConstraint.anchor = GridBagConstraints.CENTER;
115: sConstraint.gridx = 1;
116: sConstraint.gridy = 0;
117: sConstraint.gridwidth = 1;
118: sConstraint.gridheight = 1;
119: sConstraint.weightx = 0;
120: sConstraint.weighty = 0;
121: sLayout.setConstraints(okButton, sConstraint);
122: sPanel.add(okButton);
123:
124: // add to main panel
125: allPanel.add(sPanel, BorderLayout.SOUTH);
126:
127: // insert the all panel into the application frame window
128: this .getContentPane().add("Center", allPanel);
129:
130: this .getRootPane().registerKeyboardAction(this , "VK_ESCAPE",
131: KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false),
132: JComponent.WHEN_IN_FOCUSED_WINDOW);
133:
134: addWindowListener(this );
135: }
136:
137: public void center() {
138: Dimension dimScreen = Toolkit.getDefaultToolkit()
139: .getScreenSize();
140: setLocation((dimScreen.width - this .getSize().width) / 2,
141: (dimScreen.height - this .getSize().height) / 2);
142: }
143:
144: /**
145: * Method to handle events for the WindowListener interface.
146: * @param e java.awt.event.WindowEvent
147: */
148: public void windowActivated(java.awt.event.WindowEvent e) {
149: }
150:
151: /**
152: * Method to handle events for the WindowListener interface.
153: * @param e java.awt.event.WindowEvent
154: */
155: public void windowClosed(java.awt.event.WindowEvent e) {
156: }
157:
158: /**
159: * Method to handle events for the WindowListener interface.
160: * @param e java.awt.event.WindowEvent
161: */
162: public void windowClosing(java.awt.event.WindowEvent e) {
163: }
164:
165: /**
166: * Method to handle events for the WindowListener interface.
167: * @param e java.awt.event.WindowEvent
168: */
169: public void windowDeactivated(java.awt.event.WindowEvent e) {
170: }
171:
172: /**
173: * Method to handle events for the WindowListener interface.
174: * @param e java.awt.event.WindowEvent
175: */
176: public void windowDeiconified(java.awt.event.WindowEvent e) {
177: }
178:
179: /**
180: * Method to handle events for the WindowListener interface.
181: * @param e java.awt.event.WindowEvent
182: */
183: public void windowIconified(java.awt.event.WindowEvent e) {
184: }
185:
186: /**
187: * Method to handle events for the WindowListener interface.
188: * @param e java.awt.event.WindowEvent
189: */
190: public void windowOpened(java.awt.event.WindowEvent e) {
191: okButton.requestFocus();
192: }
193:
194: public void actionPerformed(ActionEvent evt) {
195:
196: // extract the control that sends the event
197: Object source = evt.getSource();
198: String actionCommand = evt.getActionCommand();
199:
200: if (actionCommand != null
201: && actionCommand.equals("VK_ESCAPE") == true) {
202: setVisible(false);
203: }
204:
205: if (source == okButton) {
206: setVisible(false);
207: }
208: }
209:
210: public JEditorPane getEditorPane() {
211: return editorPane;
212: }
213:
214: public JList getList() {
215: return list;
216: }
217:
218: }
|