DefaultEditorKit.beepAction : DefaultEditorKit « javax.swing.text « Java by API






DefaultEditorKit.beepAction

 
import java.awt.Event;
import java.awt.event.KeyEvent;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.text.DefaultEditorKit;

public class MainClass extends JFrame {
  MainClass(String title) {
    super(title);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel jp = new JPanel();

    JLabel jl = new JLabel("Name:");
    jp.add(jl);

    JTextField jt = new JTextField(20);
    jp.add(jt);

    KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_B, Event.CTRL_MASK);

    jt.getInputMap().put(ks, DefaultEditorKit.beepAction);

    getContentPane().add(jp);

    pack();
    setVisible(true);
  }

  public static void main(String[] args) {
    new MainClass("Binding Demo2");
  }
}

           
         
  








Related examples in the same category

1.DefaultEditorKit.copyAction
2.DefaultEditorKit.cutAction
3.DefaultEditorKit.pasteAction
4.DefaultEditorKit.readOnlyAction
5.DefaultEditorKit.selectLineAction
6.DefaultEditorKit.selectWordAction
7.DefaultEditorKit.writableAction