diff options
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing3613.java')
| -rw-r--r-- | Master/Reference Architectures and Patterns/hjp5/examples/Listing3613.java | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/Listing3613.java b/Master/Reference Architectures and Patterns/hjp5/examples/Listing3613.java new file mode 100644 index 0000000..23a7384 --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/Listing3613.java @@ -0,0 +1,71 @@ +/* Listing3613.java */
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.border.*;
+
+public class Listing3613
+extends JFrame
+implements ActionListener
+{
+ public Listing3613()
+ {
+ super("Invalidierung");
+ addWindowListener(new WindowClosingAdapter(true));
+ Container cp = getContentPane();
+ ((JComponent)cp).setBorder(new EmptyBorder(5, 5, 5, 5));
+ cp.setLayout(new FlowLayout());
+ //Textfelder erzeugen
+ JTextField tf1 = new JTextField("Zeile1", 20);
+ JTextField tf2 = new JTextField("Zeile2", 20);
+ JTextField tf3 = new JTextField("Zeile3", 20);
+ //STRG+UMSCHALT+F6 auf Frame registrieren
+ ((JComponent)cp).registerKeyboardAction(
+ this,
+ "dialog",
+ ctrlShift(KeyEvent.VK_F6),
+ JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
+ );
+ //STRG+UMSCHALT+F7 auf tf1 registrieren
+ tf1.registerKeyboardAction(
+ this,
+ "tf1",
+ ctrlShift(KeyEvent.VK_F7),
+ JComponent.WHEN_IN_FOCUSED_WINDOW
+ );
+ //STRG+UMSCHALT+F8 auf tf2 registrieren
+ tf2.registerKeyboardAction(
+ this,
+ "tf2",
+ ctrlShift(KeyEvent.VK_F8),
+ JComponent.WHEN_FOCUSED
+ );
+ //Textfelder hinzufügen
+ cp.add(tf1);
+ cp.add(tf2);
+ cp.add(tf3);
+ }
+
+ public void actionPerformed(ActionEvent event)
+ {
+ String cmd = event.getActionCommand();
+ System.out.println(cmd);
+ }
+
+ private KeyStroke ctrlShift(int vkey)
+ {
+ return KeyStroke.getKeyStroke(
+ vkey,
+ Event.SHIFT_MASK + Event.CTRL_MASK
+ );
+ }
+
+ public static void main(String[] args)
+ {
+ Listing3613 frame = new Listing3613();
+ frame.setLocation(100, 100);
+ frame.setSize(300, 200);
+ frame.setVisible(true);
+ }
+}
\ No newline at end of file |
