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);
}
}
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));
}
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();
}
Aggregations