List of usage examples for javax.swing JTextField getActions
@BeanProperty(bound = false)
public Action[] getActions()
From source file:CutPasteSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Cut/Paste Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField textField = new JTextField(); frame.add(textField, BorderLayout.NORTH); Action actions[] = textField.getActions(); Action cutAction = findAction(actions, DefaultEditorKit.cutAction); Action copyAction = findAction(actions, DefaultEditorKit.copyAction); Action pasteAction = findAction(actions, DefaultEditorKit.pasteAction); JPanel panel = new JPanel(); frame.add(panel, BorderLayout.SOUTH); JButton cutButton = new JButton(cutAction); cutButton.setText("Cut"); panel.add(cutButton);//from w w w. ja v a 2s. c o m JButton copyButton = new JButton(copyAction); copyButton.setText("Copy"); panel.add(copyButton); JButton pasteButton = new JButton(pasteAction); pasteButton.setText("Paste"); panel.add(pasteButton); frame.setSize(250, 250); frame.setVisible(true); }
From source file:CutPasteSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Cut/Paste Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = frame.getContentPane(); JTextField textField = new JTextField(); JTextArea textArea = new JTextArea(); JScrollPane scrollPane = new JScrollPane(textArea); content.add(textField, BorderLayout.NORTH); content.add(scrollPane, BorderLayout.CENTER); Action actions[] = textField.getActions(); Action cutAction = TextUtilities.findAction(actions, DefaultEditorKit.cutAction); Action copyAction = TextUtilities.findAction(actions, DefaultEditorKit.copyAction); Action pasteAction = TextUtilities.findAction(actions, DefaultEditorKit.pasteAction); JPanel panel = new JPanel(); content.add(panel, BorderLayout.SOUTH); JButton cutButton = new JButton(cutAction); cutButton.setText("Cut"); panel.add(cutButton);/* w w w .j av a 2 s . co m*/ JButton copyButton = new JButton(copyAction); copyButton.setText("Copy"); panel.add(copyButton); JButton pasteButton = new JButton(pasteAction); pasteButton.setText("Paste"); panel.add(pasteButton); frame.setSize(250, 250); frame.setVisible(true); }