Технологии Java
Обработка событий
public class F1EventListener extends KeyAdapter { public void keyTyped(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F1 && e.getModifiers() == 0) { // Нажата клавиша F1 } } }
public class OpenAction extends AbstractAction { public OpenAction() { super("Open"); putValue(SHORT_DESCRIPTION, "Open a directory"); putValue(SMALL_ICON, loadIcon("load16.gif")); } public void actionPerformed(ActionEvent e) { // Open directory } }
frame.getRootPane().getInputMap( JComponent.WHEN_IN_FOCUSED_WINDOW ).put( KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.ALT_MASK), "gotoText" ); frame.getRootPane().getActionMap().put( "gotoText", gotoTextAction);
try { UIManager.setLookAndFeel("com.sun.java" + ".swing.plaf.windows.WindowsLookAndFeel"); // Обновление L&F окна SwingUtilities.updateComponentTreeUI(this); } catch (Exception e) { System.err.println("Cannot set look and feel: " + e.getMessage()); }
java -Dswing.defaultlaf=com.sun.javax.swing. plaf.windows.WindowsLookAndFeel …