1 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 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 allPanel = new JPanel(new BorderLayout()); 47 48 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 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 allPanel.add(sPanel, BorderLayout.SOUTH); 122 123 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 143 public void windowActivated(java.awt.event.WindowEvent e) { 144 } 145 146 150 public void windowClosed(java.awt.event.WindowEvent e) { 151 } 152 153 157 public void windowClosing(java.awt.event.WindowEvent e) { 158 } 159 160 164 public void windowDeactivated(java.awt.event.WindowEvent e) { 165 } 166 167 171 public void windowDeiconified(java.awt.event.WindowEvent e) { 172 } 173 174 178 public void windowIconified(java.awt.event.WindowEvent e) { 179 } 180 181 185 public void windowOpened(java.awt.event.WindowEvent e) { 186 okButton.requestFocus(); 187 } 188 189 public void actionPerformed(ActionEvent evt) { 190 191 Object source = evt.getSource(); 193 String 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 |