How to fix this design?

I have a main GUI with a bunch of menuItems, each has it's own listener.
4 of these menuItems do the same exact thing except for the last line whichs launches a different window for each one.
I would like to get rid of the repetive methods and have one generic class that maybe just returns the 2 files needed to launch the windows.
My problems is this:
I add the same listener to each of the 4 menuItems:
loadWindow( ActionEvent e );
in loadWindow I call the class that brings up the file selector class
       // brings up 2 file choosers first one then the other
       SelectFiles sf = new SelectFiles();
       fileOne = sf.fileOne;
       fileTwo = sf.fileTwo;
        System.out.println( fileOne );// keeps coming back null
        if( fileOne != null ){
            if( e.getSource() == menuItemOne )
                 new WindowOne();// 
          }Any ideas how do this correctly

Here's the SelectFiles class.
No "fileOne" is not static.
Thanks for taking a look at it
package SetupPackage;
import javax.swing.*;
import java.io.*;
import javax.swing.JOptionPane;
import java.awt.event.ActionEvent;
* Class for getting the 2 files needed to run the apps
* @version
public class SelectFiles extends Object {
  private JFileChooser fileChooser;
  public File xmlFile;
  public File dataFile;
  public String xmlName;
  /** Creates new SelectFiles */
  public SelectFiles(File xmlFile) {
     fileChooser = new JFileChooser();
     if( xmlFile == null ){
      // Load xml file
         fileChooser.setSelectedFile(null);
         fileChooser.setCurrentDirectory(new File("."));
         fileChooser.setDialogTitle("Select a Survey");
         int result = fileChooser.showDialog(null, "Load");
         if( result == fileChooser.APPROVE_OPTION){
             xmlFile = fileChooser.getSelectedFile();
            // reset the file chooser for the data file  
             fileChooser.setSelectedFile(null);
             fileChooser.setCurrentDirectory(new File("."));
             fileChooser.setDialogTitle("Select a Response File");
             result = fileChooser.showDialog(null, "Load");
              if( result == fileChooser.APPROVE_OPTION){
                  dataFile = fileChooser.getSelectedFile();
                  //update(this.getGraphics());
                  //new parseData(XMLFile);
                  // this was different in each method
                  // ie (window 1 window 2 window 3)
                  //loadQuestionScreen();
              else return;
         else return;      
  }// if
// user have previously loaded an xml file
// ask if they want to use currently loaded file or a new one 
else{
       int yes = JOptionPane.showConfirmDialog(null,
                 "Use the currently loaded survey?", "",
                 JOptionPane.YES_NO_OPTION);
// user selected yes     
       if( yes == JOptionPane.YES_OPTION ){
             this.xmlFile = xmlFile;
// user selected no show file choosers again             
       else{    
             fileChooser.setSelectedFile(null);
             fileChooser.setCurrentDirectory(new File("."));
             fileChooser.setDialogTitle("Select a Survey");
             int result = fileChooser.showDialog(null, "Load");
             if( result == fileChooser.APPROVE_OPTION){
                 xmlFile = fileChooser.getSelectedFile();
                 fileChooser.setSelectedFile(null);
                 fileChooser.setCurrentDirectory(new File("."));
                 fileChooser.setDialogTitle("Select a Response File");
                 result = fileChooser.showDialog(null, "Load");
                  if( result == fileChooser.APPROVE_OPTION){
                     dataFile = fileChooser.getSelectedFile();
                  //update(this.getGraphics());
                  //new parseData(XMLFile);
                  // this was different in each method
                  // ie (window 1 window 2 window 3)
                  //loadQuestionScreen();
              else return;
         else return;
}

Similar Messages

  • How to fix this Designer Workflow error?

    Hi All,
    I am facing below error while trying to publish designer 2010 worflow:
    (0, 0) Activity 'ID18' validation failed: An IfElseActivity must have at least one child of type IfElseBranchActivity.)
    How to fix this issue?
    Thanks in advance!

    Hi Sam,
    This error is due to the if - else branches. Hope you might be using in your workflow.
    Designer workflow doesn't accept multiple Else If conditions. Modify the workflow to have 'If - Else If' and then try to publish. In other words 'If' condition should have only one 'Else If' condition.
    Note: 
    after modifying the workflow, save and close the designer. Clear the cache at the following folders and then open designer and publish the workflow.
    C:\Users\loggedin-id\AppData\Roaming\Microsoft\SharePoint Designer\ProxyAssemblyCache  OR  
     %AppData%\AppData\Roaming\Microsoft\SharePoint Designer\ProxyAssemblyCache<o:p></o:p>
    C:\Users\loggedin-id\AppData\Local\Microsoft\WebsiteCache   OR
        %AppData%\
    AppData\Local\Microsoft\WebsiteCache
    C:\Users\loggedin-id\ Roaming\Microsoft\Web Server Extensions\Cache   OR    %AppData%\Roaming\Microsoft\Web
    Server Extensions\Cache
    Thanks
    Senthu
    please mark as 'Answer' if it resolves your query or 'Vote' if this post is helpful

  • My new iphone 4 does not have any sound when recording a video with the camera app.  Does anyone know how to fix this?

    I just got a new white iphone 4.  When I try to take a video using the camera app, there is only a muffled sound.  I never had this problem with my old iphone.  I tried to restore it and that didn't help.  I checked over all of the settings.  Does anyone know how to fix this??  Thanks for any help you can offer!

    There is a good possibility that your trimming of the SIM card could have damaged it some way. If the SIM was working in the old phone, then you cut it and the first new phone didn't work and now this phone doesn't work, it leads me to believe it has to do with the SIM card or the account. You are sure there is no problem with the account. Did you check with the provider when you got the iPhone 4 to make sure there was no problem with the account when you could not send or receive SMS? Why can't you just get a micro-sim? The iPhone should have come with one when you purchased it.The iPhone 4 is designed for a micro-sim. I don't believe this is a hardware problem unless the phone has been hacked or modified in some manner.

  • Strange System Font in Dreamweaver.  After I installed Dreamweaver CS4 on my Mac, it loaded this strange font as seen in the photo attached.  Anyone know how to fix this?  I have uninstalled/reinstalled many times.  No prob w/ other CS4 programs.

    Strange System Font in Dreamweaver.  After I installed Dreamweaver CS4 on my Mac, it loaded this strange font as seen in the photo attached.  Anyone know how to fix this?  I have uninstalled/reinstalled many times to no avail.  There are no other problems with w/ other CS4 programs, they all have the normal system font.  I can't figure it out.  Thanks!

    Funny fonts issue in PI etc.,
    http://kb2.adobe.com/cps/405/kb405153.html
    Fonts in Dreamweaver panels display incorrectly
    http://kb2.adobe.com/cps/138/tn_13862.html
    Nadia
    Adobe Community Expert : Dreamweaver
    Unique CSS Templates | Tutorials | SEO Articles
    http://www.DreamweaverResources.com
    Web Design & Development
    http://www.perrelink.com.au
    http://twitter.com/nadiap

  • Recently loaded Lion on my laptop and now my computer crashes often. Black screen and keyboard lights up. Any ideas on what's wrong and how to fix this?

    Recently loaded Lion on my laptop and now my computer crashes often. Black screen and keyboard lights up. Any ideas on what's wrong and how to fix this?

    Everytime this happens Ihave to power down and restart! Any ideas would be appreciated!

  • After moving to iCloud I can only get my email through the cloud, no new emails are making it to my home computer. Does anyone have any advice on how to fix this issue?

    After moving to iCloud I can only get my email through the cloud, no new emails are making it to my home computer and .mac account. Does anyone have any advice on how to fix this issue?

    Welcome to the Apple Community.
    Which OS are you using.

  • My iPhone 4 no longer connects to my car or alarm clock after a recent sync to my computer.  The message at I get when trying to. Connect is "this accessory is not optimized for the device" or something like that.  Anyone know how to fix this?

    My iPhone 4 no longer connects to my car or alarm clock after a recent sync to my computer.  The message at I get when trying to. Connect is "this accessory is not optimized for the device" or something like that.  Anyone know how to fix this?

    Hello there philp_69,
    If I understand correctly it sounds like your phone hasnt been recognized in iTunes on your PC since the last couple of updates. I would use the troubleshooting in the following article which will walk you through the steps one by one. 
    iPhone, iPad, or iPod touch not recognized in iTunes for Windows
    Thank you for using Apple Support Communities.
    All the very best,
    Sterling

  • My new iPhone 4S can't connect to iTunes, App Store or iBooks via Wi-Fi. Works with 3G network. How to fix this?

    My new iPhone 4S (week old) can't connect to iTunes, App Store or iBooks via Wi-Fi (and some other apps e.g. Hollister – but most of the other apps like Safari or ebay work fine). There is no problem with those apps loading via 3G network. When I turn off the wi-fi, it runs over 3G and i can access App store without any problem. When i turn off the 3G network and turn the Wi-Fi on, those apps like App Store won't work, other apps work fine. When i turn on both Wi-Fi and 3G, the App store (and so on) is also not working, other apps are.
    I also found out that when the Wi-fi is on and I sign out my apple ID, the App store starts working! But when I log in again, it will imediatelly stop working. I've tried logging in with others apple IDs, still with the same result. There is no problem with my apple ID account, because it works on my iPad, even via Wi-Fi.
    When i first set up my iPhone, there were no complications using App store ia Wi-fi with exactly the same account. I don't know if it has anything to do with it, but this problem started when i logged in with my UK account and then wanted to log back in with my Czech account.
    I tried turning it off, hard reset and deleting my iPhone several time (even without back up). Nothing worked since then.
    Does anyone have any idea how to fix this?
    I would really appreciate ANY help. This porblem is driving me crazy!

    I am also having the same issue. Please help!

  • My Iphone 5 won't show up in itunes on my computer? Any idea on how to fix this problem?

    My Iphone 5 won't show up in itunes when i plug it into my windows 8 laptop but it shows up on my computer under devices and drivers as an iphone. Any idea on how to fix this problem so I can use my phone in itunes?

    http://support.apple.com/kb/ts1538

  • Page numbers displayed incorrectly in TOC in new Pages - does anybody know how to fix this?

    I'm working on a multi-section document with a single TOC for two sections. Section one uses lowercase roman numerals (i, ii,...) and section two arabic numerals (1, 2, ...). The page numbers are displayed correctly on the pages themselves, but in the TOC the first two headings from section two (pages 1 und 3) are displayed as "i" and "iii". This only started after the update to pages 5, everything was fine before that. Does anybody know how to fix this? I already tried deleting the TOC and inserting a new one and changing the numbers to uppercase letters and back, to no avail.
    thanks for any input

    Go back to Pages '09 inside the iWork Folder inside Applications.
    There are so many problems with Pages 5 it is difficult to know where to begin.
    Peter

  • Internal speakers are not working,  they're not showing up at all. Does anyone know how to fix this?

    My computer's speakers are not putting out sound. They worked fine yesterday, and I just now started up my computer and began using it today. The internal speakers don't show up on my list of output devices in settings, and I can't adjust the volume. Any help is really appreciated!!!

    They are all in the same folder and it says all images are there, but it is only showing 1 card's images at a time. Does anyone know how to fix this?
    This is kind of confusing, on the one hand you say "it says all images are there" and then you directly contradict this by saying "it is only showing 1 card's images at a time".
    Could you explain in a lot more detail what you see (and don't say "it", say exactly what part of Lightroom or what part of your operating system you are looking at), or show us a screen capture?

  • Hi. I get the following message when trying to update or install an application: "impossible to connect to iTunes store". Does anyone know how to fix this? Thanks!

    Hi. I get the following message when trying to update or install an application: "impossible to connect to iTunes store". Does anyone know how to fix this? Thanks!

    Try updating your iTunes using an iTunesSetup.exe (or iTunes64Setup.exe) installer file downloaded from the Apple website:
    http://www.apple.com/itunes/download/

  • Messages on my MacBook Air won't send messages over iMessage. Anyone know how to fix this?

    In preferences, under accounts, it claims that my Apple iD is hooked up to messages, including my phone number and email address...yet it isn't sending messages they always fail. Does anyone know how to fix this problem? It would be a great help.

    Read this whole message before doing anything.
    Back up all data.
    Quit Messages if it’s running.
    Step 1
    Hold down the option key and select
    Go ▹ Library
    from the Finder menu bar. Move the following items from the Library folder to the Trash (either may not exist):
    Caches/com.apple.Messages
    Caches/com.apple.imfoundation.IMRemoteURLConnectionAgent
    Leave the Library folder open. Log out and log back in. Try Messages again. If it works now, stop here. Close the Library folder.
    Step 2
    If you still have problems, quit Messages again. Go back to the Finder and move the following item from the open Library folder to the Desktop:
    Messages
    Note: you are not moving the Messages application. You’re moving a folder named “Messages.”
    Test. If Messages now works, delete the Messages folder on the Desktop. Otherwise, quit Messages again. Put back the folder you moved, overwriting the newer one that may have been created in its place, and continue.
    Step 3
    In the Preferences subfolder, there may be several files having names that begin with "com.apple.iChat". Move them all to the Desktop. There may also be a file with the name "com.apple.imagent.plist". Move that to the Trash.
    Also in the Preferences folder, there's a subfolder named "ByHost". Open it and do the same thing.
    Log out and log back in. Test again. This time Messages should perform normally, but your settings will be lost. You may be able to put back some of the files you moved to the Desktop in this step. Relaunch and test after each one. Eventually you should find one or more that causes Messages to malfunction. Delete those files and recreate whatever settings they contained.
    If the issue is still not resolved, quit Messages again and put all the items you moved to the Desktop back where they were. You don’t need to replace the items you moved to the Trash. Stop here and post again.
    If you later decide that you don’t like the results of steps 2 and 3, you can undo them completely by quitting Messages and restoring the items you deleted in those steps from your backup.

  • My storage is mostly full of a category labeled "other." I'm out of memory to the extent that it won't even allow me to update apps. I have moved all photos over to my computer and my music streams through the cloud. Any advice on how to fix this problem?

    My storage is mostly full of a category labeled "other." I'm out of memory to the extent that it won't even allow me to update apps. I have moved all photos over to my computer and my music streams through the cloud. Any advice on how to fix this problem?

    http://discussions.apple.com/thread/3418045?tstart=60

  • My windows(8.1 64bit) partition is read only from the mac(yosemite) side of things. Anybody have a clue on how to fix this? Also, slightly frustrating as well, windows crashes every time I attempt to open a file from the mac partition.

    my windows(8.1 64bit) partition is read only from the mac(yosemite) side of things. Anybody have a clue on how to fix this? Also, slightly frustrating as well, windows crashes every time I attempt to open a file from the mac partition.

    All Office applications will also try to open a temporary work file in the same location as the source file. This implies the source file directory also needs to be writable for this temporary file. Since the default HFS+ driver provides only read-only access, such temporary files will fail to open, and will cause the application to fail.
    As a test copy the file you want to edit, say an Excel spreadsheet from the OSX file system to the C: drive on the Windows side and try to open it. If you look in this directory, you should see two files, the source and a temporary file. You may have to force the temporary file to be opened on a read-write file system, by manipulating the folder for temporary files.

Maybe you are looking for

  • I am a victim of " Your apple ID has been disabled" (not for security reasons, only disabled), is there any way to solve this?

    Is there any possible way to achieve my goal? I really want to solve this, looking forward for your assistance. Note: This is only "Your Apple ID has been Disabled", it did not mention security reasons and other words / things. Random Facts: 1- I had

  • G5 Crashes Upon Startup

    Hey y'all. I'm having problems with my dual 1.8 G5. It keeps crashing over and over and over again. Here's the long version: I was playing Civ4, and my computer had been running as normal that day. For the record, I was running it off of a second har

  • Agent as Trading partner

    Hi experts, The client is using a non-SAP application for SD and SAP ECC6.0 for FI. Agent is captured as Trading partner and linked in Customer Master. Wants to get the agent  getting displayed in the standard SAP AR reports (without customization) l

  • Prepayment line item functionality

    Hi Experts, I am working with the prepayment process in the Claims Management. I would like to understand how the items in the prepayment work. As i was doing some tests I noticed that you create items with the prepaid amount and each item gets assig

  • Third octave analysis of a blast signal

    Hi, I am trying to analyze one blast signal in third octave band. I am taking a narrow band power spectra of the signal and it is giving me the correct values, but when I am trying to do third octave band power spectra it is not giving me the correct