1 package tim.prune.function;
3 import java.awt.BorderLayout;
4 import java.awt.Component;
5 import java.awt.FlowLayout;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
8 import java.awt.event.KeyEvent;
9 import java.awt.event.KeyListener;
11 import javax.swing.BorderFactory;
12 import javax.swing.JButton;
13 import javax.swing.JDialog;
14 import javax.swing.JEditorPane;
15 import javax.swing.JLabel;
16 import javax.swing.JPanel;
17 import javax.swing.JScrollPane;
20 import tim.prune.GenericFunction;
21 import tim.prune.I18nManager;
24 * Class to show a guide to the shortcut keys
26 public class ShowKeysScreen extends GenericFunction
29 private JDialog _dialog = null;
31 private JButton _okButton = null;
36 * @param inApp app object
38 public ShowKeysScreen(App inApp)
46 public String getNameKey() {
47 return "function.showkeys";
57 _dialog = new JDialog(_parentFrame, I18nManager.getText(getNameKey()));
58 _dialog.getContentPane().add(makeContents());
61 _dialog.setLocationRelativeTo(_parentFrame);
62 _dialog.setVisible(true);
63 _okButton.requestFocus();
67 * @return the contents of the window as a Component
69 private Component makeContents()
71 JPanel mainPanel = new JPanel();
72 mainPanel.setLayout(new BorderLayout());
73 JLabel introLabel = new JLabel(I18nManager.getText("dialog.keys.intro") + " :");
74 introLabel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
75 mainPanel.add(introLabel, BorderLayout.NORTH);
77 JEditorPane kp = new JEditorPane("text/html", I18nManager.getText("dialog.keys.keylist"));
78 kp.setEditable(false);
80 kp.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
81 mainPanel.add(new JScrollPane(kp), BorderLayout.CENTER);
83 // OK button at the bottom
84 JPanel okPanel = new JPanel();
85 okPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
86 _okButton = new JButton(I18nManager.getText("button.ok"));
87 _okButton.addActionListener(new ActionListener()
89 public void actionPerformed(ActionEvent e)
94 _okButton.addKeyListener(new KeyListener() {
95 public void keyPressed(KeyEvent e)
97 if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {_dialog.dispose();}
99 public void keyTyped(KeyEvent e) {}
100 public void keyReleased(KeyEvent e) {}
102 okPanel.add(_okButton);
103 mainPanel.add(okPanel, BorderLayout.SOUTH);