Multiple Key Bindings
Hello,
I have a Edit -> Delete menu item. I have set an acclerator Ctrl+D on it.
I want to detect the "Delete" key as well and be able to invoke the Edit-> Delete functionality.
Is it possible? I have looked into the documentation which explains about mnemonic and accelerator but I am not sure how to do this. Any pointers is appreciated.
Thanks in advance.
BP
You could use the input map/action map approach. If you want it frame-wide, you could do stuff likeInputMap inputMap = getRootPane ().getInputMap (JComponent.WHEN_IN_FOCUSED_WINDOW);
ActionMap actionMap = getRootPane ().getActionMap ();
inputMap.put (KeyStroke.getKeyStroke (KeyEvent.VK_DELETE, 0), "delete");
actionMap.put ("delete", yourDeleteAction);(I'm not guaranteeing this compiles)
Similar Messages
-
Control-k key binding broken. How can I check and change my key bindings?
I use the Terminal app a lot. Unfortunately I am not able to use the control-k shortcut to cut lines in the terminal anymore. How can I check (and change) the Terminal key bindings?
Thank you!Basing on your input, you should get the following values:
1) session keys
SK_ENC: 6DCE2A99BACB5207A7A96A92F114D66C
SK_MAC: 0D446132B168F75CD6F0A780693A4DD3
SK_DEK: 19F7B0F94837F32874B29B5EFB7809F6
2) host cryptogram
1B781553209748EA
3) Retail MAC
01761103B810F00E
Summing up, the External Authenticate command should have the following value: 84 82 01 00 10 1B781553209748EA 01761103B810F00E.
Try to compare it with your results.
Regards -
How do you register multiple key presses at the same time?
Hi. I'm trying to write a first person game in OpenGL and I'm having some trouble with key listening. Right now I just use the basic AWT KeyListener. The problem that arises is that whenever I hold down a key, such as a movement key, there is a short pause after it moves me in the appropriate direction, and only after the pause does it start continuously moving me. In addition to that, I can't press multiple keys at once to get diagonal movement (I use WASD for movement). Is there something I can do with AWT to fix both of these problems, or is there something other than AWT that I should use that would be better?
the pause is the typomatic rate of the keyboard, you can avoid that by using the keyPressed and setting a flag then a sleep(myDelayTime).... if they keyRelease--and clearing of the flag--hasn't happened after the sleep, then you're key is still down so keep firing, moving, or what ever.
-
How to get Multiple Key Combinations
Hi,
I am trying to get the event for multiple key combinations, ie some thing like "*Ctrl + I + M*" or "*Alt + A + S + D*".
For two key combinations ( like Ctrl+I or Ctrl+M) i am able to get, but for more than two keys combinations, can someone give an idea how to get it.
I tried with both KeyCodeCombination and KeyCharacterCombination.
Below is a quick example to check for the key combination demo.
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.input.KeyCharacterCombination;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class KeyCombinationDemo extends Application {
Stage stage;
Scene scene;
StackPane root;
public static void main(String[] args) {
Application.launch(args);
@Override
public void start(Stage stage) throws Exception {
this.stage = stage;
root = new StackPane();
root.getChildren().add(new Label("Enter any Key"));
this.scene = new Scene(root, Color.LINEN);
stage.setTitle(this.getClass().getSimpleName());
stage.setWidth(600);
stage.setHeight(600);
stage.setScene(this.scene);
stage.show();
final KeyCombination keyComb1=new KeyCodeCombination(KeyCode.I,KeyCombination.CONTROL_DOWN);
final KeyCharacterCombination keyComb2 = new KeyCharacterCombination("M",KeyCombination.CONTROL_DOWN);
this.scene.addEventHandler(KeyEvent.KEY_RELEASED, new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if(keyComb1.match(event)){
System.out.println("Ctrl+I pressed");
}else if(keyComb2.match(event)){
System.out.println("Ctrl+M pressed");
}Thanks in Advance.
Regards,
Sai Pradeep Dandem.Hi John,
Thanks for the prompt response.
I tried the way you suggested and it worked well !! Thanks :)
But, still i am expecting a direct way to handle this. :p
Anyway here is code which i modified accordingly
final String keyCombination1 = "_ALT_E_O";
final String keyCombination2 = "_ALT_E_P";
final String keyCombination3 = "_CONTROL_H";
final StringBuilder key = new StringBuilder();
this.scene.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
String codeStr = event.getCode().toString();
if(!key.toString().endsWith("_"+codeStr)){
key.append("_"+codeStr);
this.scene.addEventHandler(KeyEvent.KEY_RELEASED, new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if(key.length()>0){
if(key.toString().equals(keyCombination1)){
System.out.println("Key Combination 1 pressed");
}else if(key.toString().equals(keyCombination2)){
System.out.println("Key Combination 2 pressed");
}else if(key.toString().equals(keyCombination3)){
System.out.println("Key Combination 3 pressed");
key.setLength(0);
});Thanks & Regards,
Sai Pradeep Dandem -
Multiple key level associations
Hi,
I am getting the below error during the consistency check.
Table, X, has multiple key level associations.
Can anyone please let me know the reason for the same.
Also, when I drag the physical tables from the physical layer to the BMM Layer, there are some default primary keys in the Logical Table.What considerations does OBIEE take into when deciding upon the Primary Key in the Logical table.
Thanks in Advance
Akshatha"can you check the keys foreign keys for those table "
You didn't mention what I should be checking for.
However, I think I've worked it out now.
I have a dimension table that is referenced by both other dimension tables and the fact tables. Therefore, when imported into BI, both the dimension tables and the fact tables have foreign keys to this common dimension table.
I'm guessing that the foreign keys on the dimension tables are not required - because there are foreign key references from the fact tables to the common table anyway. Bearing in mind that this is a star schema and not a snowflake schema.
=> I deleted all the foreign keys from all my dimension tables, and now the consistency check works ok. -
Key Bindings using the arrow keys
Following is some code that allows you to move a component around the screen using the arrow keys. I've noticed a problem and I'm just wondering if its Java or my keyboard.
Lets start with an example that works:
Press the down and right keys. Then press either the up or left key. The image moves proving that it supports 3 keys.
Now for the problem:
Press the up and left keys. Then press either the down or right key. Three things to notice:
a) the direction doesn't change when the third key is pressed
b) no output is displayed, so the ActionListener is not being invoked
c) after a short time, the program starts beeping
Now try rerunning the code after removing the comments that assign the key bindings to the "a, s, d, f" keys. Redo the above test and it works even if all four keys are pressed.
I don't remember this problem when I wrote the code a while ago, but I did recently get a cheap new keyboard so I'm just wondering if the problem is my keyboard or whether its a quirk with Java.
You can download Duke from here:
http://java.sun.com/docs/books/tutorial/uiswing/examples/components/LayeredPaneDemoProject/src/components/images/dukeWaveRed.gif
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class KeyboardNavigationProblem implements ActionListener
private JComponent component;
private int deltaX;
private int deltaY;
private Timer timer;
private int keysPressed;
private InputMap inputMap;
public KeyboardNavigationProblem(JComponent component, int delay)
this.component = component;
this.deltaX = deltaX;
this.deltaY = deltaY;
timer = new Timer(delay, this);
timer.setInitialDelay( 0 );
inputMap = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
public void addAction(int keyCode, String description, int deltaX, int deltaY)
new NavigationAction(keyCode, description, deltaX, deltaY);
public void updateDeltaX(int delta)
deltaX += delta;
public void updateDeltaY(int delta)
deltaY += delta;
public void actionPerformed(ActionEvent e)
int componentWidth = component.getSize().width;
int componentHeight = component.getSize().height;
Dimension parentSize = component.getParent().getSize();
int parentWidth = parentSize.width;
int parentHeight = parentSize.height;
// Determine next X position
int nextX = Math.max(component.getLocation().x + deltaX, 0);
if ( nextX + componentWidth > parentWidth)
nextX = parentWidth - componentWidth;
// Determine next Y position
int nextY = Math.max(component.getLocation().y + deltaY, 0);
if ( nextY + componentHeight > parentHeight)
nextY = parentHeight - componentHeight;
// Move the component
component.setLocation(nextX, nextY);
class NavigationAction extends AbstractAction implements ActionListener
private int deltaX;
private int deltaY;
private KeyStroke pressedKeyStroke;
private boolean listeningForKeyPressed;
public NavigationAction(int keyCode, String description, int deltaX, int deltaY)
super(description);
this.deltaX = deltaX;
this.deltaY = deltaY;
pressedKeyStroke = KeyStroke.getKeyStroke(keyCode, 0, false);
KeyStroke releasedKeyStroke = KeyStroke.getKeyStroke(keyCode, 0, true);
inputMap.put(pressedKeyStroke, getValue(Action.NAME));
inputMap.put(releasedKeyStroke, getValue(Action.NAME));
component.getActionMap().put(getValue(Action.NAME), this);
listeningForKeyPressed = true;
public void actionPerformed(ActionEvent e)
if (listeningForKeyPressed)
updateDeltaX( deltaX );
updateDeltaY( deltaY );
inputMap.remove(pressedKeyStroke);
listeningForKeyPressed = false;
if (keysPressed == 0)
timer.start();
keysPressed++;
else // listening for key released
updateDeltaX( -deltaX );
updateDeltaY( -deltaY );
inputMap.put(pressedKeyStroke, getValue(Action.NAME));
listeningForKeyPressed = true;
keysPressed--;
if (keysPressed == 0)
timer.stop();
System.out.println(KeyboardNavigationProblem.this.deltaX + " : "
+ KeyboardNavigationProblem.this.deltaY);
public static void main(String[] args)
JPanel contentPane = new JPanel();
contentPane.setLayout( null );
JLabel duke = new JLabel( new ImageIcon("dukewavered.gif") );
duke.setSize( duke.getPreferredSize() );
duke.setLocation(100, 100);
contentPane.add( duke );
KeyboardNavigationProblem navigation = new KeyboardNavigationProblem(duke, 100);
navigation.addAction(KeyEvent.VK_LEFT, "zLeft", -5, 0);
navigation.addAction(KeyEvent.VK_RIGHT, "zRight", 5, 0);
navigation.addAction(KeyEvent.VK_UP, "zUp", 0, -5);
navigation.addAction(KeyEvent.VK_DOWN, "zDown", 0, 5);
// navigation.addAction(KeyEvent.VK_A, "zLeft", -5, 0);
// navigation.addAction(KeyEvent.VK_S, "zRight", 5, 0);
// navigation.addAction(KeyEvent.VK_D, "zUp", 0, -5);
// navigation.addAction(KeyEvent.VK_F, "zDown", 0, 5);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setContentPane( contentPane);
frame.setSize(800, 600);
frame.setLocationRelativeTo( null );
frame.setVisible(true);
}if you hold down left and right (so it doesn't move), down works, but not up.
hold up/down, right works but not left.Yes, the problem only seems to be when the up and left in combination with the right or down key is pressed.
num lock off - use the number pad arrow keys and all works OK Thats interesting, I didn't notice that. Although it just confuses the issue as to what the problem is.
So it appears to me that:
a) left + up + down, and
b) left + up + right
are special key combinations that are intercepted by either the OS or the JVM. Do these key combinations ring a bell to anybody?
I'm use JDK1.4.2 on XP. I wonder if other OS will have the same problem?
Again, this isn't a real, problem, just more of a curiosity. Thanks, -
Problem: sqldeveloper 1.5 key bindings in mac os x
Hi -
I just installed the new sqldeveloper (1.5.0.53.38) on Mac OS X Leopard, and when I try to edit sql queries in the worksheet, I'm finding that many keys don't work. For example, the spacebar and delete keys do nothing.
I tried loading various different accelerator presets:
- after loading "Default MacOS X" set, neither space nor delete keys do anything
- after loading "Default", "Classic" or "Brief" sets, the spacebar works, but not delete
I tried to fix this by changing the accelerators through the Preferences UI, but I couldn't figure out how to assign the 'backspace' key to the 'delete-previous' accelerator (since it doesn't seem possible to type the actual backspace character in the keystroke box...). I was able to fix the delete key by editing settings.xml by hand, changing this:
<Item class="oracle.javatools.util.Pair">
<first class="java.lang.String">delete-previous</first>
<second class="oracle.ide.keyboard.KeyStrokes">
<data>
<Item class="javax.swing.KeyStroke">[0]</Item>
</data>
</second>
</Item>
to this:
<Item class="oracle.javatools.util.Pair">
<first class="java.lang.String">delete-previous</first>
<second class="oracle.ide.keyboard.KeyStrokes">
<data>
<Item class="javax.swing.KeyStroke">[8]</Item>
</data>
</second>
</Item>
I was able to get the spacebar to work again by removing the association between the spacebar key and the completion-insight accelerator, using the Preferences UI.
So, my questions are:
- Do I have some weird setup where my delete key is [8] instead of [0]? I'm trying to tell if this is a problem with my environment or with the settings that are shipped with the product.
- If it's the latter, could the default MacOS X accelerator settings be updated? I seem to remember this same problem happening the last couple of times I installed a new version of SQL Developer.
Let me know if there's any other information I could provide that would be useful.
Thanks!Another problem I found with the MacOS X key bindings: the 6 key doesn't work!
In the config that ships with SQL Developer, I found this:
<Item class="oracle.javatools.util.Pair">
<first class="java.lang.String">DOCUMENT_6_CMD_ID</first>
<second class="oracle.ide.keyboard.KeyStrokes">
<data>
<Item class="javax.swing.KeyStroke">6</Item>
</data>
</second>
</Item>
which should be:
<Item class="oracle.javatools.util.Pair">
<first class="java.lang.String">DOCUMENT_6_CMD_ID</first>
<second class="oracle.ide.keyboard.KeyStrokes">
<data>
<Item class="javax.swing.KeyStroke">meta 6</Item>
</data>
</second>
</Item> -
BPC for Excel: Are multiple key ranges really possible?
Hi Experts,
in a training document I found to possibility of multiple key ranges, to make an input schedule sheet more attractive or insert rows with excel formulas etc.
For example: ColKeyRange: EVRNG(H13:J13;M13:O13)
RowKeyRange: EVRNG(G15:G20;L15:L20)
In my case I want the balance sheet separated. On the left side asset positions, on the right side liability positions (in columns for bot: Previous Year | Actual | Plan
If I define my input schedule like that it gets messed up. No figures, weird formatting etc. Have you implemented an input schedule with multiple key ranges and did it work ok?
Thank you,
CoraHi Cora,
Yes, multiple key ranges do work, but it is a bit complicated as Dzmitry suggests. Your example row expansion will not work, as the row expansion needs to remain in the same columns for each part of the expansion. (In other words, EVRNG(G15:G20;L15:L20) is wrong but EVRNG(G15:G20;G25:G30) is ok.) To achieve your result, Dzmitry is correct that you will probably need to use two EVDREs.
That said, multiple expansions work as follows:
If you are not using an expansion, or you use NOEXPAND in your columns or rows, you can use a multiple key range for formatting purposes and simply hardcode in the members that you wish to see in each key range.
If you want to see different expansions in each key range, then you need to use a special expansion syntax. To take your example, say you have a single dimension in your column with column range defined EVRNG(H13:J13;M13:O13). You could have your column expansion on the category dimension be "PRIORYR,ACTUAL,PLAN|PLAN,ACTUAL,PRIORYR", giving you the same set of categories reversed in each column.
Ethan -
Thinkpad keyboard problem - some keys generate multiple keys when pressed
thinkpad keyboard problem - some keys generate multiple keys when pressed
For example, "t" generates "tr", "y" generates "yu", "backspace" generates "backspace" plus "IBM access connections", "m" generates "mn" and "n" generates "mn". Not all keys are wrong.
For what it's worth, the odd behaviour started shortly after a trip to Miami in which I had a meeting at a cafe in which we were undercover but it was pouring cats and dogs - it was like having a meeting in a sauna - so I am wondering if the high humidity could have caused the behaviour.
I tried replacing the keyboard but the new keyboard has the same problem.
The machine in question is a Thinkpad T23 running Windows XP Pro
Any help would be appreciated as I am now in Los Angeles using a borrowed Mac! :-)i have something along the lines of the same problem.
http://bbs.archlinux.org/viewtopic.php?id=56777
my conclusion is something in the last system update screwed it up. -
How to sort on MULTIPLE Keys which are elements of VO's stored in list
How to sort on MULTIPLE Keys which are elements of VO's stored in a list.. without disturbing the ordering done by previous sorting...?
Is there any best soln for the same...
Thanks..How to sort on MULTIPLE Keys which are elements of
VO's stored in a list.. without disturbing the
ordering done by previous sorting...?Do you mean you want to do a heirarchical sort? Where the secondary key is only used when the primary keys are equal etc.? That's pretty trivial. If the primary keys are equal, check the secondary key. How do you sort words in alphabetical order? It's the same process. -
BDB- Recno multiple key/data pairs retrieval
Hey,
I am new to BDB and have just started to work with Berkley DB (ver. 5.3.15) using the Linux C API.
I set up a simple Recno DB which is populated with sequential keys 1,2,3….100. DB Records are in variable length size, although, I am limiting them to a max size.
Below are the environment and DB open flags I am using:
dbenv->open(dbenv, DB_HOME_DIR, DB_SYSTEM_MEM | DB_INIT_LOCK | DB_CREATE | DB_INIT_MPOOL, 0)
dbp->open(dbp, NULL, NULL,DATABASE_NAME, DB_RECNO, DB_CREATE, 0664))
Single record get/put or using cursor to iterate over the all DB works well.
However, I would like to retrieve multiple records in a single get call.
These records can be non-sequential.
For example, retrieving 3 records with the keys 4,89,90. I prefer the bulk buffer to be as minimal as possible (avoiding stack or heap unnecessary memory allocation).
I was reading and saw few examples about using bulk retrieval. Though, I couldn’t find any example for racno bulk get on multiple specified keys.
From what I figured out till now, it seems that I should use:
Get flags: DB_SET_RECNO, DB_MULTIPLE_KEY. And the macros: DB_MULTIPLE_INIT and DB_MULTIPLE_RECNO_NEXT to iterate over a bulk buffer received.
But, I couldn’t figure it out where and how I should specify the list of Keys.
Beside, the BDB man says: "For DB_SET_RECNO to be specified, the underlying database must be of type Btree, and it must have been created with the DB_RECNUM flag."
Does the BDB open with DB_RECNO flag imply that the underlying database is Btree? If creating Btree instead of recno, wouldn’t I loss access performances?
I would appreciate if anyone could supply some guidelines or an example which will assist me to figure it out how to retrieve multiple key/data pairs from a recno DB.
Thanks in advance
KimelI am checking the BDB to see if it can suit my needs (mostly performance wise).
It should work on a simple home router device and should hold router runtime information (static/dynamic).
This information should be accessible for process in the system which can write or read the device info.
The DB is not require to be persistent and is recreated every reboot (memory only).
I believe the DB will hold not more then 200 parameters at max.
DB access rate is around 30 records per sec (write/read)...
Currently, I think of either BDB or maybe just use a normal Linux shared memory (random access + semaphore).
Cons and pros to each...
If I choose BDB, I will use the in memory DB and recno due to access performance considerations.
Getting back to my question, I would like to be able to read a list of parameters in a single get call.
In order to use recno, I will give every parameter a unique id (1 - ip, 2 - subnet , 3 - default gateway).
e.g: ip , subnet , default gateway. (get keys 1,2,3)
Hope you have the relevant info.
Thanks -
Copy & paste multiple key frames?
Is there a way to copy and paste multiple key frames?
Thanks.Drawing a marque around multiple keyframes is easy, too. You can select a property and all of its keyframes will be selected. You can performa sophisticated choices of non-continguous keyframes with command-select. You can also do lots of editing in the graph view.
-
IsKeyDown - Multiple key detection ?
does anyone know of how to read two keys or check two keys are down/pressed?
I am trying to do a game where the object can mover diagonally so i need the game to react differently if 2 cursor keys are down?
Any ideas about the isKeyDown() function?
The keypressed/ keyreleased function i think will only detect one at a time.
cheers allTry this quick Swing App I knocked up using Sun One. It shows multiple key detection, doesn't mind simultaneous key presses.
I wrote the code for clarity more than anything else.
Run it, see what it does and how it reacts to the cursor keys being pressed.
* KeyEvents.java
* Created on 05 December 2002, 16:21
package andy.apps.KeyEvents;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class KeyEvents extends javax.swing.JFrame {
/** Creates new form KeyEvents */
public KeyEvents() {
initComponents();
upPanel.registerKeyboardAction(new UpOnListener(), KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0, false), JComponent.WHEN_IN_FOCUSED_WINDOW);
upPanel.registerKeyboardAction(new UpOffListener(), KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0, true), JComponent.WHEN_IN_FOCUSED_WINDOW);
downPanel.registerKeyboardAction(new DownOnListener(), KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0, false), JComponent.WHEN_IN_FOCUSED_WINDOW);
downPanel.registerKeyboardAction(new DownOffListener(), KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0, true), JComponent.WHEN_IN_FOCUSED_WINDOW);
leftPanel.registerKeyboardAction(new LeftOnListener(), KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0, false), JComponent.WHEN_IN_FOCUSED_WINDOW);
leftPanel.registerKeyboardAction(new LeftOffListener(), KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0, true), JComponent.WHEN_IN_FOCUSED_WINDOW);
rightPanel.registerKeyboardAction(new RightOnListener(), KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0, false), JComponent.WHEN_IN_FOCUSED_WINDOW);
rightPanel.registerKeyboardAction(new RightOffListener(), KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0, true), JComponent.WHEN_IN_FOCUSED_WINDOW);
class UpOnListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
KeyEvents.this.upPanel.setBackground(Color.black);
class UpOffListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
KeyEvents.this.upPanel.setBackground(Color.white);
class DownOnListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
KeyEvents.this.downPanel.setBackground(Color.black);
class DownOffListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
KeyEvents.this.downPanel.setBackground(Color.white);
class LeftOnListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
KeyEvents.this.leftPanel.setBackground(Color.black);
class LeftOffListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
KeyEvents.this.leftPanel.setBackground(Color.white);
class RightOnListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
KeyEvents.this.rightPanel.setBackground(Color.black);
class RightOffListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
KeyEvents.this.rightPanel.setBackground(Color.white);
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
private void initComponents() {
upPanel = new javax.swing.JPanel();
leftPanel = new javax.swing.JPanel();
downPanel = new javax.swing.JPanel();
rightPanel = new javax.swing.JPanel();
getContentPane().setLayout(new java.awt.GridLayout(2, 2));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
upPanel.setBorder(new javax.swing.border.TitledBorder("Up"));
upPanel.setBackground(new java.awt.Color(255, 255, 255));
getContentPane().add(upPanel);
leftPanel.setBorder(new javax.swing.border.TitledBorder("Left"));
leftPanel.setBackground(new java.awt.Color(255, 255, 255));
getContentPane().add(leftPanel);
downPanel.setBorder(new javax.swing.border.TitledBorder("Down"));
downPanel.setBackground(new java.awt.Color(255, 255, 255));
getContentPane().add(downPanel);
rightPanel.setBorder(new javax.swing.border.TitledBorder("Right"));
rightPanel.setToolTipText("null");
rightPanel.setBackground(new java.awt.Color(255, 255, 255));
getContentPane().add(rightPanel);
pack();
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
* @param args the command line arguments
public static void main(String args[]) {
new KeyEvents().show();
// Variables declaration - do not modify
private javax.swing.JPanel upPanel;
private javax.swing.JPanel leftPanel;
private javax.swing.JPanel rightPanel;
private javax.swing.JPanel downPanel;
// End of variables declaration
} -
KeyBindings: Multiple key selections for actionPerformed in one methdo
I'm making a program where I have several objects that respond differently when different buttons are pressed. I'd like to use key bindings without using anonymous or inner classes as per my preference (I think the code is cleaner and easier to read and understand), so I'd like to find a way to determine which key was pressed in which object. I have an SSCCE here with some psueudocode that is an attempt to explain what I'm trying to do.
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.WindowConstants;
public class SSCCE extends AbstractAction
private JPanel p = new JPanel();
private JTextField t[] = {new JTextField(10),new JTextField(10)};
public SSCCE()
JFrame f = new JFrame("SSCCE");
p.add(t[0]);
p.add(t[1]);
p.getActionMap().put(p.getInputMap().get(KeyStroke.getKeyStroke("F1")), this);
p.getActionMap().put(p.getInputMap().get(KeyStroke.getKeyStroke("F2")), this);
p.getActionMap().put(p.getInputMap().get(KeyStroke.getKeyStroke("F3")), this);
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.setSize(300,100);
f.setLocationRelativeTo(null);
f.add(p);
f.setVisible(true);
@Override
public void actionPerformed(ActionEvent arg0)
/*if (t[0] has focus when event is fired)
* if(F1 is pressed)
* //do some code
* else if(F2 is pressed)
* //do other code
* else
* //do some code
*else if(t[1] has focus when event is fired)
* if(F1 is pressed)
* //do some code
* else if(F2 is pressed)
* //do some code
* else
* //do some code
public static void main(String[] args)
new SSCCE();
}How? I just tried that, but it didn't work.
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.WindowConstants;
public class SSCCE
private JPanel p = new JPanel();
private JTextField t[] = {new JTextField(10),new JTextField(10)};
public SSCCE()
JFrame f = new JFrame("SSCCE");
p.add(t[0]);
p.add(t[1]);
t[0].getActionMap().put(t[0].getInputMap().get(KeyStroke.getKeyStroke("F1")), new t0F1());
t[0].getActionMap().put(t[0].getInputMap().get(KeyStroke.getKeyStroke("F2")), new t0F2());
t[1].getActionMap().put(t[1].getInputMap().get(KeyStroke.getKeyStroke("F1")), new t1F1());
t[1].getActionMap().put(t[1].getInputMap().get(KeyStroke.getKeyStroke("F2")), new t1F2());
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.setSize(300,100);
f.setLocationRelativeTo(null);
f.add(p);
f.setVisible(true);
public static void main(String[] args)
new SSCCE();
public class t0F1 extends AbstractAction
@Override
public void actionPerformed(ActionEvent e)
System.out.println(e.getSource());
public class t0F2 extends AbstractAction
@Override
public void actionPerformed(ActionEvent e)
System.out.println(e.getSource());
public class t1F1 extends AbstractAction
@Override
public void actionPerformed(ActionEvent e)
System.out.println(e.getSource());
public class t1F2 extends AbstractAction
@Override
public void actionPerformed(ActionEvent e)
System.out.println(e.getSource());
} -
Combine multiple key figures in single key figure
Hi,
We have a requirement where we need to put multiple key figures into a single key figure
For example source DSO is as follows (+ Unit object):
Region | Date | Amount | Quantity
Asia | 01-01-2008 | 100 | 1000
Eurpoe | 02-02-2008 | 200 | 2000
In Target DSO / Cube, the data must appear like this (no Unit Object)
Region | Date | Type | Value
Asia | 01-01-2008 | Amount | 100
Asia | 01-01-2008 | Quantity | 1000
Eurpoe | 02-02-2008 | Amount | 200
Eurpoe | 02-02-2008 | Quantity | 2000
How do we achieve this?
Regards,
NikhilHi
Write a strart routine that maps Type ->Amount and Quantity,Value -> Kf of Amount or Quantity
Put these chars into Key fields in target DSO = Region | Date | Type ,that will assure unique entries
Bye
Maybe you are looking for
-
Using environment variable in local site folder filespec
Configuration: Dreamweaver CC 2014.1; Windows 7 I have quite a few sites defined in Dreamweaver and would like to define the folder locations using environment variables so thst if I decide to reorganize my disk (again) I can just redefine the variab
-
Consuming XI webservice in WDJ
Hello, I am trying to invoke an XI webservice through Web Dynpro JAVA. I am provided with an WSDL, URL and uid/pwd from the XI team. URL format : http://company.com:59600/XISOAPAdapter/MessageServlet?channel=:DS7CLNT110:Sender_SOAP_XXXX Steps i follo
-
Adobe Air refuses to install OS X 10.6
I've been trying for the past hour or so to find a way to install Adobe AIR on my MacBook Pro. As it begins to install, it gives me an error stating that "An error occurred while installing Adobe AIR. Installation may not be allowed by your administr
-
my ipod dosen't play out of the left speaker. its not the beadphones because i've tried it on my stereo. ocasionally if i move the chord just right it plays but fairly faintly. i was wondering if there is a way to fix it without having to send it in,
-
NEED HELP WITH TRIGGER????
THIS IS TWO TABLE I NEED CREATE TABLE "METHODS_LIVE" "ID" INTEGER NOT NULL, "OBJECTID" INTEGER NOT NULL, "LA_KEY" VARCHAR(255) NULL, "PROCEDURENAME" VARCHAR(255) NULL, "LA_ORDER" INTEGER NOT NULL, "TAG" VARCHAR(255) NULL, PRIMARY KEY ("ID") CREATE TA