Switch through buttons of a buttonGroup (manually)

Hello everybody,
i created a little editor to resize, relocate, rotate etc... a simple Jpanel.
The edit options e.g. resize are realized as buttons within a buttongroup, so that only one option can be activated at a time.
This works fine by using a actionListener with the mouse for now, but i would like to set these options with a different input device too.
final JToggleButton bt_Resize = new JToggleButton();
bt_Resize.setName(Properties.idOptionResize);
buttonList.put(Properties.idOptionResize, bt_Resize);
final JToggleButton bt_Rotate = new JToggleButton();
bt_Rotate.setName(Properties.idOptionRotate);
buttonList.put(Properties.idOptionRotate, bt_Rotate);
final JToggleButton bt_Relocate = new JToggleButton();
bt_Relocate.setName(Properties.idOptionRelocate);
buttonList.put(Properties.idOptionRelocate, bt_Relocate);
ActionListener actionListener = new ActionListener() {
     public void actionPerformed(ActionEvent actionEvent) {
             if (actionEvent.getActionCommand().equals(Properties.idOptionResize)){
          editOption = Properties.idOptionResize;
             } else if (actionEvent.getActionCommand().equals(Properties.idOptionRotate)){
          editOption = Properties.idOptionRotate;
             } else if (actionEvent.getActionCommand().equals(Properties.idOptionRelocate)){
             editOption = Properties.idOptionRelocate;
};//end actionListener
initButtons(buttonList, actionListener);
(...)i already get commands like "up" and "down" from this device and would now like to switch through the buttons accordingly:
public void processCommand(String command) {
if(command.equals(Properties.idDown)){
     // set next button as selected
} else if(command.equals(Properties.idUp)){
     // set previous button as selected
...               Is there a simple way to switch through the buttons in a buttonGroup so that with every command (up/down) the next or previous button is selected?

@ Calypso: i got a panel with vertically arranged buttons like this:
[button1]
[button2]
[button3]
[button4]and by switching up/down i meant select the next or previous button in that "list". e.g. button2 is selected i want to switch to button3 (down) or button1 (up) without using the mouse.
@ Encephalopathic: thanks for your effort, but i found a much easier way to get the result i needed:
//first i create a list of all buttons:
ArrayList<JtoggleButton> buttonList;
// the buttons are added to the list right after adding them to the panel
//this is the method that selects the next/previous button like clicking on it directly
private void moveButtonEntry(int index){
     JToggleButton[] btnArray;
     boolean noButtonSelected = true;
     boolean indexInBounds = true;
     if (!buttonList.isEmpty()){
          btnArray = buttonList.toArray(new JToggleButton[0]);     
          int i = 0;
          while (indexInBounds){
               if (i > btnArray.length - 1) {
                    indexInBounds = false;
               } else {
                    if (btnArray.isSelected()){
                         if ((i+index < btnArray.length) && (i+index > -1)){
                              btnArray[i+index].doClick();//setSelected(true);
                              indexInBounds = false;
                              noButtonSelected = false;
                         } else {
                              indexInBounds = false;
                              noButtonSelected = false;
                    i++;
          }//end while
          /* if none of the buttons is selected yet, select the first one! */
          if(noButtonSelected){
               btnArray[0].doClick();//setSelected(true);
}//end moveButtonEntry

Similar Messages

  • HT5012 I am having difficulty XMIT/REC text messages to family members using Android phones?  I have a 3GB data plan and all switches and buttons are set properly.  Any suggestions?

    I am having difficulty XMIT/REC text messages to family members using Android phones?  I have a 3GB data plan and all switches and buttons are set properly.  Any suggestions?

        Hello APVzW, we absolutely want the best path to resolution. My apologies for multiple attempts of replacing the device. We'd like to verify the order information and see if we can locate the tracking number. Please send a direct message with the order number so we can dive deeper. Here's steps to send a direct message: http://vz.to/1b8XnPy We look forward to hearing from you soon.
    WiltonA_VZW
    VZW Support
    Follow us on twitter @VZWSupport

  • I would like to duplicate the folders and apps that I have set up on my iPhone to my iPad.  Is there a quick way of doing this without going through the whole process again manually?

    I would like to duplicate the folders and apps that I have set up on my iPhone to my iPad.  Is there a quick way of doing this without going through the whole process again manually?

    You can restore your iPad with your iPhone backup but items that are iPhone only will not transfer.  It should recreate all your folders.  It can't hurt anything to try.

  • My safari screen suddenly fills my entire screen, and there is no right hand corner button to push to manually shrink it. What to do? I can never even exit the program without quitting it.

    My screen when I am using Safari suddenly fills my entire screen, and there is no right hand corner button to push to manually shrink it. What to do? I can never even exit the program without quitting it.This has happened only within the last two days.

    Try changing the screen resolution.
    Go to Apple Menu / System Preferences / Displays.
    Change the resolution. Whatever numbers are shown, e.g. 1280 x 960, select a larger one. The larger the number, in the resolution the smaller the display on the screen. You can keep changing this till you find the resolution that suits you.

  • Nokia 520 switch on button not working

    Ive had a Nokia 520 for only 4 months and its broken as the switch on button does not light up the phone all other aspects of the phone are working.....3 are not interested and are still taking monthly payments for a phone I cant use unless someone contacts me and the screen lights up. I would like some good advice please as of how to fix this or have this fault repaired? Thankyou

    If the button is broken, you need to get it repaired at a local Nokia Care Center. But as an alternative, you can use camera button to unlock your phone, just hold the camera button for a second.
    If this feature is not enabled on your phone, you can enable it in Settings->applications->Photos+camera

  • Navigation to new sceen through button click in as2

    Hi ,
    I need help in Navigation to new sceen through button click in as2
    thanks

    Then use the gotoAndStop() or gotoAndPlay() functions.  IF you are using scenes you might have some problems.  Scenes have always been problematic when it comes to working with Actionscript.  You are better off creating your scenes as movieclips or as sections along one scene's timeline.

  • Switch display button not working

    Hi I recently installed arch on my HP laptop, and everything is running, exept for my switch display button (Fn+F4).
    Before arch, I used to run debian and ubuntu, in both the button worked fine.
    Trying a workarond, I could setup my xorg to set the display to an external tv using the nvidia-settings, but the fonts are huge, do anybody knows how to fix it?
    Thanks

    I installed a newer version of the nvidia driver, now the switch display button is working.

  • Why I can't I do a songs sort which are marked by !'s (apostrophes) on the left side of list indicating the song does not exist in my music border, instead of scrolling through 1000's of song manually?? Seems stupid, no?

    Why I can't I do a songs sort which are marked by !'s (apostrophes) on the left side indicating the song does not exist in my music border, instead of scrolling through 1000's of song manually?? Seems stupid, no? And these !'s appear only when you try to play that song and it says "unable to locate".

    Use Shift+Delete to remove items from a playlist and the library at the same time.
    tt2

  • Photoshop CS6, Mac OS, switching through open images with OS command no more possible

    Using Photoshop CS6 (13.0.1) on a Mac Pro OSX v 10.6.8 it is no more possible to switch through open image windows with the OS related key combo "command <".
    There is also no Photoshop own configurable command available, that could solve this issue.
    CS5 or versions below always allowed that, and I very much miss this practical and fast switching between images, much faster then having to maneuver down through the "windows" menue.
    Anybody knows a solution?

    thanks conroy, Ctrl+Tab does the trick! - Gerhard

  • When I open about this mac - more info and I switch through the tabs (display,memory,storage,support,service) it lags (fps drops, animation looks choppy not smooth). Why does this happen? (over 300 gb free,same programs installed,free desk-downloads)

    When I open about this mac -> more info and I switch through the tabs (display,memory,storage,support,service) it lags (fps drops, animation looks choppy not smooth) even though all the mac (programs , interface ) works smooth . Why does this happen? (over 300 gb free,same programs installed,free desktop-downloads -no garbage there- everything neat and tidy.) Need some help. Only there it the animations goes like 2 fps and is not smooth. I do not understand why because the programs are the same so its the usage. Nothing is changed, yet i experience this little issue for a couple of days.

    OK, I'm confused. When I do About this Mac > More Info in OS10.9, I don't see any animation other than the window resizing. Is that the animation you are describing?
    Which if any of the following apply to your computer:
    1) Are you running any anti-virus/internet security applications?
    2) Are you running any "cleaning/tune-up/optimizations" applications?
    3) Any peer-to-peer or torrent downloading software?
    4) Any third-party disk backup software that came bundled with an external hard drive?
    5) Any online backup scheme other than iCloud (Carbonite; GoogleDrive; MS One Drive)?
    6) Did your financial institution ask you to install Trusteer EndPoint Protection (also known as Trusteer Rapport)?

  • Is there a way to change the order that Ctrl+` switches through tab groups?

    I prefer for Ctrl+Tab to switch between tabs in the most-recently used order (the same way Alt-Tab works), so I use that setting in about:config. Is there a way to do the same thing with the Ctrl+` shortcut that switches through tab groups? By default it appears to cycle through all of them, regardless of the order of use, which is very inconvenient for me, because I have tab groups that I don't use very frequently that just get in the way when cycling through them.
    Barring that, is there a way to make it so that Ctrl-Tab cycles through all tabs, regardless of what group they're in?
    I'd really appreciate any information. Thanks!

    You're not alone in wanting this.  Feel free to provide feedback to Apple directly:
    http://www.apple.com/feedback/ipad.html

  • Change of Tab in Tabstrip through Button

    hi,
    I want to change tabs through Buttons. I have given two buttons like Next & Previous. I have given contextAttribute "SelectedTab" and bind with selectedTab property of tabstrip. i have done this coding
    public void onActionPrevious(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionPrevious(ServerEvent)
         if(wdContext.currentContextElement().getSelectedTab()=="FamilyTab")
              wdContext.currentContextElement().setSelectedTab("PersonalTab");
                else if (wdContext.currentContextElement().getSelectedTab()=="AddressTab")
                   wdContext.currentContextElement().setSelectedTab("FamilyTab");
    It is working fine. But this type of code is not good programming skills becoz there are so many tabs here.
    Please give me some other coding so that code will be less and programming skills are good.
    Regards
    Manish

    Hi,
    As you told that for each tab you have seperate views.
    Now create attributes previous and next in your controller and map it to each view.
    Suppose you have 3 tabs:
    Parent      Family      Address
    In parent tab's view, in wdDoInit() write the following:
    wdContext.currentContextElement().setPrevious("");
    wdContext.currentContextElement().setNext("FAMILY_TAB_ID");
    In family tab's view, in wdDoInit() write the following:
    wdContext.currentContextElement().setPrevious("PARENT_TAB_ID");
    wdContext.currentContextElement().setNext("ADDRESS_TAB_ID");
    In address tab's view, in wdDoInit() write the following:
    wdContext.currentContextElement().setPrevious("FAMILY_TAB_ID");
    wdContext.currentContextElement().setNext("");
    Now in the main view where you have tabs and the previous and next button, you can access the previous and next attributes.
    Say onActionPrevious you can write:
    wdContext.currentContextElement().setSelectedTab(wdContext.currentContextElement().getPrevious());
    and in the same way you can write for onActionNext:
    wdContext.currentContextElement().setSelectedTab(wdContext.currentContextElement().getNext());
    Hope now you got my point.
    thanks & regards,
    Manoj

  • Can we change the View attribute of the Switcher through PERSONALISE PAGE?

    Can we change the View attribute of the Switcher through PERSONALISE PAGE? I want this switcher to display another column. This switcher that i want to change is a seeded one. I have extended a VO and added a new attribute. I want this Switcher to display this new attribute. How can I acheive this.
    Regards
    Ali

    When I do exactly that I get a .XLS file that when you open it and click Save As comes up in Single Web Page mode. When I change the type I get a much smaller file. I am doing exactly what you describe, but with different results. Is it possible that this is configurable?
    Here is a screenshot of me exporting:
    http://i879.photobucket.com/albums/ab359/jameyweare/problem1.gif
    Here is the properties of the file. As you can see the size is 215kb This is actually a very small query for for demonstration purposes. I have queries that return 20k rows with 10 to 15 columns. This creates a spreadsheet that is over 20MB.
    http://i879.photobucket.com/albums/ab359/jameyweare/problem2.gif
    This next screenshot is of the Save As dialog from Excel. I have highlighted the file type that the file is currently saved in.
    http://i879.photobucket.com/albums/ab359/jameyweare/problem3.gif
    In this screenshot I have changed the file format.
    http://i879.photobucket.com/albums/ab359/jameyweare/problem4.gif
    Here is the new properties. The file size has decreased to 57.5kb. In the cases where I had files that were 20MB or greater (and took aver 10 minutes to open up), this process reduced those files to about 200kb.
    http://i879.photobucket.com/albums/ab359/jameyweare/problem5.gif
    Any help on this would be appreciated.
    Edited by: Jaime Weare on Jul 17, 2009 3:38 PM

  • Open the default email application through button click in struts

    Hi can someone help me with launching the default mail application from a jsp page through button click? I am using struts.

    Yes you can send the dynamic values to the JS,
    I have never tried <bean:write but you can use as,
    var make="<%=makeFromJava%>"Where make is a JS variable and makeFromJava is a java variable where you can sent/set some dynamic values

  • I can not access the switch through the console (solved)

    Hello,
    I'm having a problem.
    I can not access the switch through the console. The web interface is working properly.
    Model: SRW224g4
    Below some pictures.
    The HyperTerminal settings
    error:
    If anyone can help me?
    Thank you and excuse the bad English.

    Hello Rumenigue,
    It looks to me like you are using a console cable.  The reason you usually see them the other way around is because with a console cable the RJ-45 end goes into the device (an ethernet jack labeled console) whereas on this switch the console port is serial itself. 
    Usually the serial end of the cable you have plugs into a USB to serial adapter (because most computers today don't have serial ports anymore) and that USB connection goes into your PC, creating the virtual COM port you need in HyperTerminal.
    So if you get a USB to Serial adapter you could plug that from USB to the console port, or if you computer has a serial port of its own just connect a serial cable directly from the PC to the switch, then use HyperTerminal with the settings recommended above by Tom.
    Hope I have helped,
    Christopher Ebert
    Network Support Engineer - Cisco Small Business Support Center

Maybe you are looking for