How to save input from radio buttons into textfiles, Help

Below is my code. Currently it gets the input from the textbox "Date" and places it into a textfile using "getText"
How do i get the input from a radio button?
i think getselected only works on JLists.
String a = bookNo.getText();
          out = new PrintWriter(new FileOutputStream("" + a +".txt"));
out.println("Date: " + tDate.getText());
out.close();
catch(IOException ex)
System.out.println("Error");
Your help is appreciated

Sorry, here's my code. The point of the system is to write information from the page, onto the textfile named "something.txt"
public void write() {
String fullfile = "something.txt";
try {
BufferedWriter out = new BufferedWriter(new FileWriter(fullfile));
out.write("");
out.write("HOLIDAY BOOKING SYSTE,");
out.write("");
out.write("SECTION 4.0 DESITNATION");
out.write("");
out.write("Holiday Destination: " + list.getSelectedValue());
out.write("Duration of holiday: ");
out.write("");
out.write("SECTION 5.0 TRAVEL RESERVATION DETAILS");
out.write("Airport for depature and return");
out.write("Depature Date: " + txtDateD.getText());
out.write("Depature Time: " + txtTimeD.getText());
out.write("Arrival Date: " + txtDateA.getText());
out.write("Arrival Time: " + txtDateA.getText());
out.write("Holiday Destination: " + txtbookingno.getText());
out.write("Customer Booking Information");
out.close();
} catch (IOException f) {
//end of file writer
The code below is for the radio buttons, The choice is to either pay for an "Economic" ticket, or a "First Class" ticket. If a customer selects the economic ticket radio button, what line of coding do i add to the write method above, to show "Economic ticket"
Also i ran into another slight problem, theres a textbox called "Fine" in another form called "page1", how do i call it's value i.e. what line of code do i place for it in the method above?

Similar Messages

  • How get information from radio button into a textfile,

    ok, Here's my code. The point of the system is to write information from the booking form, onto the textfile named "something.txt"
    write code;
    public void write() {
    String fullfile = "something.txt";
    try {
    BufferedWriter out = new BufferedWriter(new FileWriter(fullfile));
    out.write("");
    out.write("HOLIDAY BOOKING SYSTE,");
    out.write("");
    out.write("SECTION 4.0 DESITNATION");
    out.write("");
    out.write("Holiday Destination: " + list.getSelectedValue());
    out.write("Duration of holiday: ");
    out.write("");
    out.write("SECTION 5.0 TRAVEL RESERVATION DETAILS");
    out.write("Airport for depature and return");
    out.write("Depature Date: " + txtDateD.getText());
    out.write("Depature Time: " + txtTimeD.getText());
    out.write("Arrival Date: " + txtDateA.getText());
    out.write("Arrival Time: " + txtDateA.getText());
    out.write("Holiday Destination: " + txtbookingno.getText());
    out.write("Customer Booking Information");
    out.close();
    } catch (IOException f) {
    //end of file writer
    The code below is for the radio buttons, The choice is to either pay for an "Economic" ticket, or a "First Class" ticket. If a customer selects the economic ticket radio button, what line of coding do i add to the write method above, to show "Economic ticket"
    JRadioButton EconomyButton = new JRadioButton(EconomyString);
    EconomyButton.setMnemonic(KeyEvent.VK_C);
    EconomyButton.setActionCommand(EconomyString);
    constraints.gridx=0;
    constraints.gridy=27;
    constraints.insets = new Insets (0,0,0,0);
    EconomyButton.setFont(new Font("palatino linotype", Font.PLAIN,13));
    gridbag.setConstraints(EconomyButton,constraints);
    c.add(EconomyButton);
    JRadioButton FirstClassButton = new JRadioButton(FirstClassString);
    FirstClassButton.setMnemonic(KeyEvent.VK_C);
    FirstClassButton.setActionCommand(FirstClassString);
    constraints.gridx=1;
    constraints.gridy=27;
    constraints.insets = new Insets (0,0,0,0);
    FirstClassButton.setFont(new Font("palatino linotype", Font.PLAIN,13));
    gridbag.setConstraints(FirstClassButton,constraints);
    c.add(FirstClassButton);
    Also i ran into another slight problem, theres a textbox called "Fine" in another form called "page1", how do i call it's value i.e. what line of code do i place for it in the method above? Help,

    Try to use the "[ code][ code]" tags, it makes your code much easier to read! :)
    If you want a method, such as write() to be able to get text from a radio button, such as EconomyButton, make sure to declare it higher in your code and public, so you can use the method:EcononomyButton.getText()Also note, you may find it easier if you rename your variables to lower case, such as "economyButton", and your classes upper case.
    For more information on ways to get information out of a button you've created, check out the javadocs:
    http://www.google.com/search?&q=java+5+jradiobutton
    Note, if you scroll down, you'll see a bunch of "Methods Inherited By" stuff. You can use them too!
    -FBL
    (This is your code, using the code tags)
              /* Write code */
         public void write() {
              String fullfile = "something.txt";
              try {
                   BufferedWriter out = new BufferedWriter(new FileWriter(fullfile));
                   out.write("");
                   out.write("HOLIDAY BOOKING SYSTE,");
                   out.write("");
                   out.write("SECTION 4.0 DESITNATION");
                   out.write("");
                   out.write("Holiday Destination: " + list.getSelectedValue());
                   out.write("Duration of holiday: ");
                   out.write("");
                   out.write("SECTION 5.0 TRAVEL RESERVATION DETAILS");
                   out.write("Airport for depature and return");
                   out.write("Depature Date: " + txtDateD.getText());
                   out.write("Depature Time: " + txtTimeD.getText());
                   out.write("Arrival Date: " + txtDateA.getText());
                   out.write("Arrival Time: " + txtDateA.getText());
                   out.write("Holiday Destination: " + txtbookingno.getText());
                   out.write("Customer Booking Information");
                   out.close();
              catch (IOException f) {
              //end of file writer
                        /* Radio buttons */
         JRadioButton EconomyButton = new JRadioButton(EconomyString);
         EconomyButton.setMnemonic(KeyEvent.VK_C);
         EconomyButton.setActionCommand(EconomyString);
         constraints.gridx=0;
         constraints.gridy=27;
         constraints.insets = new Insets (0,0,0,0);
         EconomyButton.setFont(new Font("palatino linotype", Font.PLAIN,13));
         gridbag.setConstraints(EconomyButton,constraints);
         c.add(EconomyButton);
         JRadioButton FirstClassButton = new JRadioButton(FirstClassString);
         FirstClassButton.setMnemonic(KeyEvent.VK_C);
         FirstClassButton.setActionCommand(FirstClassString);
         constraints.gridx=1;
         constraints.gridy=27;
         constraints.insets = new Insets (0,0,0,0);
         FirstClassButton.setFont(new Font("palatino linotype", Font.PLAIN,13));
         gridbag.setConstraints(FirstClassButton,constraints);
         c.add(FirstClassButton);
         

  • Acrobat 9.1  Mac How do you change from Radio buttons to Check boxes?

    I have a DMV Form I Downloaded and had to convert to PS then back to PDF (written originally on PC Acrobat was in XML format).
    So on new form, I am able to add fields. I used the the Forms manager to automatically create the fields. Fields that were made Radio Buttons should have been Check boxes. How do change the Radio buttons to check boxes. There are a lot of them and I don't wish to have to re-key them in.
    Suggestions?

    Well when I click on the box it shows a Check mark in the box. That exactly what I need because in the instructions it requires a Check mark in each of the check boxes. Normally the Med form is sent as a paper copy from DMV every two years.
    Also another Tip. A PDF that has XML Content. (PC Acrobat Version).
    If you want a usable PDF on Mac and get rid of the XML do the following:
    Open the XML Based PDF on Mac Acrobat 9.X .
    Now choose export and save as Postscript File (.ps).
    Now locate and drop on Distiller 9.X.
    When PDF created will be a Pristine exact replica of the XML file except Mac Acrobat can edit and create forms with it.

  • How to store data from a hashtable into textfile?

    let say i have 10 data in a hashtable, how can i store these data to a textfile? thanks a lot

    try to use Properties instead of HashTable,
    it has an operation store(OutputStream out, String header)
    using which we can write content of Properties to a file
    Also load content of a file using load(InputStream inStream),
    This is pretty simple operation.
    Renjith.

  • How do I save input from a user into a html file?

    Sure could use a couple of pointers here, I am a newbie to jsp's. I am trying to create an html file with meta tag keywords and description for search indexing purposes, the idea is to have the user call a jsp page and enter the desired meta tags in a form then save this info in html format so the Spider can index it at a later time. Not sure of the most efficient way to do this. Any help/ideas would be greatly appreciated. Thanks in advance.

    Hi,
    I would like to take Meta keywords and descriptions from a form entered by the user and generate an html page with the keywords and descriptions in the proper tags. This html page must be saved on the server so our Spider can index it. The idea is to increase the results for a webpage by indexing an html page with proper meta tags defined and redirect the searcher to the desired page. I'm not sure how to create an html file to be saved on the server, not displayed in the originating browser. Thanks

  • How to save input from a text file in to array

    I got this assignment, and almost have no clue, and my teacher doesn't even teaches us anything
    This is what i am suppose to do
    5. The program must store the following data about each student in this Talent Show:
    * The student's name (store as a String)
    * The student's average time score [only for the events they competed in] (store as a Double)
    Note: Some of the data comes directly from the text file, and some of the data must be calculated from the data that is read from the file.
    6. The program must search through all of the student's scores to find the student who has the minumum average time of all students.
    7. You must calculate how many events each student played. Zero values are not counted.
    8. You must then generate a report on the screen that prints out
    * the total number of students in the competition,
    * the winning student's ...
    o name
    o times
    o average time (rounded to one decimal places)
    Sample output
    btw this is the data file
    Bart Simpson
    7.5
    12.3
    7.8
    19.2
    9.9
    5.3
    8.5
    11.8
    2.2
    4.6
    Stewie Griffin
    9.5
    29.7
    7.8
    22.5
    9.9
    12.6
    8.5
    0
    8.2
    0
    Pinky
    2.5
    0
    1.8
    0
    3.9
    0
    6.5
    0
    5.2
    12.1
    Rocky N Bullwinkle
    10.0
    22.2
    9.5
    17.5
    9.9
    1.5
    8.7
    23.7
    9.2
    11.0
    Angelica Pickles
    5.5
    11.1
    6.8
    12.2
    7.9
    13.3
    8.1
    5.1
    7.2
    7.9
    Pink Panther
    8.5
    5.5
    8.8
    6.6
    8.9
    7.7
    9.9
    8.8
    2.2
    9.9
    Josie
    9.5
    0
    8.8
    12.2
    9.9
    0
    8.5
    0
    9.2
    5.3
    Rogue
    8.5
    1.1
    7.8
    2.2
    7.9
    3.3
    7.5
    4.4
    8.2
    5.5
    Usagi Tsukino
    8.5
    15.5
    8.8
    30.1
    9.9
    19.7
    9.5
    11.0
    8.2
    8.6
    Yosemite Sam
    0
    15.2
    0
    29.5
    3.9
    0
    0
    16.0
    0
    7.7
    My code so far
    import java.io.*;
    public class test
        public static void main (String [] args)
            FileInputStream File1;
            DataInputStream In;
            String fileInput = "";
            try
               File1 = new FileInputStream ("data.txt");
                In = new DataInputStream (File1);
                while (In.available () > 0)
                    fileInput = In.readLine ();
                    System.out.println (fileInput);
                In.close ();
            catch (FileNotFoundException e)
                System.out.println ("Error - this file does not exist");
            catch (IOException e)
                System.out.println ("error=" + e.toString ());
    }My question, how do i save the data in to an array, and how do i seperatly save names in to different array, and their scores in to different arrays
    bte he said you can use scanner class
    Thanks
    Edited by: supahsain08 on Mar 26, 2008 2:55 PM

    supahsain08 wrote:
    Well, you are not in my class and you don't even know my teacher
    who are you to judge meHe is jaded by our experiences here. 99% of posters who complain that the teacher doesn't teach have adequate (note that I didn't say good) teachers, but it's the student who is failing to take responsibility for his own education. It is after all your responsibility and complaining won't help you any.
    Good luck.

  • How to get input from keyboard scanner into an array

    This is probably a very basic question but I'm very new to java..
    My task is to reverse a string of five digits which have been entered using keyboard scanner.
    E.g. - Entered number - 45896
    Output - 69854
    I used the StringBuffer(inputString).reverse() command for this, but i need a more basic method to do this.
    I thought of defining an array of 5
    int[] array = new int [5];
    and then using,
    Scanner scan = new Scanner(System.in);
    to enter the numbers. But I can't figure out how to get the five input numbers into the array.
    If I can do this I can print the array in reverse order to get my result.
    Any other simple method is also welcome.

    Hey thanks for the quick reply,
    But how can I assign the whole five digit number into the array at once without asking to enter numbers separately?
    E.g. - if entered number is 65789
    Assign digits into positions,
    anArray [0] = 6;
    anArray [1] = 5;
    anArray [2] = 7;
    anArray [3] = 8;
    anArray [4] = 9;
    I'm really sorry but I am very new to the whole subject.

  • How to save music from my Ipod into my libary?

    Hello,
    i want to save music, which i buyed at another computer, now into my libary into my notbeook. The music is already at my ipod but when i try to copy it into my libary it is not possible. And before i had an own pc i always buy music in itunes at different pc's.It is possible to collect by any way and save them now at my pc???
    My english is not so good. I hope you understan my problem and help fastly!
    Thank you

    Hi Elissa,
    either use this procedure: http://docs.info.apple.com/article.html?artnum=300173
    or use an application like SENUTI, iPodRip, iPod Access which enables you to retrieve audio-track from your iPod.

  • HELP! I need help to understand how to get value on radio buttons!

    hello,
    I realy need the help from anyone that knows how to get value from radio buttons in a JSP.
    I have this :
    <%
    java.util.Vector vLinha = (java.util.Vector) datos.get("ConsNefect");
              java.util.Hashtable ordens;
              java.util.Enumeration eLinha = vLinha.elements();
              String t = "radio";
              String x = "escolha";
              String l = "";
    int i = 0;
              //int esc = 0;
    String fila = "";                         
              boolean bol = true;
    while (eLinha.hasMoreElements())
    ordens = (com.ibm.dse.base.Hashtable) eLinha.nextElement();     
              if (++i%2 == 0)
    fila = "formgriscla";
    else
    fila = "formgrisosc";
    out.println("<tr>");
    out.println("<td class=\"" + fila + "\">");
    out.print("<p class=\"dato2\">");          
              out.print("<a href=" + urls.get("action"));
         out.print("&sequencia=" + (String) ordens.get("sequencia"));                    
         out.print(">");
              out.print((String) ordens.get("descricao"));
         out.print("</a></p></td>");
              out.println("<td class=\"" + fila + "\">");
    out.print("<p class=\"datop\">");          
              out.print((String) ordens.get("datap"));
    out.print("</p>");
    out.println("<td class=\"" + fila + "\">");
    out.print("<p class=\"datop\">");
    out.print((String) ordens.get("erro"));
              out.print("</p>");
              out.println("<td class=\"" + fila + "\">");
              out.print("<p class=\"datop\">");     
              l = (String) ordens.get("sequencia");     
              out.println("<input type=\"" + t + "\" name=\"" + x + "\" value=\"" + l + "\">");          
              out.print("</p></td>");      
              out.println("</tr>");
              //esc++;
    %>
    <!--input type="Hidden" name="escolha" value=<!--%l%>-->
    <!--input type="Hidden" name="escolha" value="<!--%=escolha%>"-->
    </td>
    </tr>
    I don�t know how to take the value... PLEASE HELP ME OUT!
    THANKS TO ALL!,
    Best wishes,
    Alex (portugal)

    You must wrap your contents into a FORM element and, then, using getParameter("escolha"), retrieve your value.

  • How do I include the radio-button items on a second column as possible answers to the question?

    Using Adobe Acrobat Pro X, we created a fillable PDF from an existing PDF.
    One question can be answered by choosing one of four choices (radio buttons). The answers are laid out in a 2-by-2 arrangement.
    When Acrobat Pro converted the PDF into fillable format, it thought that the radio-button answers on the second column are not part of the question.
    How can I manually override Acrobat and make choices 3 and 4 part of the question.
    Please click attached screenshot for better zoom.

    George,
    i am the OP. I mistyped my email address and cannot log in to my original account.
    Thanks for your reply.
    How do I give each radio button the same name but unique button values?
    I right-clicked the first radio button, chose Properties (Ctrl+I).
    I copied the name: "What is your personal net worth in Canadian dollars including spousecommon law partner if applicable".
    I clicked Close.
    I then went into the Properties dialog window of the third radio button, which is one of the ungrouped choices. I pasted the name [What is your personal net worth in Canadian dollars including spousecommon law partner if applicable]. I then clicked Close.
    I get an error message pop up:
    A field of a different type already uses this name. Please choose a new name for the field, or change the field type to match the existing field with this name.
    What must I do now?
    Thanks.

  • How to set value for radio button in sap crm survey suite

    Hi ,
    I created a survey in CRM Service, in which I added a question with answer as '10 Selection Button Group ('radio button'). And answer has 11 answer options (which means 11 radio buttions). Now when we test the survey, the value for the radio buttons is appearing like 'id_0050569b03091ee480a29d8ee61e953c'. But i want to set a specific value for each radion button (from 1 to 11). So, how to set value for radio button in sap crm survey suite???.
    Thanks & Regards,
    Seshu

    Hi,
    I found solution myself. Click on Goto -> Editing Mode -> Expert Mode. Now you can set value for radio button.
    Regards,
    Seshu

  • How can i record from radio to mp3 format?

    How can i record from radio to mp3 format?
    because i want to record a radio program, and save it, how can i do it?

    If you can, the instructions will be in the user manual - iPod Manuals

  • How to use Checkbox  and radio buttons in BI Reporting

    Hi BW Experts,
       My Client has given a report in ABAP format and the report has to be develop in BI.It contains Check boxes and the radio buttons. I don’t know how to use Checkboxes and radio buttons in Bex.For using this option, do we need to write a code in ABAP.Please help on this issue.
    Thanks,
    Ram

    Hi..
    Catalog item characteristic
    - Data element
    - Characteristic type
    Entry type
    List of catalog characteristics
    Designer
    Format (character)
    Standard characteristic
    Alternative: Master characteristic
    (used for automatic product
    assignment)
    Simple entry field
    Alternatives:
    Dropdown listbox or radio button
    list

  • How to save picture from an iPad on someone else computer

    how to save picture from an iPad on someone else computer.

    Why don't you save pictures to Dropbox?
    You don't have to save it on someone's computer
    http://i1224.photobucket.com/albums/ee374/Diavonex/b90c9d4d.jpg

  • How to save pics from facebook in nokia lumia 625

    I am using Nokia Lumia 625
    please tell me how to save pics from Facebook
    while using thanks 

    Sure it does;
    Select (TAP) the post you  like to save;
    Then TAP AND HOLD to select the save option
    Click on the blue Star Icon below if my advice has helped you or press the 'Accept As Solution' link if I solved your problem..
    Attachments:
    tap1.png ‏502 KB
    tap2.png ‏284 KB

Maybe you are looking for

  • IPod Touch 3rd generation not recognized in iTunes

    I just recently upgraded my Macbook software to version 10.6.3 because I purchased an iPod shuffle and the newest version of iTunes would not install with my old software. Now my iPod Touch 3rd generation is not being recognized by the newest version

  • Open a new window on clicking the CommandButton in JSF

    Hi, I have a page and two <h:form> in that page. The second <h:form> just has a date field and a Submit button. Selecting a date and clicking the CommandButton should open the report in a new window. If no reports found then a msg needs to be display

  • I want to change the computer that uses I tunes library decisions

    I want to change my main computer that manages my I-Tunes account, how do I set a new main computer

  • Oracle 9i and oracle 10g features

    Looking for some info/link which could help me in understanding the newer features in oracle 9i database and in 10g dbase. Will be good to know the additional features which are in 10g release but not in 9i.

  • Do we need to create seconady Index in BI 7.0

    Hi, I need some Information. I came to know that in BI 7.0. The Index are created automatically by BI Accelarator. Please let me know wheather we can create secondary Index. regards Bijevemula