Storing an array of checkbox booleans into preferences and retrieving them

Just wondering how to go about storing an array of JCheckBoxes into a preference and retrieving it. There's 32 checkboxes so if they select, say, 6 of these randomly it should store it in a preference file and retrieve it when the application is loaded so that the same 6 checkboxes remain selected. I'm currently getting a stack overflow error, though.
import java.util.prefs.*;
public class Prefs {
     Preferences p;
     GUI g = new GUI();
     public Prefs() {
          p = Preferences.userNodeForPackage(getClass());
          g = new GUI();
     public void storePrefs() {
          for (int i = 0; i < g.symptoms.length; i++) {
               p.putBoolean("symptoms", g.symptoms.isSelected());
     public void retrievePrefs() {
          for (int t = 0; t < g.symptoms.length; t++) {
               p.getBoolean("symptoms", g.symptoms[t].isSelected());
symptoms is the array of checkboxes in the GUI class. Not sure where I am going wrong here. I can do it with strings from textfields etc but this is proving to be an annoyance. :(
Thanks in advance                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Actually, I have a better example, see below
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.util.prefs.*;
public class PreferencesTest {
    private Preferences prefs;
    public static final String PREF_OPTION = "SELECTED_MENU_ITEM";
    public void createGui() {
        prefs = Preferences.userNodeForPackage(this.getClass());
        JMenuItem exitAndCloseMenuItem = new JMenuItem("Exit");
        exitAndCloseMenuItem.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
        JMenu fileMenu = new JMenu("File");
        fileMenu.add(exitAndCloseMenuItem);
        JCheckBoxMenuItem[] preferenceItems = {
            new JCheckBoxMenuItem("pref 1"),
            new JCheckBoxMenuItem("pref 2"),
            new JCheckBoxMenuItem("pref 3"),
            new JCheckBoxMenuItem("pref 4")};
        int selectedMenuItem = prefs.getInt(PREF_OPTION, 0);
        preferenceItems[selectedMenuItem].setSelected(true);
        ButtonGroup preferencesGroup = new ButtonGroup();
        JMenu preferenceMenu = new JMenu("Preferences");
        for(int i = 0;i<preferenceItems.length;i++){
            preferenceItems.setActionCommand(Integer.toString(i));
preferenceItems[i].addActionListener(new menuItemActionListener());
preferencesGroup.add(preferenceItems[i]);
preferenceMenu.add(preferenceItems[i]);
JMenuBar menuBar = new JMenuBar();
menuBar.add(fileMenu);
menuBar.add(preferenceMenu);
JFrame f = new JFrame("Prefernce Test");
f.setJMenuBar(menuBar);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
public static void main(String[] args){
new PreferencesTest().createGui();
class menuItemActionListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
JCheckBoxMenuItem jcbm = (JCheckBoxMenuItem)e.getSource();
prefs.put(PREF_OPTION, jcbm.getActionCommand());

Similar Messages

  • Hi, I changed my google id and ical crashes before i can get into preferences and change the account. I tried keychain deletions but not helping. any clues?

    Hi, I changed my google id and ical crashes before i can get into preferences and change the account. I tried keychain deletions but not helping. any clues?

    Hi, I changed my google id and ical crashes before i can get into preferences and change the account. I tried keychain deletions but not helping. any clues?

  • To store PDF into BLOB and retrieve into OLE/OCX

    We would like to:
    1. Store a PDF file (output of a report saved in file server) into a BLOB
    column.
    2. Retrieve previously stored PDF in the BLOB column and display using either
    OLE automation or ActiveX (OCX) control.
    I read all related documents in metalink that addresses this issue however cant
    get this to work. We have Acrobat Reader 4.0. Here are some issues from the
    tests that I did:
    1. To load the PDF file the program code that uses BFILE and LOADFROMFILE does
    not work since the database is on a remote server and the PDF file is on a
    local file server. The DIRECTORY created on the database is unable to find the
    PDF file.
    2. Though I want the loading of the file to be programmatic, I tried
    right-click on the OLE container and inserted object from file. This loaded the
    file into the container (Icon on the container appeared) however I was not able
    to view the document by double-clicking. An error in Adobe occured: 'There was
    an error opening this document. A file read error occured'. My guess is the
    'Insert Object' did not insert the file properly into the BLOB.
    3. When trying to display the PDF file stored in file server (in case storing
    into BLOB does not work), I used an OCX control, right-clicked and Insert
    Object and select Adobe Control for ActiveX. The problem here is when I run the
    form, the OCX control shows up empty and I have to 'Insert Object' again in
    runtime. Once I manually insert object from runtime the GET_INTERFACE POINTER &
    SET_PROPERTY works fine is displaying the document. Is there any way to
    maintain the control property of the OCX when the form is run?
    4. Are there any workarounds and better solution to store PDFs into BLOBs and
    retrieve and display in OLE/OCX controls? Using temporary file into local drive
    is not an issue.
    5. Would I be able to make use of 'PDF.PdfCtrl.1' OLE class?
    6. Does OLE automation work for Acrobat Reader 4.0.?
    I would appreciate all the help.
    Shyam

    Im facing a similar kind of problem. I want to store and retrieve Office files, PDF and Jpegs into/from the database to view them on web in disconnected mode. Please reply as I cant find any help/documentation regarding saving BLOB data into files. I was able to store file data into BLOB, using DBMS_LOB package.
    Shahzad

  • I`d like to know how can i insert documents, xls/doc/pdf into iCloud and have them in my iPhone and my iPad. I just found one way, through ibooks, but i think it isn't a practical option.

    I`d like to know how can i insert documents, xls/doc/pdf into iCloud and have them in my iPhone and my iPad. I just found one way, through ibooks, but i think it isn't a practical option.

    Just use Drop Box instead.

  • I have an old MacBook (Mac OSX 10.5.8) with iPhoto '08.  Is there any way to back up not only the photos, but the way I have organized them into events and labeled them?

    I have an old MacBook (Mac OSX 10.5.8) with iPhoto '08.  Is there any way to back up not only the photos, but the way I have organized them into events and labeled them?

    Yes. Back up the Library.
    Most Simple Back Up:
    Drag the iPhoto Library from your Pictures Folder to another Disk. This will make a copy on that disk.
    Slightly more complex: Use an app that will do incremental back ups. This is a very good way to work. The first time you run the back up the app will make a complete copy of the Library. Thereafter it will update the back up with the changes you have made. That makes subsequent back ups much faster. Many of these apps also have scheduling capabilities: So set it up and it will do the back up automatically.
    Example of such apps: Chronosync - but there are many others. Search on MacUpdate or the App Store

  • I got an ipod from my friend because it was disabled. is there anyway i can un-disable it on a different computer? or can i send it into apple and have them un-disable it?

    i got an ipod touch from my friend because ti was disabled. is there anyway i can un-disable it on a computer it wasnt synced with? or can i send it into apple and have them do it for me?

    Try here:
    iPhone, iPad, iPod touch: Device not recognized in iTunes for Mac OS X
    or
    iPhone, iPad, or iPod touch: Device not recognized in iTunes for Windows

  • HT1550 I'm having trouble with importing them into iTunes and converting them at the same time. when i hold down option over the files i can't find where its supposed to say create new version. is this if you're in iTunes?

    I'm having trouble with importing them into iTunes and converting them at the same time. when i hold down option over the files i can't find where its supposed to say create new version. is this if you're in iTunes?

    You can't do it in one step. Add to iTunes first, Once the tracks are in iTunes you may convert to a different format.
    tt2

  • How to organize apps into folders and make them stick in iphone 3gs?

    Four hours down the drain! Darn, I decided to finally learn how to organize my apps into folders and do it right. Instead I spent four hours and must have got it wrong.
    I opened iTunes on my MacBook with my iPhone attached. Then clicked on the iPhone in the left side list of my iTunes. Then clicked on apps which brought up a nice page with all my iPhone apps listed in one window on the left and all the pages of the apps that are on my iPhone in the window on the right. So far this is what I think the User Manual and Help said to do.
    At that point I created new folders by dragging one app over another. For example, I would find a photography app and drag it onto another photography app. That automatically created a folder with the name photography. Just what I wanted. I then looked for more photography apps and dragged them to the folder.
    This is not too easy because I had eight pages of apps. At first, I would grab an app on a page and drag it to where I knew the corresponding folder would be and put it into the folder.
    Later I found another way was to use the list of my apps on the right to put them in apps.
    In the end, from what appeared on the screen, it seemed to me that most of my apps were in folders and the folders were either on page one, two, or three. At that point I thought that I should sync the MacBook with the iPhone, I believe, and did so.
    When the sync was finished I took the iPhone off the computer and looked at it. NONE of the folders I created, nor the organization into folders of the apps were on my iPhone!
    Obviously, I did something wrong since the same mess was on the iPhone as before, with apps all over the place and impossible to locate without taking too much time. This after four hours of work looking at a 13 in. laptop screen!
    What I hope is that someone smarter than me will look at what I did and tell me where I went wrong.
    I want the apps on the iPhone to be organized into logical folders so it is easier to find them. Something along the lines of a good database, you know?
    Thank you for reading to the end of this question,

    OK, I spent another afternoon doing the job started yesterday. Last night (could not sleep, so might as well think) I got to thinking that I really must have missed a step or something because all my work was done on the Mac and I did not recall any time when I transferred the new setup with folders to the iPhone.
    Sure enough, when I tried it today I did find that missing step. When looking at the Home Page of the iPhone or any page being worked on, in the lower right hand corner two buttons say
    SYNC APPLY
    I do not recall using the APPLY button on the first day trying this, but I used it this time.
    After making changes, I hit APPLY and the computer began to sync with the iPhone.
    This time, although there is nothing telling the user what is going on, the sync actually makes the iPhone pages to look exactly like the pages created on the Mac.
    Too bad the instructions and help did not say to do things in this way, which is the only correct way, as far as I can tell.
    I have about 155 apps on the iPhone, making the job extra lengthy. However, I never could do it on the iPhone’s tiny screen, even though it is possible, so this was good - working on the larger screen of the MacBook.
    There are also some (undocumented?) tricks in using the MacBook for this task. For example, it is possible to create a folder and then, using the list of all apps on the iPhone that is on the left side of screen, open the folder, click on the check box next to any app you want to put in the folder and it will jump right in!
    If the check box already has a check mark, just click the box to remove it, click again to put the check mark in the box and voila the app takes off for the folder. This also works to just put apps onto a certain page, if you want to do that, but dragging apps around sometimes works better.
    I hope it will not be necessary to do this again because of the time involved, and he need for quite a bit of thinking on how to move the apps and folders around to get everything just where you want it on the iPhone. The work reminded me of an old kids game that has a small square case with, I guess eleven movable numbers, that are all mixed up, and one space that is not filled with a number. You can move the little squares with the numbers around inside the case to try to line the numbers up in order from 1-11 and do it faster than anybody else.
    Well, unfortunately lining up all my apps was like that because each page of the iPhone only holds 16 folders or apps and each folder is limited to 12 apps. Starting with 155 apps it takes too much mouse maneuvering to make the process easy.
    Finally, the automatic folder names are very broad, as in MUSIC, LIFESTYLE, SPORTS and such, so I often just deleted the given categories and put my in my own. Also, some day I may break down the folders more because twelve apps in one folder means the apps are still pretty much out of view.
    I wrote this in case anyone else finds it and has the same irksome product. If I just reinvented the wheel, please do not tell me now.

  • With Netscape all of the Webcam shots from live feeds were automatically saved in my cache folder and I could simply open my cache send the saved files into AcDsee and convert them into jpgs, It would save as many as I would allow space for. With firefox

    I cant retrieve my images from webcams that are cached any more with mozilla. With netscape all of the live webcam images from live cams were automatically saved in my cache folder and all i had to do was open it send the files to acdsee and turn them into jpgs. It would save them untill the Cache ran out of room no matter how many files or sites I had running. Mozilla seems to save what it wants when it wants and often dose not save any that I can retrieve because I believe it is bulking them into Cache 123 or 4 and those i cant open to retrieve the files. Sometimes it saves 100 or so and sometimes 2 or 3 sometimes 10 or more but i don't seem to have any control over what it does or does not save to retrieve no matter how much space i allow for the cache to save.
    == This happened ==
    Every time Firefox opened
    == I finally gave up trying to keep netscape due to all the ridiculess popups and continued reminders from you saying i had to switch over

    You have or had an extension installed (Ant.com Toolbar) that has changed the user agent from Firefox/3.6.3 to Firefox/3.0.12.
    You can see the Firefox version at the top and the user agent at bottom of the "Help > About" window (Mac: Firefox > About Mozilla Firefox).
    You can check the '''general.useragent''' prefs on the '''about:config''' page.
    You can open the ''about:config'' page via the location bar, just like you open a website.
    Filter: '''general.useragent'''
    If ''general.useragent'' prefs are bold (user set) then you can right-click that pref and choose ''Reset''.
    See [[Web sites or add-ons incorrectly report incompatible browser]] and [[Finding your Firefox version]]
    See also http://kb.mozillazine.org/Resetting_your_useragent_string_to_its_compiled-in_default

  • Autofill stopped working after installing latest OS Mountail Lion update Can anyone help? I've gone into preferences and

    Autofill has stopped working after installing latest update to OS X Mountail Lion (10.8). Latest of many problems with this OS - wish I had never upgraded to it. Can anyone help?

    Hi Eric, it is Safari but I thunk I've solved it by dragging the autofill into the safari toolbar and clicking on it when I want to use the fearture. Nothing else worked. this OS is a crock as far as I am concerned.

  • Firefox opens with 2 tabs and neither of which are my nome page I go into preferences and my homepage is set right.

    when I start a new session of firefox it opens with two tabs open one is http://www.mysearchdial.com/?chnl=prtk and the other is jus a new tab but it has choices in it for facebook ebay amazom twitter and others. but if you go to tools then options under general it say show my homepage and it has google in as my homepage for startup

    Hi there,
    To get rid of the MySearchDial annoyware:
    # Close all browsers.
    # Go to the Start menu.
    # Select Control Panel → Uninstall a program (or Add/Remove Programs in Windows XP/Vista/7).
    # Choose Mysearchdial and click the Uninstall/Change button.
    # Wait for Mysearchdial to uninstall.
    # Click the Firefox menu (top-left corner).
    # Select Options.
    # Under Home Page click the Restore to Default button→ click OK.
    # Go back to the Firefox menu.
    # In the menu select Add-ons→ choose the Extensions tab →click Remove on the right of any extensions mentioning "Mysearchdial".
    # Move the mouse cursor inside the search box at the top right of the Firefox window and click the down arrow next to the provider's logo.
    # From the dropdown list, select ''Manage Search Engines...''.
    # Select "Mysearchdial".
    # Click "Delete" or "Remove".
    Hope this helps!
    Curtis

  • Is there a way to combine layers into precomp AND trim them

    Hi.  I have a bunch of image sequences that I bring in from a 3D program.  Each sequence may have a separate set of images for Shadow, Specular color, Ambient Color, Glow etc - so clip A could have several layers, each with identical length.  The same would hold for each other clip.
    Ideally, I would like to put all the Shadow, specular, ambient, and glow images of clip A into a precomp, and the same for clips B,C, D, and so on.
    When I do this, however, the precomp suddenly occupies the whole timeline, and if I manually trim comp back to correct size, the precomp goes to beginning of the timeline and I have to mannually reposition it.  This can quickly get tedious.
    Is there a way to automate this process?  Or something to use other than precomps that would essentially group the layers/lock them together so all the A clips function as one unit, and all the B clips as another?
    Andrew Kramer (at Video Copilot.net) has a script to automatically trim compositions, but I can't figure out if there's a way to use it in this instance where I need to combine multiple layers first.
    Thanks for any suggestions.

    I'm not where I can look but there is a script that takes the in and out point of a bunch of layers in your Pre-comp, trims the pre-comp, then trims the pre-comp and keeps it in the right place.
    I usually don't take the time to do this. Instead I set timeline markers for the in and out points of the pre-comp, then, if the comp starts getting really confusing, I'll just set an in and out point for the pre-comp rather than change the length of the pre-comp. This makes my ELAT (edit this look at that) workflow easier if I have to dive into the pre-comp to make changes.
    Let me make another observation. From your description it sounds like you are trying to make too long a movie in AE. AE shines at making shots, and occasionally, making sequences. Even Pixar renders out shots and then moves those shots into a NLE to turn them into a sequence, then a scene, then a movie. When I do the kind of compositing you're doing I treat each rendered 3D shot with all of the render passes as a single composition. I render the result, and then edit the sequence in a NLE. Only on rare occasions will I do the editing of the sequence using a bunch of pre-comps as layers in AE.
    Hope this helps.

  • Is there a way to take my address's I typed into Pages and get them into my address book?

    I have over 200 address's typed into pages.  Is there a way to get them into my address book with out copying a pasting each one individually??

    Per  http://support.apple.com/kb/PH4648
    Address Book can import contact information that you save or export from other applications in vCard, LDAP Interchange Format (LDIF), tab-delimited, and comma-separated value (CSV) formats.
    You can export addresses in vCard format from Entourage, Outlook, and others, and in LDIF format from Thunderbird, for example. You can export text files in tab-delimited or CSV format from spreadsheet applications, such as Numbers.

  • How can I import dvds that have already into iMovie and edit them?

    I just purchased an iMac and after Apple moved all of my movies into iMac from my PC, I am trying to edit the movies in iMovie that are in the iMac. Can't seem to figure this out. Is it possible to create a new movie from an .avi file? Also, why is it when I click on a frame in an iMovie it keeps going back to the first frame??? Whew , very frustrating!

    Is it possible to create a new movie from an .avi file?
    You'll have to convert the AVI to a format iMovie can accept. You might try the freeware MPEG StreamClip and see if it can handle your AVI, though AVI is just a container format and can use any number of codecs, some of  which have never been ported to Mac.
    Regards.

  • I have transferred all my music from iTunes onto my USB to play on my car audio radio. The radio reads the music but does not play it in sequence. There is a specific way to save the music into folders and name them. I have a Pioneer DEH-2350UBSW.

    I have transferred all my music from iTunes onto my USB to play on my car radio. The radio reads the music but does not play it in sequence. So it plays certain folders, then it skips folders. in certain folders it skips tracks. apparently there is a specific way to save the music into folders onto the USB with regard to naming the tracks and folders.. I have a Pioneer DEH-2350UBSW. Can anyone please help.

    It is a stick, Cruzer Blade 16gig.
    In the manual it says the following about the USB storage device:
    1. Playable folder hierarchy is up to 8 tiers
    2. Playable folders up to 500
    3. Playable files up to 15 000
    Under sequence of audio files it says that the user cannot assign folder numbers and specify playback sequences with this unit. It also gives an example of a hierarchy:
    01 - folder
    Under that is 02 which is also a folder
    Under that are compressed audio files 01 to 05: folder number
    Under that there is another folder same concept as above - I have attached that part of the manual in this response.
    I named my folder - Folder 001 Artists name and then in that folder I added the tracks as:
    001 Song title
    002 song title
    It played the 1st song in the folder and skipped to the next folder, I can't even locate the other tracks.
    On another folder I saved 31 songs but only 29 played so I am not sure whether there is a limit.
    All I need is an example of how to number and name everything.

Maybe you are looking for

  • User-Defined Message Search

    Hi experts, I've configured the User-Defined Message Search on my PI 7.11. Do u need to configure Jobs that will delete the entries that the extractor collects ? what is the impact on the DB ?

  • Which Compression has the most bang for the buck?

    When I'm 'exporting' a quicktime that I need to post for download, I try to get the size of the file down as much as I can while preserving the video quality. However, there are so many compression choices, and then more choices with that! Which is b

  • "failed to open document" help

    I have been working on a flash file for school using CS5.5.  Everything was working, and I even downloaded a trial of CS5.5 on my computer to work on the project, but now I am in class and it will not open.  It keeps saying "failed to open document."

  • Sort in template

    I need to perform a sort in my template. <?sort: ELEMENT_NAME?> works, but what if I want to sort descending instead? I have also tried <xsl: sort order="ascending" select"ELEMENT_NAME"/> but this does not sort at all. Any ideas? /Björn

  • How to find CI_ID

    I need to understand how to find the CI_ID of for example endpoint protection definition updates, how would I go about this? http://windows-support.co.uk