1 31 package org.objectweb.proactive.ext.security.gui; 32 33 import java.awt.*; 34 import java.awt.event.*; 35 36 import javax.swing.BorderFactory ; 37 import javax.swing.ButtonGroup ; 38 import javax.swing.ImageIcon ; 39 import javax.swing.JButton ; 40 import javax.swing.JCheckBoxMenuItem ; 41 import javax.swing.JComboBox ; 42 import javax.swing.JFrame ; 43 import javax.swing.JLabel ; 44 import javax.swing.JMenu ; 45 import javax.swing.JMenuBar ; 46 import javax.swing.JMenuItem ; 47 import javax.swing.JPanel ; 48 import javax.swing.JRadioButtonMenuItem ; 49 import javax.swing.JScrollPane ; 50 import javax.swing.JSplitPane ; 51 import javax.swing.JTable ; 52 import javax.swing.JTextArea ; 53 import javax.swing.JTextField ; 54 import javax.swing.KeyStroke ; 55 56 57 61 public class SecurityGui extends JFrame { 62 JTextArea output; 63 JScrollPane scrollPane; 64 JTextField sender; 65 JComboBox senderFromAuth; 66 JComboBox senderFromInt; 67 JComboBox senderFromConf; 68 JComboBox senderToAuth; 69 JComboBox senderToInt; 70 JComboBox senderToConf; 71 JTextField receiver; 72 JComboBox receiverFromAuth; 73 JComboBox receiverFromInt; 74 JComboBox receiverFromConf; 75 JComboBox receiverToAuth; 76 JComboBox receiverToInt; 77 JComboBox receiverToConf; 78 79 public SecurityGui() { 80 JMenuBar menuBar; 81 JMenu menu; 82 JMenu submenu; 83 JMenuItem menuItem; 84 JCheckBoxMenuItem cbMenuItem; 85 JRadioButtonMenuItem rbMenuItem; 86 87 addWindowListener(new WindowAdapter() { 88 public void windowClosing(WindowEvent e) { 89 System.exit(0); 90 } 91 }); 92 93 setDefaultLookAndFeelDecorated(false); 98 99 Container contentPane = getContentPane(); 101 output = new JTextArea (5, 30); 102 output.setEditable(false); 103 scrollPane = new JScrollPane (output); 104 contentPane.add(scrollPane, BorderLayout.CENTER); 105 106 menuBar = new JMenuBar (); 108 setJMenuBar(menuBar); 109 110 menu = new JMenu ("A Menu"); 112 menu.setMnemonic(KeyEvent.VK_A); 113 menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items"); 114 menuBar.add(menu); 115 116 menuItem = new JMenuItem ("A text-only menu item", KeyEvent.VK_T); 118 119 menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, 121 ActionEvent.ALT_MASK)); 122 menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything"); 123 menu.add(menuItem); 124 125 menuItem = new JMenuItem ("Both text and icon", 126 new ImageIcon ("images/middle.gif")); 127 menuItem.setMnemonic(KeyEvent.VK_B); 128 menu.add(menuItem); 129 130 menuItem = new JMenuItem (new ImageIcon ("images/middle.gif")); 131 menuItem.setMnemonic(KeyEvent.VK_D); 132 menu.add(menuItem); 133 134 menu.addSeparator(); 136 137 ButtonGroup group = new ButtonGroup (); 138 139 rbMenuItem = new JRadioButtonMenuItem ("A radio button menu item"); 140 rbMenuItem.setSelected(true); 141 rbMenuItem.setMnemonic(KeyEvent.VK_R); 142 group.add(rbMenuItem); 143 menu.add(rbMenuItem); 144 145 rbMenuItem = new JRadioButtonMenuItem ("Another one"); 146 rbMenuItem.setMnemonic(KeyEvent.VK_O); 147 group.add(rbMenuItem); 148 menu.add(rbMenuItem); 149 150 menu.addSeparator(); 152 cbMenuItem = new JCheckBoxMenuItem ("A check box menu item"); 153 cbMenuItem.setMnemonic(KeyEvent.VK_C); 154 menu.add(cbMenuItem); 155 156 cbMenuItem = new JCheckBoxMenuItem ("Another one"); 157 cbMenuItem.setMnemonic(KeyEvent.VK_H); 158 menu.add(cbMenuItem); 159 160 menu.addSeparator(); 162 submenu = new JMenu ("A submenu"); 163 submenu.setMnemonic(KeyEvent.VK_S); 164 165 menuItem = new JMenuItem ("An item in the submenu"); 166 menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, 167 ActionEvent.ALT_MASK)); 168 submenu.add(menuItem); 169 170 menuItem = new JMenuItem ("Another item"); 171 submenu.add(menuItem); 172 menu.add(submenu); 173 174 menu = new JMenu ("Another Menu"); 176 menu.setMnemonic(KeyEvent.VK_N); 177 menu.getAccessibleContext().setAccessibleDescription("This menu does nothing"); 178 menuBar.add(menu); 179 180 String [] columnNames = { 182 "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" 183 }; 184 185 Object [][] data = new Object [0][]; 186 JTable table = new JTable (data, columnNames); 187 table.setPreferredScrollableViewportSize(new Dimension(500, 70)); 188 189 GridBagLayout editorLayout = new GridBagLayout(); 191 GridBagConstraints c = new GridBagConstraints(); 192 JPanel editorPanel = new JPanel (); 193 editorPanel.setBorder(BorderFactory.createTitledBorder( 194 "Move the Mouse to Move Duke")); 195 editorPanel.setLayout(editorLayout); 196 197 String [] attributesModeStrings = { "Required", "Optional", "Disallowed" }; 198 199 JLabel name = new JLabel ("Target"); 202 c.gridx = 0; 203 c.gridy = 0; 204 editorLayout.setConstraints(name, c); 205 editorPanel.add(name); 206 207 sender = new JTextField (10); 208 sender.setActionCommand("Target"); 209 c.gridx = 1; 210 c.gridy = 0; 211 editorLayout.setConstraints(sender, c); 212 editorPanel.add(sender); 213 214 name = new JLabel ("Authentication"); 215 c.gridx = 0; 216 c.gridy = 5; 217 editorLayout.setConstraints(name, c); 218 editorPanel.add(name); 219 220 senderToAuth = new JComboBox (attributesModeStrings); 221 senderToAuth.setSelectedIndex(0); 222 223 c.gridx = 1; 225 c.gridy = 5; 226 editorLayout.setConstraints(senderToAuth, c); 227 editorPanel.add(senderToAuth); 228 229 name = new JLabel ("integrity"); 230 c.gridx = 0; 231 c.gridy = 6; 232 editorLayout.setConstraints(name, c); 233 editorPanel.add(name); 234 235 senderFromInt = new JComboBox (attributesModeStrings); 236 senderFromInt.setSelectedIndex(0); 237 c.gridx = 1; 238 c.gridy = 6; 239 editorLayout.setConstraints(senderFromInt, c); 240 editorPanel.add(senderFromInt); 241 242 name = new JLabel ("confidentiality"); 243 c.gridx = 0; 244 c.gridy = 7; 245 editorLayout.setConstraints(name, c); 246 editorPanel.add(name); 247 248 senderFromConf = new JComboBox (attributesModeStrings); 249 senderFromConf.setSelectedIndex(0); 250 c.gridx = 1; 251 c.gridy = 7; 252 editorLayout.setConstraints(senderFromConf, c); 253 editorPanel.add(senderFromConf); 254 255 name = new JLabel (" >>>> "); 256 c.gridx = 2; 257 c.gridy = 5; 258 editorLayout.setConstraints(name, c); 259 editorPanel.add(name); 260 261 name = new JLabel ("authentification"); 262 c.gridx = 3; 263 c.gridy = 5; 264 editorLayout.setConstraints(name, c); 265 editorPanel.add(name); 266 267 receiverFromAuth = new JComboBox (attributesModeStrings); 268 receiverFromAuth.setSelectedIndex(0); 269 c.gridx = 4; 270 c.gridy = 5; 271 editorLayout.setConstraints(receiverFromAuth, c); 272 editorPanel.add(receiverFromAuth); 273 name = new JLabel ("integrity"); 274 c.gridx = 3; 275 c.gridy = 6; 276 editorLayout.setConstraints(name, c); 277 editorPanel.add(name); 278 279 receiverFromInt = new JComboBox (attributesModeStrings); 280 receiverFromInt.setSelectedIndex(0); 281 c.gridx = 4; 282 c.gridy = 6; 283 editorLayout.setConstraints(receiverFromInt, c); 284 editorPanel.add(receiverFromInt); 285 286 name = new JLabel ("confidentiality"); 287 c.gridx = 3; 288 c.gridy = 7; 289 editorLayout.setConstraints(name, c); 290 editorPanel.add(name); 291 292 receiverFromInt = new JComboBox (attributesModeStrings); 293 receiverFromInt.setSelectedIndex(0); 294 c.gridx = 4; 295 c.gridy = 7; 296 editorLayout.setConstraints(receiverFromInt, c); 297 editorPanel.add(receiverFromInt); 298 299 name = new JLabel ("Authentication"); 300 c.gridx = 0; 301 c.gridy = 1; 302 editorLayout.setConstraints(name, c); 303 editorPanel.add(name); 304 305 senderFromAuth = new JComboBox (attributesModeStrings); 306 senderFromAuth.setSelectedIndex(0); 307 308 c.gridx = 1; 310 c.gridy = 1; 311 editorLayout.setConstraints(senderFromAuth, c); 312 editorPanel.add(senderFromAuth); 313 314 name = new JLabel ("integrity"); 315 c.gridx = 0; 316 c.gridy = 2; 317 editorLayout.setConstraints(name, c); 318 editorPanel.add(name); 319 320 senderFromInt = new JComboBox (attributesModeStrings); 321 senderFromInt.setSelectedIndex(0); 322 c.gridx = 1; 323 c.gridy = 2; 324 editorLayout.setConstraints(senderFromInt, c); 325 editorPanel.add(senderFromInt); 326 327 name = new JLabel ("confidentiality"); 328 c.gridx = 0; 329 c.gridy = 3; 330 editorLayout.setConstraints(name, c); 331 editorPanel.add(name); 332 333 senderFromConf = new JComboBox (attributesModeStrings); 334 senderFromConf.setSelectedIndex(0); 335 c.gridx = 1; 336 c.gridy = 3; 337 editorLayout.setConstraints(senderFromConf, c); 338 editorPanel.add(senderFromConf); 339 340 name = new JLabel (" <<<< "); 341 c.gridx = 2; 342 c.gridy = 2; 343 editorLayout.setConstraints(name, c); 344 editorPanel.add(name); 345 346 name = new JLabel ("Target"); 347 c.gridx = 3; 348 c.gridy = 0; 349 editorLayout.setConstraints(name, c); 350 editorPanel.add(name); 351 352 receiver = new JTextField (10); 353 receiver.setActionCommand("Target"); 354 c.gridx = 4; 355 c.gridy = 0; 356 editorLayout.setConstraints(receiver, c); 357 editorPanel.add(receiver); 358 359 name = new JLabel ("authentification"); 360 c.gridx = 3; 361 c.gridy = 1; 362 editorLayout.setConstraints(name, c); 363 editorPanel.add(name); 364 365 receiverFromAuth = new JComboBox (attributesModeStrings); 366 receiverFromAuth.setSelectedIndex(0); 367 c.gridx = 4; 368 c.gridy = 1; 369 editorLayout.setConstraints(receiverFromAuth, c); 370 editorPanel.add(receiverFromAuth); 371 name = new JLabel ("integrity"); 372 c.gridx = 3; 373 c.gridy = 2; 374 editorLayout.setConstraints(name, c); 375 editorPanel.add(name); 376 377 receiverFromInt = new JComboBox (attributesModeStrings); 378 receiverFromInt.setSelectedIndex(0); 379 c.gridx = 4; 380 c.gridy = 2; 381 editorLayout.setConstraints(receiverFromInt, c); 382 editorPanel.add(receiverFromInt); 383 384 name = new JLabel ("confidentiality"); 385 c.gridx = 3; 386 c.gridy = 3; 387 editorLayout.setConstraints(name, c); 388 editorPanel.add(name); 389 390 receiverFromConf = new JComboBox (attributesModeStrings); 391 receiverFromConf.setSelectedIndex(0); 392 c.gridx = 4; 393 c.gridy = 3; 394 editorLayout.setConstraints(receiverFromConf, c); 395 editorPanel.add(receiverFromConf); 396 397 JButton button = new JButton ("Add"); 398 c.gridx = 5; 399 c.gridy = 4; 400 editorLayout.setConstraints(button, c); 401 editorPanel.add(button); 402 403 JScrollPane editScrollPane = new JScrollPane (editorPanel); 405 406 JScrollPane tableScrollPane = new JScrollPane (table); 409 410 JSplitPane splitPane = new JSplitPane (JSplitPane.VERTICAL_SPLIT, 412 editScrollPane, tableScrollPane); 413 splitPane.setOneTouchExpandable(true); 414 splitPane.setDividerLocation(150); 415 416 getContentPane().add(splitPane, BorderLayout.CENTER); 418 } 419 420 public void actionPerformed(ActionEvent e) { 421 } 422 423 public static void main(String [] args) { 424 JFrame.setDefaultLookAndFeelDecorated(true); 425 426 SecurityGui window = new SecurityGui(); 427 428 window.setTitle("MenuLookDemo"); 429 window.setSize(450, 260); 430 window.setVisible(true); 431 } 432 } 433 | Popular Tags |