001: package net.sourceforge.squirrel_sql.plugins.editextras;
002:
003: import net.sourceforge.squirrel_sql.fw.util.StringManager;
004: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
005:
006: import javax.swing.*;
007: import java.awt.*;
008: import java.awt.event.ActionEvent;
009: import java.awt.event.KeyEvent;
010:
011: public class EscapeDateFrame extends JDialog {
012: private static final StringManager s_stringMgr = StringManagerFactory
013: .getStringManager(EscapeDateFrame.class);
014:
015: JTextField txtYear = new JTextField();
016: JTextField txtMonth = new JTextField();
017: JTextField txtDay = new JTextField();
018: JTextField txtHour = new JTextField();
019: JTextField txtMinute = new JTextField();
020: JTextField txtSecond = new JTextField();
021: // i18n[editextras.timeStamp=Time stamp]
022: JButton btnTimestamp = new JButton(s_stringMgr
023: .getString("editextras.timeStamp"));
024:
025: // i18n[editextras.date=Date]
026: JButton btnDate = new JButton(s_stringMgr
027: .getString("editextras.date"));
028: // i18n[editextras.time=Time]
029: JButton btnTime = new JButton(s_stringMgr
030: .getString("editextras.time"));
031:
032: public EscapeDateFrame(Frame owner) {
033: // i18n[editextras.escapeDate=Escape date]
034: super (owner, s_stringMgr.getString("editextras.escapeDate"));
035:
036: JPanel pnlEdit = new JPanel();
037:
038: pnlEdit.setLayout(new GridLayout(6, 2));
039:
040: // i18n[editextras.year=Year]
041: pnlEdit
042: .add(new JLabel(s_stringMgr
043: .getString("editextras.year")));
044: pnlEdit.add(txtYear);
045: // i18n[editextras.month=Month]
046: pnlEdit.add(new JLabel(s_stringMgr
047: .getString("editextras.month")));
048: pnlEdit.add(txtMonth);
049: // i18n[editextras.day=Day]
050: pnlEdit
051: .add(new JLabel(s_stringMgr.getString("editextras.day")));
052: pnlEdit.add(txtDay);
053: // i18n[editextras.hour=Hour]
054: pnlEdit
055: .add(new JLabel(s_stringMgr
056: .getString("editextras.hour")));
057: pnlEdit.add(txtHour);
058: // i18n[editextras.minute=Minute]
059: pnlEdit.add(new JLabel(s_stringMgr
060: .getString("editextras.minute")));
061: pnlEdit.add(txtMinute);
062: // i18n[editextras.second=Second]
063: pnlEdit.add(new JLabel(s_stringMgr
064: .getString("editextras.second")));
065: pnlEdit.add(txtSecond);
066:
067: JPanel pnlButtons = new JPanel(new GridLayout(3, 1));
068: pnlButtons.add(btnTimestamp);
069: pnlButtons.add(btnDate);
070: pnlButtons.add(btnTime);
071:
072: JPanel pnlMain = new JPanel();
073: pnlMain.setLayout(new BorderLayout());
074:
075: pnlMain.add(pnlEdit, BorderLayout.CENTER);
076: pnlMain.add(pnlButtons, BorderLayout.SOUTH);
077:
078: getContentPane().add(pnlMain);
079: setSize(250, 250);
080:
081: getRootPane().setDefaultButton(btnTimestamp);
082:
083: AbstractAction closeAction = new AbstractAction() {
084: public void actionPerformed(ActionEvent actionEvent) {
085: setVisible(false);
086: dispose();
087: }
088: };
089: KeyStroke escapeStroke = KeyStroke.getKeyStroke(
090: KeyEvent.VK_ESCAPE, 0);
091: getRootPane().getInputMap(
092: JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
093: escapeStroke, "CloseAction");
094: getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
095: .put(escapeStroke, "CloseAction");
096: getRootPane().getInputMap(JComponent.WHEN_FOCUSED).put(
097: escapeStroke, "CloseAction");
098: getRootPane().getActionMap().put("CloseAction", closeAction);
099:
100: }
101: }
|