MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / getMenuBar

Method getMenuBar

src/test/Test_Event.java:436–534  ·  view source on GitHub ↗
(JPanel ptop)

Source from the content-addressed store, hash-verified

434 };
435
436 private JMenuBar getMenuBar(JPanel ptop) {
437 JMenuBar mb = new JMenuBar() {
438 @Override
439 public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager m) {
440 if(logging)System.out.println("Test_Editor path length=" + path.length);
441 super.processKeyEvent(e, path, m);
442 }
443 };
444 JMenu mb1 = new JMenu("Test") {
445 @Override
446 public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager m) {
447 if(logging)System.out.println("Test_Editor JMenu path length=" + path.length);
448 super.processKeyEvent(e, path, m);
449 }
450
451 @Override
452 public void addNotify() {
453 if(logging)System.out.println("Test_Editor JMenu addNotify");
454 super.addNotify();
455 }
456
457 };
458
459 JMenuItem mb1a = new JMenuItem("test-1");
460 JMenuItem mb1b = new JMenuItem("test-2");
461 JMenu mb1c = new JMenu("test-3");
462 JMenuItem mb1c1 = new JMenuItem("test-4");
463 JMenuItem mb1c2 = new JMenuItem("test-5");
464
465 mb1.setMnemonic('t');
466
467 mb1.add(mb1a);
468 mb1.add(mb1b);
469 mb1.add(mb1c);
470 mb1c.add(mb1c1);
471 mb1c.add(mb1c2);
472
473 KeyStroke[] a = mb1.getRegisteredKeyStrokes();
474 if(logging)System.out.println("menubar menu registration: " + a.length);
475 for (int i = 0; i < a.length; i++) {
476 if(logging)System.out.println(a[i]);
477 }
478
479 mb.add(mb1);
480
481 a = mb1.getRegisteredKeyStrokes();
482 if(logging)System.out.println("menubar menu registration: " + a.length);
483
484 ActionListener al = new ActionListener() {
485
486 @Override
487 public void actionPerformed(ActionEvent e) {
488 if(logging)System.out.println("Test_Editor action " + getID(e.getSource()));
489 ptop.setBackground(Color.red);
490 btnj.setText(e.getActionCommand());
491 }
492
493 };

Callers 1

Test_EventMethod · 0.95

Calls 4

setMnemonicMethod · 0.80
printlnMethod · 0.65
addActionListenerMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected