本文整理匯總了Java中javax.swing.text.DefaultEditorKit.pasteAction方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultEditorKit.pasteAction方法的具體用法?Java DefaultEditorKit.pasteAction怎麽用?Java DefaultEditorKit.pasteAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.text.DefaultEditorKit
的用法示例。
在下文中一共展示了DefaultEditorKit.pasteAction方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: actionPerformed
import javax.swing.text.DefaultEditorKit; //導入方法依賴的package包/類
/**
* action to be performed
*
* @param ev
*/
public void actionPerformed(ActionEvent ev) {
Action textPaste = null;
DefaultEditorKit kit = new DefaultEditorKit();
Action[] defActions = kit.getActions();
for (Action defAction : defActions) {
if (defAction.getValue(Action.NAME) == DefaultEditorKit.pasteAction) {
textPaste = defAction;
break;
}
}
final Action textPasteFinal = textPaste;
if (multiViewer.getFrame().isActive() || textPasteFinal == null) {
execute("paste;");
} else
textPasteFinal.actionPerformed(ev);
}
示例2: installCutCopyPasteShortcuts
import javax.swing.text.DefaultEditorKit; //導入方法依賴的package包/類
private static void installCutCopyPasteShortcuts(InputMap inputMap, boolean useSimpleActionKeys) {
String copyActionKey = useSimpleActionKeys ? "copy" : DefaultEditorKit.copyAction;
String pasteActionKey = useSimpleActionKeys ? "paste" : DefaultEditorKit.pasteAction;
String cutActionKey = useSimpleActionKeys ? "cut" : DefaultEditorKit.cutAction;
// Ctrl+Ins, Shift+Ins, Shift+Del
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK), copyActionKey);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, InputEvent.SHIFT_MASK | InputEvent.SHIFT_DOWN_MASK), pasteActionKey);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, InputEvent.SHIFT_MASK | InputEvent.SHIFT_DOWN_MASK), cutActionKey);
// Ctrl+C, Ctrl+V, Ctrl+X
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK), copyActionKey);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK), pasteActionKey);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK), DefaultEditorKit.cutAction);
}
示例3: getActionMapKey
import javax.swing.text.DefaultEditorKit; //導入方法依賴的package包/類
public @Override Object getActionMapKey() {
return DefaultEditorKit.pasteAction;
}
示例4: PasteAction
import javax.swing.text.DefaultEditorKit; //導入方法依賴的package包/類
public PasteAction() {
super(DefaultEditorKit.pasteAction);
}
示例5: getMacroID
import javax.swing.text.DefaultEditorKit; //導入方法依賴的package包/類
@Override
public final String getMacroID() {
return DefaultEditorKit.pasteAction;
}
示例6: setOSXFieldShortcuts
import javax.swing.text.DefaultEditorKit; //導入方法依賴的package包/類
public static void setOSXFieldShortcuts() {
String lowercaseOSName = System.getProperty("os.name").toLowerCase();
boolean MAC_OS_X = lowercaseOSName.startsWith("mac os x");
if(MAC_OS_X) {
Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] {
"meta C", DefaultEditorKit.copyAction,
"meta V", DefaultEditorKit.pasteAction,
"meta X", DefaultEditorKit.cutAction,
"COPY", DefaultEditorKit.copyAction,
"PASTE", DefaultEditorKit.pasteAction,
"CUT", DefaultEditorKit.cutAction,
"shift LEFT", DefaultEditorKit.selectionBackwardAction,
"shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
"shift RIGHT", DefaultEditorKit.selectionForwardAction,
"shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
"alt LEFT", DefaultEditorKit.previousWordAction,
"alt KP_LEFT", DefaultEditorKit.previousWordAction,
"alt RIGHT", DefaultEditorKit.nextWordAction,
"alt KP_RIGHT", DefaultEditorKit.nextWordAction,
"alt shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
"alt shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
"alt shift RIGHT", DefaultEditorKit.selectionNextWordAction,
"alt shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
"meta A", DefaultEditorKit.selectAllAction,
"HOME", DefaultEditorKit.beginLineAction,
"meta LEFT", DefaultEditorKit.beginLineAction,
"END", DefaultEditorKit.endLineAction,
"meta RIGHT", DefaultEditorKit.endLineAction,
"shift HOME", DefaultEditorKit.selectionBeginLineAction,
"meta shift LEFT", DefaultEditorKit.selectionBeginLineAction,
"meta shift RIGHT", DefaultEditorKit.selectionEndLineAction,
"shift END", DefaultEditorKit.selectionEndLineAction,
"typed \010", DefaultEditorKit.deletePrevCharAction,
"DELETE", DefaultEditorKit.deleteNextCharAction,
// "alt DELETE", DefaultEditorKit.deleteNextWordAction,
// "alt BACKSPACE", DefaultEditorKit.deletePrevWordAction,
"RIGHT", DefaultEditorKit.forwardAction,
"LEFT", DefaultEditorKit.backwardAction,
"UP", DefaultEditorKit.beginAction,
"DOWN", DefaultEditorKit.endAction,
"shift UP", DefaultEditorKit.selectionBeginAction,
"shift DOWN", DefaultEditorKit.selectionEndAction,
"KP_RIGHT", DefaultEditorKit.forwardAction,
"KP_LEFT", DefaultEditorKit.backwardAction,
"ENTER", JTextField.notifyAction,
"meta shift A", "unselect"/*DefaultEditorKit.unselectAction*/,
"control shift O",
"toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
});
UIManager.put("TextField.focusInputMap", fieldInputMap);
UIManager.put("TextArea.focusInputMap", fieldInputMap);
UIManager.put("TextPane.focusInputMap", fieldInputMap);
}
}
示例7: CEditorPasteAction
import javax.swing.text.DefaultEditorKit; //導入方法依賴的package包/類
public CEditorPasteAction()
{
super(DefaultEditorKit.pasteAction);
}
示例8: createTable
import javax.swing.text.DefaultEditorKit; //導入方法依賴的package包/類
public JTable createTable(Sheet sheet) {
SheetTableModel sheetTableModel = new SheetTableModel(sheet);
JTable table = new SheetTable(sheetTableModel);
table.setDefaultRenderer(Cell.class, new CellRenderer());
TableCellEditor editor = new org.joeffice.spreadsheet.cell.CellEditor();
table.setDefaultEditor(Cell.class, editor);
int columnsCount = sheetTableModel.getColumnCount();
for (int i = 0; i < columnsCount; i++) {
TableColumn tableColumn = table.getColumnModel().getColumn(i);
tableColumn.setCellRenderer(new CellRenderer());
tableColumn.setCellEditor(editor);
int widthUnits = sheet.getColumnWidth(i);
tableColumn.setPreferredWidth(widthUnitsToPixel(widthUnits));
}
int rowCount = sheetTableModel.getRowCount();
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
Row row = sheet.getRow(rowIndex);
if (row != null) {
int cellHeight = (int) Math.ceil(sheet.getRow(rowIndex).getHeightInPoints());
cellHeight += CELL_HEIGHT_MARGINS;
table.setRowHeight(rowIndex, cellHeight);
}
}
table.setAutoscrolls(true);
table.setFillsViewportHeight(true);
JLabel tableHeader = (JLabel) table.getTableHeader().getDefaultRenderer();
tableHeader.setHorizontalAlignment(SwingConstants.CENTER);
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
table.setCellSelectionEnabled(true);
TableColumnAdjuster tca = new TableColumnAdjuster(table, 20);
if (sheet.getDefaultColumnWidth() == -1) {
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
tca.setOnlyAdjustLarger(true);
tca.setLeaveEmptyAsIs(true);
tca.adjustColumns();
}
table.setTransferHandler(new TableTransferHandler());
table.setDragEnabled(true);
table.setDropMode(DropMode.ON_OR_INSERT);
Action cutAction = new ClipboardAction(DefaultEditorKit.cutAction);
Action copyAction = new ClipboardAction(DefaultEditorKit.copyAction);
Action pasteAction = new ClipboardAction(DefaultEditorKit.pasteAction);
table.getActionMap().put(DefaultEditorKit.cutAction, cutAction);
table.getActionMap().put(DefaultEditorKit.copyAction, copyAction);
table.getActionMap().put(DefaultEditorKit.pasteAction, pasteAction);
//table.setIntercellSpacing(new Dimension(0, 0));
table.putClientProperty("print.printable", Boolean.TRUE);
Rectangle lastDataCellBounds = table.getCellRect(sheet.getLastRowNum(), sheetTableModel.getLastColumnNum(), true);
table.putClientProperty("print.size", new Dimension(lastDataCellBounds.x + lastDataCellBounds.width, lastDataCellBounds.y + lastDataCellBounds.height));
new SheetListener(table);
if (!sheet.isDisplayGridlines()) {
table.setShowGrid(false);
}
return table;
}
示例9: PasteAnnotationProxyAction
import javax.swing.text.DefaultEditorKit; //導入方法依賴的package包/類
/**
* Creates a new proxy which calls the original paste action and then makes sure the editor
* content is updated by calling {@link AnnotationsDecorator#updateEditorContent()}.
*
* @param action
* the original paste action which is called by this action
*/
public PasteAnnotationProxyAction(final Action action, final AnnotationsDecorator decorator) {
super(DefaultEditorKit.pasteAction);
this.action = action;
this.decorator = decorator;
}