本文整理汇总了Java中javax.swing.text.DefaultEditorKit.copyAction方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultEditorKit.copyAction方法的具体用法?Java DefaultEditorKit.copyAction怎么用?Java DefaultEditorKit.copyAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.DefaultEditorKit
的用法示例。
在下文中一共展示了DefaultEditorKit.copyAction方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: getActionMapKey
import javax.swing.text.DefaultEditorKit; //导入方法依赖的package包/类
public Object getActionMapKey() {
return DefaultEditorKit.copyAction;
}
示例3: CopyAction
import javax.swing.text.DefaultEditorKit; //导入方法依赖的package包/类
public CopyAction() {
super(DefaultEditorKit.copyAction);
}
示例4: getMacroID
import javax.swing.text.DefaultEditorKit; //导入方法依赖的package包/类
@Override
public final String getMacroID() {
return DefaultEditorKit.copyAction;
}
示例5: 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);
}
}
示例6: CEditorCopyAction
import javax.swing.text.DefaultEditorKit; //导入方法依赖的package包/类
public CEditorCopyAction()
{
super(DefaultEditorKit.copyAction);
}
示例7: 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;
}