Navigating Through Groups of Radio Buttons

Hi,
I am having a problem navigating through groups of radio buttons.
I have several groups of radio buttons, I tab to the first radio button and then press the down arrow to move to the next radio button in the list.
When I press the down arrow the focus does not go to the next radio button in the list. The radio buttons appear to be selected in a random order.
I have made sure that the buttons are listed in the same order in the hierarchy. I have also arranged the buttons so they appear in alphabetic order. This doesn't seem to make any difference.
Any ideas???
Thanks in advance,
Emma

I was trying to use the script in this example to solve a similar problem I'm having with a radio button group that started acting strange when I added a script to it. However, the checkboxes are not acting like radio buttons. Meaning I can click multiple values and I only want 1 of the 4 options clicked. So, when I check the 2nd box I want the 1st to go away and it doesn't.
Here is my code, I've got 4 checkboxes (used to be radio buttons) and a text field at the end that appears if the last option is checked. Can someone tell me what I've done wrong?
1st checkbox:
if (this.rawValue == "Yes") {
this.access = "protected";
form1.subform3.TruthDataDIS.access = "open";
form1.subform3.TruthDataDIS.rawValue = "No";
form1.subform3.TruthDataTENA.access = "open";
form1.subform3.TruthDataTENA.rawValue = "No";
form1.subform3.TruthDataOther.access = "open";
form1.subform3.TruthDataOther.rawValue = "No";
2nd checkbox:
if (this.rawValue == "Yes") {
this.access = "protected";
form1.subform3.TruthDataHLA.access = "open";
form1.subform3.TruthDataHLA.rawValue = "No";
form1.subform3.TruthDataTENA.access = "open";
form1.subform3.TruthDataTENA.rawValue = "No";
form1.subform3.TruthDataOther.access = "open";
form1.subform3.TruthDataOther.rawValue = "No";
3rd checkbox:
if (this.rawValue == "Yes") {
this.access = "protected";
form1.subform3.TruthDataDIS.access = "open";
form1.subform3.TruthDataDIS.rawValue = "No";
form1.subform3.TruthDataHLA.access = "open";
form1.subform3.TruthDataHLA.rawValue = "No";
form1.subform3.TruthDataOther.access = "open";
form1.subform3.TruthDataOther.rawValue = "No";
4th checkbox:
if (this.rawValue == "Yes") {
form1.subform3.TruthDataOtherName.presence = "visible";
form1.subform3.StaticText36.presence = "visible";
this.access = "protected";
form1.subform3.TruthDataHLA.access = "open";
form1.subform3.TruthDataHLA.rawValue = "No";
form1.subform3.TruthDataDIS.access = "open";
form1.subform3.TruthDataDIS.rawValue = "No";
form1.subform3.TruthDataTENA.access = "open";
form1.subform3.TruthDataTENA.rawValue = "No";
else {
form1.subform3.TruthDataOtherName.presence = "invisible";
form1.subform3.StaticText36.presence = "invisible";
Thanks in advance for your assistance,
Debra

Similar Messages

  • I need to reset, clear or deselect a group of radio buttons

    I haven't been able to find the answer to this: I have a quiz-like animation that uses a group of radio buttons, I need the group to reset, clear or deselect the previous selection after submitting the answer on each question, is that possible?
    Here is the code:
    stop();
    var messageBox:TextField = new TextField();
    messageBox.text = "";
    addChild(messageBox);
    messageBox.textColor = 0xFF0000;
    messageBox.width = 200;
    messageBox.height =100;
    messageBox.x = 450;
    messageBox.y = 340;
    var userAnswer:int;
    var rbg:Object = rbA.group;
    var finalScore:int;
    btnCheck.addEventListener(MouseEvent.CLICK, nextBtn);
    function nextBtn(evt:MouseEvent):void {
    userAnswer = int(rbg.selectedData);
                if(userAnswer == 0) {messageBox.text = "PLEASE SELECT AN OPTION";
    }else{
    finalScore = finalScore + userAnswer;
    messageBox.text = "";
    nextFrame();
    btnFinish.addEventListener(MouseEvent.CLICK, finishBtn);
    function finishBtn (evt:MouseEvent):void {
    userAnswer = int(rbg.selectedData);
    if(userAnswer == 0) {messageBox.text = "PLEASE SELECT AN OPTION";
    }else{
    finalScore = finalScore + userAnswer;
    if (finalScore > 13){ gotoAndStop(8);
    }else if (finalScore > 9){ gotoAndStop(7);
    }else if (finalScore > 4){ gotoAndStop(6);
    }else {}
    startOver.addEventListener(MouseEvent.CLICK, reStart);
    function reStart(evt:MouseEvent):void {
    gotoAndStop(1);
    finalScore = 0;

    I'm all ears on this one because I checked into this the first time I saw this posting back whenever and couldn't find the solution.  And now I built something that tries to make it happen, and it doesn't.  In the AS3 help docs it doesn't say gets or sets, whereas in the AS2 docs it goes on about doing such things with that property... so maybe they changed the compnent for AS3?
    Here's what I concocted building off a help docs example.  rb3 and rb4 are basically there just to reset rb1 and rb2:
    import fl.controls.RadioButton;
    import fl.controls.RadioButtonGroup;
    var rbg1:RadioButtonGroup = new RadioButtonGroup("group1");
    var rbg2:RadioButtonGroup = new RadioButtonGroup("group2");
    var rb1:RadioButton = new RadioButton();
    var rb2:RadioButton = new RadioButton();
    var rb3:RadioButton = new RadioButton();
    var rb4:RadioButton = new RadioButton();
    rb1.group = rbg1;
    rb2.group = rbg1;
    rb3.group = rbg2;
    rb4.group = rbg2;
    rb1.move(10,10);
    rb2.move(10,50);
    rb3.move(150,10);
    rb4.move(150,50);
    addChild(rb1);
    addChild(rb2);
    addChild(rb3);
    addChild(rb4);
    function resetGroup1(evt:MouseEvent){
    rbg1.selection.selected = false;
    rb1.selected = false;
    rb2.selected = false;
    rb3.addEventListener(MouseEvent.CLICK, resetGroup1);
    rb4.addEventListener(MouseEvent.CLICK, resetGroup1);
    I rarely use radio buttons components.  If I need them, I usually create my own using movieclips.  If you go this route then you'll be able to decide what they can do, you just need to create the functions for controlling their behavior as a group..

  • Exclusion groups of radio buttons get merged

    When copying and pasting multiple exclusion groups of radio buttons from page to page, the different exclusion groups get merged into one.

    This bug is really having a negative affect on my development time. Due to this bug, it is taking me about 20 minutes to place each radio button group, and I have to do about 300 of these.
    I thought that creating a radio group as a custom library item and using that instead of copying/pasting would solve the merging issue, but it happens there, too. Anytime a radio group is pasted or inserted from the library, it is merged with an existing group, and is placed in some unpredictable location on the page.
    Anyone have a work-around?

  • Custom group of radio buttons

    Hi, I would like to accomplish the following: I have a group of radio buttons of which I would like the 'selector button' in the first column of a table and the label in the second column. To do this I am currently writing a new renderer class but somehow I can't manage to retrieve the options of the group. Does anyone know how I can resolve this problem?
    The UIComponent in the renderer has one child of the type UISelectItems, but from there I don't know how to proceed. Can anyone help me out (and am I on the right track anyway)?
    Below is my current code of the encodeBegin(FacesContext context, UIComponent component) method:
    Iterator items = component.getChildren().iterator();
    while (items.hasNext()) {
         Object child = items.next();
         if (child instanceof UISelectItems) {
              // How to proceed now?
    Any help is very much appreciated!

    I did try Setting process first screen to false. But here its not executing on itself. When user clicks on the execute button. It does not check for the Mandatory value and runs the transaction.
    Also, What I obeserved is even though it appears that RB2 is selected but system is executing with value RB1.
    Edited by: raj1234 on Apr 21, 2010 8:09 PM

  • Using a radio button to populate another group of radio buttons?

    I am new to Adobe forms and new to Javascript. I have a question on my form with a radio button group (PHQ) with four choices 1, 2, 3 or 4. If the user chooses "1", I want a check to appear in the "No" box for another radio button group (Screen). If, on the other hand, the user chooses 2, 3, or 4, from the PHQ group, I want a check to appear in the "Yes" box of the Screen group. Is this possible? Not sure how to go about doing this.

    I suspect that you have a problem in some portion of your code that you have not posted. To help debugging I suggest you create a simple test using two pages: input.cfm and action.cfm.  Get the most simple case working then add the javascript, css, and CF code to make your application work.
    <!--- contents of input.cfm --->
    <html>
    <head>
         <title>Input</title>
    </head>
    <body>
         <form action="action.cfm" method="POST">
              Choose type: <br />
              <input name="type" type="radio" value="male" />     Male<br />
              <input name="type" type="radio" value="female" /> Female<br />
              <input type="submit" />
         </form>
    </body>
    </html>
    <!--- content of action.cfm --->
    <html>
    <head>
         <title>Action</title>
    </head>
    <body>
         <cfif form.type eq "male">
              Type is male.
         <cfelseif form.type eq "female">
              Type is female.
         </cfif>
         Here is a cfdump of the form variables:<br />
         <cfdump var="#form#" />
    </body>
    </html>
    Message was edited by: JR "Bob" Dobbs
    Added sample for action.cfm

  • How do i get a text field to autopopulate based on responses in two groups of radio buttons

    I am using Adobe Acrobat Pro and am very new to this.
    What I want to achieve:
    I have two sets of radio buttons; one group is "Likelihood" choices and the other group are "Consequence" choices. Based on what the user picks in those two groups, I want the form to auto-populate the risk rating in another field. E.g If the user picks "Insignificant" in the consequence group and "Rare" in the likelihood group; the field titled Risk Rating should display the word "Low". If they pick "Insignificant" and "Almost Certain" the Risk Rating field should display "Moderate". Please let me know if you need further information. Thanks in advance.

    You can use something like this code as the custom calculation script of the risk rating field:
    var consequence = this.getField("Consequence").valueAsString;
    var likelihood = this.getField("Likelihood").valueAsString;
    if (consequence=="Insignificant" && likelihood=="Rare") event.value = "Low";
    else if (consequence=="Insignificant" && likelihood=="Almost Certain") event.value = "Moderate";
    // etc.
    else event.value = "";
    Edit: Fixed small mistake in code.

  • Grouping Of radio Buttons in table Control

    Hi All,
              I have one problem in my table control.I am using some radio buttons in the table control.I want that in one row only one button is selected.I have grouped them.But iam not getting mutual exclusivity row wise.Infact I am getting it column wise i.e i am not able to select more than one button in one column but i can select multiple buttons in one row.
    Please suggest.
    Thanks In Advance,
    Saket

    Hi ,
           The above mentioned is the way of creating a radio button in a table control . Can u elaborate on the issue i.e input field disabled.

  • How do I make a group of radio buttons available depending on a checkbox being checked or not?

    Hello Adobe Community,
    I have a form wherein I'm trying to make a group of 3 radio buttons become available for interaction when a nearby checkbox is checked, and unavailable when the checkbox is unchecked.
    Is this possible?
    Thanks.

    See the following tutorial:
    Disabling (graying-out) Form Fields by Thom Parker

  • Grouping radio buttons in JEditorPane

    I can't seem to make grouping of radio buttons work for an html page that's loaded into a JEditorPane. The content type is set properly to text/html. Is there a little trick that I'm missing??
    Once I select a button that's not part of a previous group, it unselects that previous group anyway!!

    Hello There,
    I too am stuck up with the same problem. My HTML document contains two radio buttons which belong to the same group. But when displayed on a Jeditorpane the radio buttons does'nt behave as a part of a group. Both the radio buttons get selected. If you have come across a solution..please help me..
    Thanx
    Mohamed Zafer

  • Radio Buttons - returning individual values from an exclusion group possible?

    Using LC Designer 7.1
    Does anyone know if it is possible to return individual values from an exclusion group of radio buttons?  My xml data file gives one value for the entire group, e.g.,
    2
    ...where the second radio button was selected.  But I'd prefer an output something like this...
      0
      1
      0
    etc...
    Is something in this format possible?

    You might be better off to use checkboxes and script them to act like radio buttons (as an exclusion group). That way they'd each have an on/off value.
    Regards,
    Dave

  • Grouping Radio Buttons on a Dialog Box

    Hi,
    Sorry to post this, I could not get any doc that could help.
    I have three groups of  radio buttons in a dialog box and, I set the Group property of each of the first radio button in a group to true. But it does not seem to work. Did I miss something?
    Thanks for your help.

    Found the solution:
    I Used 'ADMRadioGroupSuite1' Suite - RadioGroupSuite ("ADM Radio Group Suite") to group them. 

  • Multiple sets of radio buttons no longer working

    Hello All:
    My first post so I apologize in advance if I don't do it
    properly.
    I have a few web forms that have multiple groups of radio
    buttons on them that are suddenly errorring out since we moved to
    CF 7. I started tinkering with the one form that I have posted the
    code for and kept cutting it down to the simplest code that begins
    to produce the error. If I just use 1 radio button group everything
    works fine, but the minute I add the second one, the whole thing
    throws a "Syntax error (missing operator) in query expression"
    message. Each radio button group has it's own group name and a
    checked value. It is very simple code and very frustrating why it
    has suddenly stopped working so any assistance is welcome.
    Here's the form code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    <body background="white" marginheight="0"
    marginwidth="0">
    <cfform action="testSub.cfm" method="POST">
    <table width="95%" border="0" cellpadding="0">
    <tr>
    <td width="24%"><img src="survey.jpg"
    border="0"></td>
    <td width="76%"><p>It is our desire to assure
    that MID is meeting the needs of
    our clients. xxxxxxx
    <p> </p>
    <p>*****************************************************<br>
    </p></td>
    </tr>
    <tr>
    <td colspan="2"><p>Please answer questions 1
    through 4 with a 1 - 5 rating, with 1 being POOR and 5 being
    EXCELLENT.</p>
    <p> You are not obligated to provide this
    information.</p>
    <p><font face="Arial, Helvetica, sans-serif"
    size="2">My Name (First &amp;
    Last):</font> <font face="Arial, Helvetica,
    sans-serif" size="2">
    <cfinput type="Text" name="poc" required="no" size="50"
    maxlength="50">
    <br>
    <b>1. Was
    your service technician polite and
    courteous?</b><br>
    <cfinput type="radio" name="polite" value="1">
    1
    <cfinput type="radio" name="polite" value="2">
    2
    <cfinput type="radio" name="polite" value="3" checked>
    3
    <cfinput type="radio" name="polite" value="4">
    4
    <cfinput type="radio" name="polite" value="5">
    5     </p>
    <p><br>
    <br>
    2. Was
    your service technician polite and
    courteous?</b><br>
    <cfinput type="radio" name="know" value="1">
    1
    <cfinput type="radio" name="know" value="2">
    2
    <cfinput type="radio" name="know" value="3" checked>
    3
    <cfinput type="radio" name="know" value="4">
    4
    <cfinput type="radio" name="know" value="5">
    5     </p>
    <input type="submit" name="btnSubmit" value="Submit My
    Comments!">
    <input type="reset" name="reset" value="Reset
    Form"><br>
    <br>
    </cfform>
    <tr>
    <td> </td>
    <td> </td>
    </tr>
    </table>
    </body>
    </html>
    The ACTION code
    <html>
    <head>
    <title>test</title>
    </head>
    <body>
    <CFIF IsDefined("FORM.btnSubmit")>
    <CFQUERY NAME="Add" datasource="newMID">
    INSERT INTO survey(
    poc,
    polite,
    know
    VALUES (
    '#poc#',
    '#polite#'
    '#know#',
    </CFQUERY>
    </CFIF>
    <cfoutput>
    Thank you. Your IT survey has been forwarded to our NHCPR IT
    mailbox.
    </cfoutput>
    <cfmail to="[email protected]"
    FROM="[email protected]"
    SUBJECT="IT Survey Form">
    Polite: #polite#
    Know: #know#
    POC (opt.): #poc#
    </cfmail>
    </body>
    </html>

    OK. I took out the extra comma. Put a space in after *survey*
    and put "form" in front of the variables in order to scope them. I
    got it to work just then and decided to add the next radio button
    and once again, the error message keeps coming up.
    Here's what it looks like now.
    ACTION
    code***********************************************************
    <html>
    <head>
    <title>test</title>
    </head>
    <body>
    <CFIF IsDefined("FORM.btnSubmit")>
    <CFQUERY NAME="Add" datasource="newMID">
    INSERT INTO survey (
    poc,
    polite,
    know,
    time
    VALUES (
    '#form.poc#',
    '#form.polite#',
    '#form.know#',
    '#form.time#'
    </CFQUERY>
    </CFIF>
    <cfoutput>
    Thank you. Your IT survey has been forwarded to our NHCPR IT
    mailbox.
    </cfoutput>
    <cfmail to="[email protected]"
    FROM="[email protected]"
    SUBJECT="IT Survey Form">
    Polite: #polite#
    Know: #know#
    POC (opt.): #poc#
    Timely: #time#
    </cfmail>
    </body>
    </html>
    The ERROR msg
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC
    Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in
    INSERT INTO statement.
    The error occurred in
    C:\Inetpub\wwwroot\PaxNew\chiefOscar\testSub.cfm: line 20
    18 : '#form.polite#',
    19 : '#form.know#',
    20 : '#form.time#'
    21 : )
    22 :
    SQL INSERT INTO survey ( poc, polite, know, time ) VALUES (
    'kennedi', '3', '5', '3' )
    DATASOURCE newMID
    VENDORERRORCODE -3502
    SQLSTATE 42000
    Resources:
    Check the ColdFusion documentation to verify that you are
    using the correct syntax.
    Search the Knowledge Base to find a solution to your problem.
    Browser Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
    SV1; InfoPath.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
    Remote Address 10.249.6.81
    Referrer
    http://205.115.107.22/chiefoscar/tsurvey.cfm
    Date/Time 29-Jan-08 02:05 PM
    Stack Trace (click to expand)

  • How do I make each Radio button appear in the tab order?

    When users tab through the form, the tab only highlights the first radio button of a group before moving to the next field or group of fields.
    Example: the user is asked for the following information:  LastName, Gender (M/F radio buttons), and BirthDate.
    When tabbing through the form, users are taken from from the LastName field to the Male radio button, to the Birthdate Field. Never does the tab allow them to select Female unless they click it with the mouse.
    It seems like this should be a simple fix, but I can't find it anywhere!
    Thanks for your help.

    That's the way they work. Think of a radio button group as a dropdown or list box. When any of these types of fields receives the focus, you can use the arrow keys to move through the options and the tab key moves to the next field.
    If you set up the group using check boxes instead, giving each in the group the same name but different export value, they will behave as you want. A group of checkboxes will behave a bit different than a group of radio buttons, but it's close.

  • Radio buttons that pass a value to a textfield

    Hi everybody;
    I’m trying to create a “Rating Matrix” for the evaluation of new raw material. On this form I create a group of radio buttons (i.e. Radio1 to Radio5).
    Each radio represents a rating value “Poor=1, Fair=3, Average=5, Good=7, Excellent=9” and I would like to capture this rating (1 or 3 or 5, etc) into a Texfield.
    I work in solving this issue without success, if any of you have any example that I could look at it, I will really appreciate.
    Thanks in advance.

    Thanks for your fast response! WowWhat I'm trying to do, is being able to pass a value to a TextField depending on the ratio button selected.If I choose one of the ratio buttons of the group "Opacity" (Opacity1, Opacity2, Opacity3, Opacity4 or Opacity5), I like the TextField "Rank" to show the value.If Opacity1 selected, Rank field value = 1.If Opacity2 selected, Rank field value = 3.If Opacity3 selected, Rank field value = 5.If Opacity4 selected, Rank field value = 7.If Opacity5 selected, Rank field value = 9.
    You think this can work?
    if(Opacity1.value == "On") {Rank.value==1; // value is added to the texfield;}
    if(Opacity2.value == "On") {Rank.value==3; // value is added to the texfield;} Else if(Opacity3.value == "On") {Rank.value==5; // value is added to the texfield;}
    Sorry not a programmer.I understand the loop, but is not very clear where I need to add this script, on the radio or in the textfield?Thanks.
    Date: Thu, 18 Jul 2013 11:48:28 -0700
    From: [email protected]
    To: [email protected]
    Subject: Radio buttons that pass a value to a textfield
        Re: Radio buttons that pass a value to a textfield
        created by GKaiseril in JavaScript - View the full discussion
    Do you want to count the occurrence of each value and report that in a given text field?
    Do you understand that when no radio button or check box when not selected has a value of the string "Off".
    Assuming that the value for various radio buttons in a group is the value you want to test
    // custom calculation script;
    // count occurrences of "9" values
    var nTest = 9; // value to test for;
    var nCount = 0; // count of occurrences;
    // loop through the fields;
    for(i = 1; i < 6; i++) {
    var nValue = this.getField("Radio" + i).value;
    // test if field value equals test value;
    if(nTest == nValue) {
    nCount++; // values equal so increment count;
    } // end test of field value
    } // end field name loop;
    event.value = nCount; // set field value;
    // end custom calculation script;
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5518047#5518047
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5518047#5518047
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5518047#5518047. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in JavaScript by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Why does is not show the radio buttons

    I want to display the buttons in a row then radio button in a row under the button and then log scroll pane under the radio buttons. This is my code:
            //Add the buttons and the log to this panel.
            add(buttonPanel, BorderLayout.PAGE_START);
            add(radioPanel, BorderLayout.CENTER);
            add(logScrollPane, BorderLayout.CENTER);When i run it it display the buttons and the logsrollpane. Why does it not display the radio buttons?

    Thanks guys.
    This is my problem. We have a big system that produce lots of log files and the software testers have to manually have to go through the logs file and look for a certain XML tags in the log file.
    What I want to do is help the software testers my developing a small tool that will allow them to open a log file and then click on a radio button corresponding to a xml tags that they are looking for and automatically highlight the tags in the file in yellow color .
    I am not sure how feasible this is and I am stuck.
    This is what I have done so far.
    Can you please guys help me go forward.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    public class FileChooserDemo extends JPanel
                                 implements ActionListener {
        static private final String newline = "\n";
        JButton openButton;
        JButton clearButton;
        JTextArea log;
        JFileChooser fc;
        // Radio Buttons
        static String em01 = "EM01";
        static String em07 = "EM07";
        /*static String dogString = "Dog";
        static String rabbitString = "Rabbit";
        static String pigString = "Pig";*/
        public FileChooserDemo() {
            super(new BorderLayout());
            //Create the radio buttons.
            JRadioButton em01Button = new JRadioButton(em01);
            em01Button.setMnemonic(KeyEvent.VK_B);
            em01Button.setActionCommand(em01);
            em01Button.setSelected(true);
            JRadioButton em07Button = new JRadioButton(em07);
            em07Button.setMnemonic(KeyEvent.VK_C);
            em07Button.setActionCommand(em07);
            //Group the radio buttons.
            ButtonGroup group = new ButtonGroup();
            group.add(em01Button);
            group.add(em07Button);
            //Register a listener for the radio buttons.
            em01Button.addActionListener(this);
            em07Button.addActionListener(this);
            //Put the radio buttons in a column in a panel.
            JPanel radioPanel = new JPanel(new GridLayout(0, 1));
            radioPanel.add(em01Button);
            radioPanel.add(em07Button);       
            //Create the log first, because the action listeners
            //need to refer to it.
            log = new JTextArea(40,60);
            log.setMargin(new Insets(5,5,5,5));
            log.setEditable(false);
            JScrollPane logScrollPane = new JScrollPane(log);
            //Create a file chooser
            fc = new JFileChooser();
            //Uncomment one of the following lines to try a different
            //file selection mode.  The first allows just directories
            //to be selected (and, at least in the Java look and feel,
            //shown).  The second allows both files and directories
            //to be selected.  If you leave these lines commented out,
            //then the default mode (FILES_ONLY) will be used.
            //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            //fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            //Create the open button.  We use the image from the JLF
            //Graphics Repository (but we extracted it from the jar).
            openButton = new JButton("Open File");
            openButton.addActionListener(this);
            //Create the save button.  We use the image from the JLF
            //Graphics Repository (but we extracted it from the jar).
            clearButton = new JButton("Clear Text Area");
            clearButton.addActionListener(this);
            //For layout purposes, put the buttons in a separate panel
            JPanel buttonPanel = new JPanel(); //use FlowLayout
            buttonPanel.add(openButton);
            buttonPanel.add(clearButton);
            //Add the buttons and the log to this panel.
            add(buttonPanel, BorderLayout.PAGE_START);
            add(radioPanel, BorderLayout.LINE_START);
            add(logScrollPane, BorderLayout.CENTER);
        public void actionPerformed(ActionEvent e) {
            //Handle open button action.
            if (e.getSource() == openButton) {
                int returnVal = fc.showOpenDialog(FileChooserDemo.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                     log.setText("");
                    File file = fc.getSelectedFile();
                    try{
                         BufferedReader in = new BufferedReader(new FileReader(file));
                             String data;
                             while ((data = in.readLine()) != null) {
                                  log.append(data + newline);
                    }catch(IOException ioe){
                log.setCaretPosition(log.getDocument().getLength());
            //Handle save button action.
            }else if (e.getSource() == clearButton) {
                  log.setText("");
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("PROGRESS Message Viewer");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            JComponent newContentPane = new FileChooserDemo();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }

Maybe you are looking for