JRadio Button not getting the  focus back

I am having a problem with JRadio Button. I have three buttons in a Panel and I display three different set of sub panels on selecting the corresponding radio button. The top most button is the default one. I selected the second button and saved it to the database. When I come back to the screen, I have the second button selected.But the focus(the rectangle around the text) is on the first button. When I again click on the second button then the focus is coming to the second button. I tried almost everything( requestFocus() etc.,). Can some one help me.
TIA,
CK

Hi!
Here's some code for simulating your application -- as far as I could understand what it was aimed for... ;-)
Try this code and let me know...
(it's a bit long but just paste it)
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.event.*;
public class Test extends JFrame
ButtonGroup bg;
JRadioButton jrb1;
JRadioButton jrb2;
JRadioButton jrb3;
JPanel panel;
MyItemListener mil = new MyItemListener();
public Test()
setSize(600,400);
Container cp = getContentPane();
cp.setLayout(null);
bg = new ButtonGroup();
jrb1 = new JRadioButton("button 1");
jrb1.setBounds(10, 10, 200, 20);
jrb2 = new JRadioButton("button 2");
jrb2.setBounds(10, 35, 200, 20);
jrb3 = new JRadioButton("button 3");
jrb3.setBounds(10, 60, 200, 20);
bg.add(jrb1);
bg.add(jrb2);
bg.add(jrb3);
JPanel pan = new JPanel();
pan.setLayout(null);
pan.setBounds(40, 40, 220, 90);
pan.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
pan.add(jrb1);
pan.add(jrb2);
pan.add(jrb3);
cp.add(pan);
panel = new JPanel();
panel.setLayout(null);
panel.setBounds(280, 40, 200, 90);
panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
cp.add(panel);
jrb1.addItemListener(mil);
jrb2.addItemListener(mil);
jrb3.addItemListener(mil);
public static void main(String[] args)
(new Test()).setVisible(true);
class MyItemListener implements ItemListener
public void itemStateChanged(ItemEvent e)
Object source = e.getSource();
if (source == jrb1)
jrb1_itemStateChanged(e);
else if (source == jrb2)
jrb2_itemStateChanged(e);
else if (source == jrb3)
jrb3_itemStateChanged(e);
public void jrb1_itemStateChanged(ItemEvent e)
if (jrb1.isSelected()){
Color color = Color.red;
panel.setBackground(color);
// THIS JDIALOG BOX SIMULATES FRAMES THAT MIGHT POP UP
// DURING DATABASE TRANSACTIONS...
//======================================================
JDialog jd = new JDialog();
jd.setSize(400,300);
jd.setModal(true);
jd.getContentPane().setBackground(color);
jd.setVisible(true);
public void jrb2_itemStateChanged(ItemEvent e)
if (jrb2.isSelected()){
Color color = Color.green;
panel.setBackground(color);
// THIS JDIALOG BOX SIMULATES FRAMES THAT MIGHT POP UP
// DURING DATABASE TRANSACTIONS...
//=======================================================
JDialog jd = new JDialog();
jd.setSize(400,300);
jd.setModal(true);
jd.getContentPane().setBackground(color);
jd.setVisible(true);
public void jrb3_itemStateChanged(ItemEvent e)
if (jrb3.isSelected()){
Color color = Color.yellow;
panel.setBackground(color);
// THIS JDIALOG BOX SIMULATES FRAMES THAT MIGHT POP UP
// DURING DATABASE TRANSACTIONS...
//======================================================
JDialog jd = new JDialog();
jd.setSize(400,300);
jd.setModal(true);
jd.getContentPane().setBackground(color);
jd.setVisible(true);
cbmn2

Similar Messages

  • JRadioButton not getting the Focus Back

    Hi,
    I am having a problem with the RadioButtons. I have a panel and have three radio buttons belonging to a group. I have selected the third button and saved it to the database. When I came back to the panel, I have the third button selected.But the focus( Rectangle around the text) is on the first button. If I click on the third button then the focus came to the third button. I tried using requestFocus() but its not at all working. Some one please help me asap.
    Example of Code...
    if(selButton =1)
    rb1.setSelected(true);
    else if(selButton = 2)
    rb2.setSelected(true);
    else
    rb3.setSelected(true);
    TIA,
    CK

    Did you try:
    if(selButton =1) {
      rb1.setSelected(true);
      rb1.requestFocuse();
    } else if(selButton = 2) {
      rb2.setSelected(true);
      rb2.requestFocuse();
    } else {
      rb3.setSelected(true);
      rb3.requestFocuse();
    }Doesn't work ?

  • I deleted the playlists on my iPhone and when I now try to synchronize with my iTunes account to put the music back, nothing happens and I do not get the music back on my iPhone. Anyone who knows why that could be? Grateful for any suggestions!

    I deleted the playlists on my iPhone and when I now try to synchronize with my iTunes account to put the music back, nothing happens and I do not get the music back on my iPhone. Anyone who knows why that could be? Grateful for any suggestions!

    I know it sounds weird, and that is the reason I posted my question.  Because my case is not like all the ones I've found online and it's confusing.  I added a screen capture of my itunes with my old iphone (the one that houses my playlists) connected to it.
    My playlists "ARE"  in my iphone 4s.  They are still there even though they do not show up when I plug in to itunes in my computer. 
    When connecting my phone to itunes on my macbook, the playlists do not appear anywhere in itunes.  I have found my connected iphone icon, I have clicked on the arrow next to it and it does pull up the standard lists that come with the iphone/itunes:  Music, Movies, TV shows, books.  That's it! below that is "Genius" and below "Geniuns" is "PLAYLISTS"  but the only playlist of mine that shows there is one that I created several years back titled "90's music" and that one I created it on my computer, not my phone.  Under "90's music" there are also other standard playlists that itunes automatically adds.
    Does anyone else have this issue or know how to get around this.  I am starting to think that I am going to have to recreate these lists on my computer

  • I make annotations to my photos in iphoto using preview. But once I have made the annotation I do not get the photo back in iphoto into the event from which I took the photo. What am I doing wrong?

    I make annotations to my photos in iphoto using preview. But once I have made the annotation I do not get the photo back into the event in iphoto from which I took the photo. What am I doing wrong? I am not using aperture

    For the annotations to display on the photo in iPhoto you must setup Preview as the external editor in iPhoto via iPhoto's Advanced preference pane.
    After adding the annotations just do a Save.  iPhoto will then recognize the change via a new modified version.  You can revert to the original at any time if you want to get rid of the text.
    OT

  • Why am I not getting the buttons of Hide/Show, Refresh, Back, Home, Options ?

    Gorgeous Hello All,
    If anyone of you can please provide me a solution for the following, will help me in plentious and galore.
    Am using Adobe RoboHelp, Version 10 and IE version being 10.
    A hurdle :-
    When I File -> View -> Primary Layout : I am getting only these options of Search, Hide, Contents, Index, Glossary, Print being displayed on the screen, eventhough I have ticked for Hide/Show, Refresh, Back, Home (Home -> Advanced Properties -> Home : and declared the respective url as well) , Options  courtesy View -> Pods -> Project Set-up -> Double Click on Windows -> Double Click on NewWindow.
    Why am I not getting the buttons of Hide/Show, Refresh, Back, Home, Options when I File -> View -> Primary Layout ?
    Cheese - Vipin Nambiar

    Hey Piyush Buddy, where were you since my morning !!! :-) :-) :-)   Your simple question here made me realize where did I make the slip of my brain and now all the desired buttons are appearing on my screen. 
    I just made simple parameter changes called View -> Pods -> Single Source Layouts -> Right Click On Microsoft HTML Help -> Setted as Primary Layout (earlier my Primary Layout was setted up for Multiscreen HTML 5).
    THANKS GALORE Piyush buddy - Your simple question to me made a mammoth and galores of help to get my train on track.

  • My Late 2009 Model 10,1 running 10.8.5 frequently acts as though I have pushed the F11 button, but I haven't.  The cables are not loose.  Gently touching the mouse will get the screen back, but often it immediately goes to the F11 mode.

    My Late 2009 Model 10,1 running 10.8.5 frequently acts as though I have pushed the F11 button, but I haven't.  The cables are not loose.  Gently touching the mouse will get the screen back, but often it immediately goes back to the F11 mode.  Is this a hardware or software issue?  How can it be fixed?

    I called Apple.  The problem was caused by settings in Mission Control.  After changing all 4 of the Hot Keys (if that's the proper term) shown in the bottom half of the Mission Control window in System Preferences to "-" by clicking on the drop down menus, the problem went away.  Apple's help was excellent!

  • The bookmarks toolbar is there but has no item buttons on it. How do I get the items back for this toolbar? Also would like to know if the toolbars can be put on the same line to make more room on the page (drag & drop) ??

    The bookmarks toolbar is there but has no item buttons on it. How do I get the items back for this toolbar?
    Also would like to know if the toolbar can be put on the same line to make more room on the page (drag & drop) ?? Like the menu & bookmarks toolbar could/should fit on same line. This would add more page view...
    Floyd Perry
    Thanks

    Check that you still have the "Bookmarks Toolbar items" placed on the Bookmarks Toolbar
    * Make sure that you have the "Bookmarks Toolbar" visible: "View > Toolbars"
    * Check in "View > Toolbars > Customize" that the "Bookmarks Toolbar items" is on the Bookmarks Toolbar
    * If the "Bookmarks Toolbar items" is not on the Bookmarks Toolbar then drag it back from the Customize window onto the Bookmarks Toolbar
    * If you do not see the "Bookmarks Toolbar items" then click the "Restore Default Set" button
    You can only move the content from a toolbar onto other toolbars if all toolbars support that feature. You need to check that in the options of each toolbar.

  • I hit Forget Network and now cannot get back onto my wireless home network. All of my other computers and iphones are fine.  How do I get the network back?  It shows in my list of networks but when I use the password and try to join it says not connected.

    I hit Forget Network and now cannot get back onto my wireless home network. All of my other computers and iphones are fine.  How do I get the network back?  It shows in my list of networks but when I use the password and try to join it says not connected.

    See if the iPad will accept the password after you restart it. It's worth a try.
    Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    You could also try a reset as well.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

  • My iphone 4s keeps shutting down on it's own and seems to restart itself. Pressing the home button or trying a hard reset does not turn the phone back on. Is anyone else having problems like this?

    My iPhone 4s keeps randomly shutting down. It usually does this after it's been sitting in sleep mode for a few minutes. Pressing the home button or attempting a hard reset does not turn the phone back on. It seems to turn on on it's own. It has done this since I got it and seems to be doing it more frequently. I've only had the phone for about 2 months.

    Welcome to the Apple Community.
    This isn't a Home Sharing problem, you will get better answers posting in the iPhone community.
    https://discussions.apple.com/community/iphone/iphone_hardware
    https://discussions.apple.com/community/iphone/using_iphone

  • I Have a HP Pavilion DV7 1285DX laptop I can not get the speaker cover buttons working.

    I had to disassemble the laptop and now I can not get the buttons on the speaker cover working. The power button works and the buttons for the CD but the volume mute button and the wireless button will not work

    Odds are you did not connect everything back up properly. Do you have the Service Manual? I have disassembled a dv7 and it has ribbon cables going all over the place. Very confusing.

  • When I double-click the home button on my iPhone 3g, I do not get the recent apps screen. How come and how can I fix it?

    When I double-click the home button on my iPhone 3G-8GB, I do not get the recent apps screen. How come and how can I fix it?

    Ok..Thank u for the information.. And one more question,
    Is it possible to use two itunes in a same system??(bcz i had an iphone 4 with itunes in my laptop and also wish to back up this 3G with that same system)

  • On my macbook pro the hard drive icon is not on my desktop and I don't know how to find the hard drive or get the icon back on my desktop

    on my macbook pro the hard drive icon is not on my desktop and I don't know how to find the hard drive or get the icon back on my desktop

    Click on the Desktop. From the Finder menu select Preferences. Check the boxes for what you want on your Desktop. If they are already checked, then try unchecking and rechecking.

  • How can I get the tabs back where they belong beneath the address bar , NOT on top ???

    how can I get the tabs back where they belong beneath the address bar , NOT on top ???
    they are on top, which puts the address bar at a variable position depending on how many tab rows exist - makes a moving target for navigating to across my dual 24 inch screens
    I tried your "solution" using about:config and setting browser.tab.on.top or whatever to false, but that had NO effect
    Maybe because TabMixPlus is installed?
    It does allow putting the tabs all the way at the bottom, but I don't like that either.
    PLEASE, give me the address bar at TOP with tabs under that!!!
    Also, I don't want FlashGot to be at the right of the address bar!!!

    why should we use yet another add on to get the tabs back at the bottom? Big mistake.
    Moreover, why make FF look more like Chrome? If I wanted Chrome, i would have installed it long time ago.
    FF 29.0 is NOT an improvement.
    Nasty piece of mud.

  • My computer no longer seesmy 3rd generation ipod nano.  after following the on line directions to re-install I get a message it is ok to discinnect instead of do not disconnect.  how to I get the ipod back onto my computer?

    my computer no longer seesmy 3rd generation ipod nano.  after following the on line directions to re-install I get a message it is ok to discinnect instead of do not disconnect.  how to I get the ipod back onto my computer?

    Hello rh3362,
    I would start with this:
    http://support.apple.com/kb/TS1369
    Hope this helps.
    ~Julian

  • Good morning a few weeks ago  I send the request for the replacement program of my ipod nano 1st generation and they sent me the shipping box but I did not get the label to go back,  and I can not  return it , i need to you sent me again the box for retu

    Good morning a few weeks ago  I send the request for the replacement program of my ipod nano 1st generation and they sent me the shipping box but I did not get the label to go back,  and I can not  return it , i need to you sent me again the box for return the ipod

    Best thing would be to call Apple up again, and let them what has happened and they'll help you!

Maybe you are looking for

  • Jabber on ichat does not work after update to 10.5.2

    Hi, since I updated to 10.5.2 I cannot chat on Jabber via ichat. I see my contacts online but when I try to open a conversation, I just get a blank window. When I enter text and hit return I get the following message: "Cannot chat - Add at least one

  • FI-REFX Add additional validation to monthly posting

    Dear, We would like to add extra validations to the standard posting programs RERAOP/RERAPP (and their reversal programs RERAOPRV/RERAPPRV). These are standard SAP transactions within Real Estate to make (monthly) postings on the contract. Each contr

  • ITunes will no longer import music from my hard drive.

    I click and drag the mp3 file from the folder to the iTunes library and drop it and nothing happens. I click "File" and go to "Add file to library" and find the file and nothing happens. Apple wants $30 just to talk to someone about their software ma

  • How can I fix my iTunes? (Error -45054)

    After updating to the new OS Mavericks I have experienced this error for iTunes: -45054. After I click the Ok button to acknowledge the error iTunes closes. I tried to fix this by reintsalling iTunes, but this did not work. Any ideas on how to fix?

  • EDI partner profile not found

    Hi All, We are facing a recurring issue which happens in BW QA system after we refresh is from the BW production system. After about a week or so after the refresh, the data loads halt in the BW QA system and the BW team gets an error "EDI partner pr