Arrow key functionality in the ButtonGroup  
Author Message
srinivas.veeranki





PostPosted: 2006-7-27 13:55:00 Top

java-programmer, Arrow key functionality in the ButtonGroup Hi All,

I added 4 JRadio buttons to ButtonGroup. For these radio buttons i am
unable to achieve the arrow key functionality. here i am attaching the
code

rateList = theController.getDeleteOptionList();
for (int i = 0, j = 1; i < rateList.size(); i++) {
ListElement listRb = (ListElement) rateList.get(i);
JRadioButton radioBtn = new JRadioButton(listRb.getTextValue());
radioBtn.setActionCommand(listRb.getTextValue());
radioBtn.addActionListener(actionclass);
deleteButtonGrp.add(radioBtn);
}

Thanks for ur help in advance...

Srinivas.

 
srinivas.veeranki





PostPosted: 2006-7-27 16:34:00 Top

java-programmer >> Arrow key functionality in the ButtonGroup Hi All,

I added 4 JRadio buttons to ButtonGroup. For these radio buttons i am
unable to achieve the arrow key functionality. here i am attaching the

code


rateList = theController.getDeleteOptionList();
for (int i = 0, j = 1; i < rateList.size(); i++) {
ListElement listRb = (ListElement)
rateList.get(i);
JRadioButton radioBtn = new
JRadioButton(listRb.getTextValue());

radioBtn.setActionCommand(listRb.getTextValue());
radioBtn.addActionListener(actionclass);
deleteButtonGrp.add(radioBtn);



}


Thanks for ur help in advance...

Srinivas.

 
Andrew Thompson





PostPosted: 2006-7-27 17:27:00 Top

java-programmer >> Arrow key functionality in the ButtonGroup email***@***.com wrote:
..
> I added 4 JRadio buttons to ButtonGroup. For these radio buttons i am
> unable to achieve the arrow key functionality. here i am attaching the
> code

Here is compilable code..

<sscce>
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;

public class ArrowKeyNavigation {

public static void main(String[] args) {
JFrame f = new JFrame("ButtonGroupNavigation");
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

/* from
http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html
*/
Set forwardKeys = f.getFocusTraversalKeys(
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
Set newForwardKeys = new HashSet(forwardKeys);
newForwardKeys.add(
KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0));
f.setFocusTraversalKeys(
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
newForwardKeys);

Set backwardKeys = f.getFocusTraversalKeys(
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
Set newBackwardKeys = new HashSet(backwardKeys);
newBackwardKeys.add(
KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0));
f.setFocusTraversalKeys(
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
newBackwardKeys);

Container c = f.getContentPane();
c.setLayout(new GridLayout(1,0));

ButtonGroup bg = new ButtonGroup();
for (int ii=0; ii<4; ii++) {
JRadioButton b = new JRadioButton("Btn " + ii);
bg.add( b );
c.add( b );
}

f.pack();
f.setVisible(true);
}
}
</sscce>

HTH

Andrew T.

 
 
Andrew Thompson





PostPosted: 2006-7-27 17:50:00 Top

java-programmer >> Arrow key functionality in the ButtonGroup email***@***.com wrote:
> Hi All,

<drily>Hello again</drily>

You already have answers on the other thread,

Please learn to use the "Separate multiple groups
with commas' functionality of your web interface to
Usenet.

Andrew T.