1 19 20 package org.netbeans.modules.openide.util; 21 22 import java.awt.Component ; 23 import javax.swing.Action ; 24 import javax.swing.JButton ; 25 import javax.swing.JMenuItem ; 26 import javax.swing.JPopupMenu ; 27 import org.openide.util.Lookup; 28 29 37 public abstract class AWTBridge extends Object { 38 41 public static AWTBridge getDefault () { 42 AWTBridge ap = Lookup.getDefault().lookup(AWTBridge.class); 43 return ap == null ? new Default () : ap; 44 } 45 46 49 public abstract JPopupMenu createEmptyPopup(); 50 51 55 public abstract JMenuItem createMenuPresenter (Action action); 56 57 61 public abstract JMenuItem createPopupPresenter (Action action); 62 63 67 public abstract Component createToolbarPresenter (Action action); 68 69 70 public abstract Component [] convertComponents(Component comp); 71 72 76 private static final class Default extends AWTBridge { 77 78 public JMenuItem createMenuPresenter(Action action) { 79 return new JMenuItem (action); 80 } 81 82 public JMenuItem createPopupPresenter(Action action) { 83 return new JMenuItem (action); 84 } 85 86 public Component createToolbarPresenter(Action action) { 87 return new JButton (action); 88 } 89 90 public JPopupMenu createEmptyPopup() { 91 return new JPopupMenu (); 92 } 93 94 public Component [] convertComponents(Component comp) { 95 return new Component [] {comp}; 96 } 97 } 98 } 99 | Popular Tags |