Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Keyboard-macros/Java/keyboard-macros.java
Normal file
30
Task/Keyboard-macros/Java/keyboard-macros.java
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package keybord.macro.demo;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
class KeyboardMacroDemo {
|
||||
public static void main( String [] args ) {
|
||||
final JFrame frame = new JFrame();
|
||||
|
||||
String directions = "<html><b>Ctrl-S</b> to show frame title<br>"
|
||||
+"<b>Ctrl-H</b> to hide it</html>";
|
||||
|
||||
frame.add( new JLabel(directions));
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
frame.addKeyListener( new KeyAdapter(){
|
||||
public void keyReleased( KeyEvent e ) {
|
||||
if( e.isControlDown() && e.getKeyCode() == KeyEvent.VK_S){
|
||||
frame.setTitle("Hello there");
|
||||
}else if( e.isControlDown() && e.getKeyCode() == KeyEvent.VK_H){
|
||||
frame.setTitle("");
|
||||
}
|
||||
}
|
||||
});
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue