| 1 | /******************************************************************************* | |
| 2 | * Copyhacked (H) 2012-2025. | |
| 3 | * This program and the accompanying materials | |
| 4 | * are made available under no term at all, use it like | |
| 5 | * you want, but share and discuss it | |
| 6 | * every time possible with every body. | |
| 7 | * | |
| 8 | * Contributors: | |
| 9 | * ron190 at ymail dot com - initial implementation | |
| 10 | ******************************************************************************/ | |
| 11 | package com.jsql.view.swing.popupmenu; | |
| 12 | ||
| 13 | import javax.swing.*; | |
| 14 | import javax.swing.text.DefaultEditorKit; | |
| 15 | import javax.swing.text.JTextComponent; | |
| 16 | import java.awt.event.InputEvent; | |
| 17 | import java.awt.event.KeyEvent; | |
| 18 | ||
| 19 | /** | |
| 20 | * Default popup menu for textfield and texteditor. | |
| 21 | */ | |
| 22 | public class JPopupMenuText extends JPopupMenuComponent { | |
| 23 | | |
| 24 | /** | |
| 25 | * Create popup menu for this component. | |
| 26 | * @param component The component receiving the menu | |
| 27 | */ | |
| 28 | public JPopupMenuText(JTextComponent component) { | |
| 29 | super(component); | |
| 30 | ||
| 31 |
1
1. <init> : negated conditional → NO_COVERAGE |
if (component.isEditable()) { |
| 32 | JMenuItem cutItem = new JMenuItem(); | |
| 33 |
1
1. <init> : removed call to javax/swing/JMenuItem::setAction → NO_COVERAGE |
cutItem.setAction(component.getActionMap().get(DefaultEditorKit.cutAction)); |
| 34 |
1
1. <init> : removed call to javax/swing/JMenuItem::setText → NO_COVERAGE |
cutItem.setText("Cut"); |
| 35 |
1
1. <init> : removed call to javax/swing/JMenuItem::setAccelerator → NO_COVERAGE |
cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK)); |
| 36 |
1
1. <init> : removed call to javax/swing/JMenuItem::setMnemonic → NO_COVERAGE |
cutItem.setMnemonic('t'); |
| 37 | ||
| 38 | JMenuItem pasteItem = new JMenuItem(); | |
| 39 |
1
1. <init> : removed call to javax/swing/JMenuItem::setAction → NO_COVERAGE |
pasteItem.setAction(component.getActionMap().get(DefaultEditorKit.pasteAction)); |
| 40 |
1
1. <init> : removed call to javax/swing/JMenuItem::setText → NO_COVERAGE |
pasteItem.setText("Paste"); |
| 41 |
1
1. <init> : removed call to javax/swing/JMenuItem::setAccelerator → NO_COVERAGE |
pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK)); |
| 42 |
1
1. <init> : removed call to javax/swing/JMenuItem::setMnemonic → NO_COVERAGE |
pasteItem.setMnemonic('P'); |
| 43 | ||
| 44 | this.add(cutItem, 0); // Before Copy menu | |
| 45 | this.add(pasteItem, 2); // After Copy menu | |
| 46 | } | |
| 47 | } | |
| 48 | } | |
Mutations | ||
| 31 |
1.1 |
|
| 33 |
1.1 |
|
| 34 |
1.1 |
|
| 35 |
1.1 |
|
| 36 |
1.1 |
|
| 39 |
1.1 |
|
| 40 |
1.1 |
|
| 41 |
1.1 |
|
| 42 |
1.1 |