super(proxy); this.getProxy().setComponentPopupMenu(new JPopupMenuText(this.getProxy()));
// allows default cut copy paste popup menu actions private void addCutCopyPastePopUp(JTextComponent textComponent) { ActionMap am = textComponent.getActionMap(); Action paste = am.get("paste-from-clipboard"); Action copy = am.get("copy-to-clipboard"); Action cut = am.get("cut-to-clipboard"); cut.putValue(Action.NAME, "Cut"); copy.putValue(Action.NAME, "Copy"); paste.putValue(Action.NAME, "Paste"); JPopupMenu popup = new JPopupMenu("My Popup"); textComponent.setComponentPopupMenu(popup); popup.add(new JMenuItem(cut)); popup.add(new JMenuItem(copy)); popup.add(new JMenuItem(paste)); }
textComponent.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE); DefaultCaret caret = (DefaultCaret) textComponent.getCaret(); caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
textComponent.setFont(new JLabel().getFont()); textComponent.setEditable(false); textComponent.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE); DefaultCaret caret = (DefaultCaret) textComponent.getCaret(); caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);