Search in sources :

Example 1 with MenuShortcut

use of java.awt.MenuShortcut in project voltdb by VoltDB.

the class DatabaseManager method addMenuItems.

void addMenuItems(Menu f, String[] m) {
    for (int i = 0; i < m.length; i++) {
        MenuItem item = new MenuItem(m[i].substring(1));
        char c = m[i].charAt(0);
        if (c != '-') {
            item.setShortcut(new MenuShortcut(c));
        }
        item.addActionListener(this);
        f.add(item);
    }
}
Also used : MenuItem(java.awt.MenuItem) MenuShortcut(java.awt.MenuShortcut)

Example 2 with MenuShortcut

use of java.awt.MenuShortcut in project jdk8u_jdk by JetBrains.

the class CMenuItem method setLabel.

public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem) getTarget()).getShortcut();
        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;
            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }
    if (label == null) {
        label = "";
    }
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }
    final String finalLabel = label;
    final char finalKeyChar = keyChar;
    final int finalKeyCode = keyCode;
    final int finalKeyMask = keyMask;
    execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar, finalKeyCode, finalKeyMask));
}
Also used : MenuItem(java.awt.MenuItem) MenuShortcut(java.awt.MenuShortcut)

Example 3 with MenuShortcut

use of java.awt.MenuShortcut in project voltdb by VoltDB.

the class DatabaseManager method main.

public void main() {
    fMain = new Frame("HSQL Database Manager");
    imgEmpty = createImage(new MemoryImageSource(2, 2, new int[4 * 4], 2, 2));
    fMain.setIconImage(imgEmpty);
    fMain.addWindowListener(this);
    MenuBar bar = new MenuBar();
    // used shortcuts: CERGTSIUDOLM
    String[] fitems = { "-Connect...", "--", "-Open Script...", "-Save Script...", "-Save Result...", "-Save Result csv...", "--", "-Exit" };
    addMenu(bar, "File", fitems);
    String[] vitems = { "RRefresh Tree", "--", "GResults in Grid", "TResults in Text", "--", "1Shrink Tree", "2Enlarge Tree", "3Shrink Command", "4Enlarge Command" };
    addMenu(bar, "View", vitems);
    String[] sitems = { "SSELECT", "IINSERT", "UUPDATE", "DDELETE", "--", "-CREATE TABLE", "-DROP TABLE", "-CREATE INDEX", "-DROP INDEX", "--", "-CHECKPOINT", "-SCRIPT", "-SET", "-SHUTDOWN", "--", "-Test Script" };
    addMenu(bar, "Command", sitems);
    Menu recent = new Menu("Recent");
    mRecent = new Menu("Recent");
    bar.add(mRecent);
    String[] soptions = { "-AutoCommit on", "-AutoCommit off", "OCommit", "LRollback", "--", "-Disable MaxRows", "-Set MaxRows to 100", "--", "-Logging on", "-Logging off", "--", "-Insert test data" };
    addMenu(bar, "Options", soptions);
    String[] stools = { "-Dump", "-Restore", "-Transfer" };
    addMenu(bar, "Tools", stools);
    Menu hMenu = new Menu("Help");
    MenuItem aItem = new MenuItem("About");
    aItem.setShortcut(new MenuShortcut('A'));
    aItem.addActionListener(this);
    hMenu.add(aItem);
    MenuItem hItem = new MenuItem("Help");
    hItem.setShortcut(new MenuShortcut('H'));
    hItem.addActionListener(this);
    hMenu.add(hItem);
    //bar.add(hMenu);
    // Command above disabled only until a help display bug is fixed.
    fMain.setMenuBar(bar);
    fMain.setSize(640, 480);
    fMain.add("Center", this);
    initGUI();
    sRecent = new String[iMaxRecent];
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension size = fMain.getSize();
    // (ulrivo): full size on screen with less than 640 width
    if (d.width >= 640) {
        fMain.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
    } else {
        fMain.setLocation(0, 0);
        fMain.setSize(d);
    }
    fMain.show();
    // (ulrivo): load query from command line
    if (defScript != null) {
        if (defDirectory != null) {
            defScript = defDirectory + File.separator + defScript;
        }
        txtCommand.setText(DatabaseManagerCommon.readFile(defScript));
    }
    txtCommand.requestFocus();
}
Also used : Frame(java.awt.Frame) MenuBar(java.awt.MenuBar) MenuItem(java.awt.MenuItem) Menu(java.awt.Menu) MenuShortcut(java.awt.MenuShortcut) Dimension(java.awt.Dimension) MemoryImageSource(java.awt.image.MemoryImageSource)

Aggregations

MenuItem (java.awt.MenuItem)3 MenuShortcut (java.awt.MenuShortcut)3 Dimension (java.awt.Dimension)1 Frame (java.awt.Frame)1 Menu (java.awt.Menu)1 MenuBar (java.awt.MenuBar)1 MemoryImageSource (java.awt.image.MemoryImageSource)1