Filechooser - how to force selection

Hi,
I have an application that needs to load data from two files. I could simply programmatically put the whole file path in the code and the problem is solved. However, it can happen that the user moves those files to a different directory and the system would not find them. So I am using a filechooser.
In reality, I don't want the user to choose anything (!)..just browse through his directories until he finds the relevant files. I want to make sure that the user only has the option to open file "file1.doc" and "file2.doc", with no possibility for his to do anything else.
I have looked at filefilter to put a ".doc" extenstion. Still the user can select "all files". So, that's not good enough. Besides, I haven't managed to pre-select the whole file name. Can someone help me with that?
Is there a way to 'lock' file name in the preselection, or at least, if the user is really stubborn and opens something else, then the filechooser does not accept that choise and re-present the openfile window
thanks

I was feeling bored and this is something that may one day be useful to me ;-) also something I'd implemented in VFP years ago for a similar reason -- to locate the database file on the network (no dedicated server).   File getNamedFile (final String name, final String description) {
      FileFilter filter = new FileFilter () {
         public boolean accept (File f) {
            return (f.isDirectory ()
                  || f.getName ().toLowerCase ().equals (name.toLowerCase ()));
         public String getDescription () {
            return description;
      JFileChooser chooser = new JFileChooser ();
      chooser.addChoosableFileFilter (filter);
      chooser.setAcceptAllFileFilterUsed (false);
      int confirmed = JOptionPane.NO_OPTION;
      do {
         int chosen = chooser.showOpenDialog (null);
         if (chosen == JFileChooser.APPROVE_OPTION
               && chooser.getSelectedFile () != null
               && chooser.getSelectedFile ().getName ().toLowerCase ().equals (name.toLowerCase ())) {
            return chooser.getSelectedFile ();
         confirmed = JOptionPane.showConfirmDialog (null, "The file " + name + " could not be found.\nWould you like to try again?", "Confirm", JOptionPane.YES_NO_OPTION);
      } while (confirmed == JOptionPane.YES_OPTION);
      return null;
   }db

Similar Messages

  • How to force selection screen in WAD Report

    Hi Gurus,
    How do we force a variable selection screen in WAD Report. We are in SP 10.
    Thanks
    Syed

    Hi Karthik,
    Iam not sure for some reason, when I select web_template and click on Web Parameters, there nothing available below Behaviour section. However when I create a new Analysis Item and see its properties, the Behaviour section shows only Allow Navigation & Only Hierarchy options.
    Should I reinstall my front end. We are in SP10.
    Appreciate your response.

  • Spreadsheet : How to force select record to row 1

    I have a spreadsheet output that will display 1 to many rows depending on the query parameter.  I want the selected row to default back to row 1 after re-running the query that populates the spreadsheet.
    Currently, when I select spreadsheet row#2, this triggers another query that pulls additional data according to the selected row.  The problem is this:  when i run the initial query that re-populates the spreadsheet and there is no record or row #2, Xcelsius throws a parameter error message because the 'refreshed' spreadsheet still has the focus set on 'row 2' from the previous step.
    What is the best way to get passed this where each time i run the query that populates the spreadsheet and that it focuses on row 1 always.
    I've tried setting the properties to 'select row 1' doesnt solve the issue.

    Just a thought:
    The select row 1 option will work only when the object is loaded to the memory. So to solve your problem, find out a way to hide the object when you fire the query using dynamic visibility and then unhide when the query returns the result. This way you may be able to make use of select row 1 option.

  • How to compile the hint to force selection statement to use index

    Hello expert,
    will you please tell me how to compile the hint to force selection statement to use index?
    Many Thanks,

    Not sure what you mean by compile, but hint is enclosed in /*+ hint */. Index hint is INDEX(table_name,index_name). For example:
    SQL> explain plan for
      2  select * from emp
      3  /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 3956160932
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |    14 |   546 |     3   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| EMP  |    14 |   546 |     3   (0)| 00:00:01 |
    8 rows selected.
    SQL> explain plan for
      2  select /*+ index(emp,pk_emp) */ *
      3  from emp
      4  /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 4170700152
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |        |    14 |   546 |     2   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |    14 |   546 |     2   (0)| 00:00:01 |
    |   2 |   INDEX FULL SCAN           | PK_EMP |    14 |       |     1   (0)| 00:00:01 |
    9 rows selected.
    SQL> Hint in the above example is forcing optimizer to use index which resul;ts in a bad execution plan. Most of the time optimizer does not need hints and chooses an optimal plan. In most cases sub-optimal plan is result of stale or incomplete statistics.
    SY.

  • How to force the "Bluetooth Communicat​ions Port" to be one of COM1 to COM8 ports?

    Dear Lenovo Community, Happy Holidays to you all and wish you a great happy new year. Recently purchased a Bluetooth OBDII device and have difficulty making it to work with its provided software on my T61 (running original XP Home). My short story and question/problem is that I can open "My Bluetooth Places" and pair with the OBDII device as an "OBDII SPP Dev", but my T61 assigns serial port COM19 to it. The OBDII software which came with the device only can let user set to one of the COM1 to COM8 ports and in the properties of Bluetooth pairing, there is no way that I can select which COM port to use. I looked at the Device Manager and I do see these COM port assignments: COM4,5,6,7: Sierra Wireless (the HSDA modem in the laptop which I have never used BTW) COM 9,10,11,12,13,14,15,16,17: Bluetooth Serial Port COM 18, 19: Bluetooth Communications Port and I don't see anything for COM1,2,3, and 8 My question is how to force the computer/OS to assign one of the COM1 to COM8 ports to my device upon pairing? Can I disable the Sierra Wireless model from the COM ports list and hope this will happen? Thanks for your help and inputs beforehand. Regards, AL

    Hi, AL_K
    Have you attempted to change the port number in device manager itself? If you navigate to Device Manager and open the list of Ports, you can right-click on the device you wish to assign a different port number. After right-clicking, click Properties. There should be a tab called Port Settings. In here, you should find a setting to manually assign a port number.
    Good luck, and let me know how it goes,
    Adam
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution!" This will help the rest of the community with similar issues identify the verified solution and benefit from it.

  • How to force english language for VC BI Iview

    Hi,
    All developments in BI system are english so when users launch VC BI Iview from the portal what ever the logon language in the portal we would like that users get results in english.
    In the VC iview, for parameter Forced Request Language we select value English but it doesn't work.
    We don't find other iview parameter which allows to do that.
    With BEX WEB template iview, we can do that by setting LANGUAGE=EN for parameter Application Parameters in the
    iview.
    Do you know how to force English language for VCBI Iview ?
    Thanks in advance for your help.
    Mai

    Hello,
    If you use Delta Links between your portal objects (role, workset, page, iview), make sure that the Forced Request Language is set to "English" on the linked iView (which is only accessible from the page, from the workset, from the role...)
    Regards
    Arnaud

  • How to force OSX to connect to a specific Access Point i.e. manually choosing beetween different APs with the same SSID?

    My office room is near different APs with the same SSID, my Snow Leopard selects automatically to join the AP with stronger signal.
    But this AP isn't running well, so I want to force my mac to join a AP with weaker signal.
    (I've the same troubel as described in https://discussions.apple.com/message/6470508#6470508)
    Note that I'm a guest user and I hanen't access to APs, so I cannot change their SSID.
    Any idea how to force Mac to join a specific AP?
    Thanks,
    adso

    My office room is near different APs with the same SSID, my Snow Leopard selects automatically to join the AP with stronger signal.
    But this AP isn't running well, so I want to force my mac to join a AP with weaker signal.
    (I've the same troubel as described in https://discussions.apple.com/message/6470508#6470508)
    Note that I'm a guest user and I hanen't access to APs, so I cannot change their SSID.
    Any idea how to force Mac to join a specific AP?
    Thanks,
    adso

  • How to force mpeg 4 video to always loop.

    Hello,
    I've created some animated loops for for use as podcasts for video iPods. As required these files are in H.264 format and store as ".m4v" files.
    Can someone please tell me how to save these files in a way that they are forces them to loop when played, not simply play once and stop.
    This is critical for the iPod experience to be ideal. Thanks.
    -Doug

    QuickTimeKirk,
    My goal is to create a looping animation for playback on an iPod. Should be easy right? Not with the QT!
    I did the following:
    1) Render a bunch of frames destined for looping.
    2) Convert them to an uncompresses ".avi" file.
    3) Open the ".avi" file in QT Pro.
    4) Click "Loop"
    5) Play movie. It loops nicely.
    6) Click "Export" and select "Movie to QuickTime Movie"
    7) Click "Save"
    When I play the saved ".mov" file (You said QT retains the metadate requiring looping) IT DOES NOT LOOP!
    To recap: This is a Quicktime movie. I selected looping when I created the bloody thing.
    It
    does
    not
    loop.
    This *****.
    This is REALLY, REALLY, ANNOYING! *** is going on with this QT Pro crap? I simply want to loop the movie. Is that really asking too much? I don't think so.
    Can someone, anyone, please, please, tell me how to force the movie to loop on launch. Forcing an iPod user to muck about and select looping (can they even do that?) is not an option. Period.
    Please help me,
    Doug

  • How to print selected cells in numbers

    Does anyone know how to print selected cells in a Numbers spreadsheet, rather than printing the entire sheet?
    Also, how to save the selected cells as a pdf file without saving the irrelevant cells?

    Hi nmygs,
    How about this?
    Cell A1 is a Pop-Up Menu containing names of the various "Departments"
    Other cells contain formulas to find a match for whatever is chosen in A1 from the Very Big Data Table.
    Reusable Print Me table.
    Regards,
    Ian.

  • How do I select a thick paper to print from Indesign?

    How do I select a thick paper to print from Indesign? I have to go to the printer to select the thicker paper. I would like to select the paper from my computer in Indesign.  Other programs allow this.

    At the bottom of the print dialog box is a button labeled Printer. That will lead you to the printer-specific options like paper weight.

  • How to force refresh of data through browser or PDF?

    We have the dashboard set to refresh every minute.  We are pulling the data using XML from DB.  When we are in browser and clear the browser cache and then reload the .swf... the data is updated.  We haven't been able to figure out how to force the cache-clear and data refresh with either swf or pdf.
    Your help is greatly appreciated.

    Hi Jeff,
    Is the XML coming from a web page or a web server?
    If yes then you can give this a go. To stop the caching mark your web page with extra tags to say it has expired.
    HTML page example:
    <HEAD>
        < META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE" />
        < META HTTP-EQUIV="EXPIRES" CONTENT="0" />
    </HEAD>
    JSP example:
    <%
      // Stop Internet Explorer from caching the results of this page.
      // We do this so that every time Xcelsius calls this page it see the latest results.
      response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
      response.setHeader("Pragma","no-cache"); //HTTP 1.0
      response.setDateHeader ("Expires", 0); //prevents caching at the proxy server 
    %>
    Regards,
    Matt

  • Using 12.0.1.26 Im trying to move photo's from an app on the pad to laptop but the select all in Edit is not hilighted, how to you select all?

    the select all under edit is not highlighted in 12.0.1.26, I need to move a large number of photos from pad app sharing area to laptop, how do I select all? Thanks

    the select all under edit is not highlighted in 12.0.1.26, I need to move a large number of photos from pad app sharing area to laptop, how do I select all? Thanks

  • Forms: How do we select two diffrent lov for two seperate conditons

    DECLARE
         a_value_chosen BOOLEAN;
    BEGIN
         if :reports.report in('OQ29','OQ25','OQ22') then
                   a_value_chosen := Show_Lov('lov_agen');
                   if :reports.office_id is not null then
                   a_value_chosen := Show_Lov('lov_agent');
              if a_value_chosen then
         :reports.office_name := null;
         :reports.county_id := null;
         :reports.county_name := null;
         :reports.region_id := null;
         :reports.region_name := null;
                   end if;
                   END if;
                   if :reports.category = 'PERFORMANCE' AND
                   :reports.SUPERVISOR_ID IS NOT NULL AND
                   :reports.SUPERVISOR_ID>0 then
              a_value_chosen := Show_Lov('LOV_YPR_AGENT');
              END IF;
    if a_value_chosen then
         :reports.office_name := null;
         :reports.county_id := null;
         :reports.county_name := null;
         :reports.region_id := null;
         :reports.region_name := null;
         end if;
         END IF;
    This is the actual code what i want is that when the reports.report is in (OQ29, OQ25, OQ22) it should select the lov_agen an if the reports.office_id is null then it should select lov_agent but some how it is selecting both the lov_agen first if you don't select anything for that condition then it is going to the next lov to satisfy the next condition. Can anyone able to help me out.
    Thanks
    Message was edited by:
    user506476

    The problem is that it is picking the lov specified but it is not picking the lov in the order of the condition. Say if condition one says to pick lov_agen and if second condition says to pick LOV_AGENT it should pick in that order. But what it is doing is that if i select for condition two it is picking both the lov's in the order of the lov's specified.
    Thanks
    Suresh

  • How do you select a single image with the keyboard?

    I can use the "/" key to deselecting the current photo but how do I select the current photo with the keyboard? Usually the space bar is used for this but that displays the image. Is the only way to select the current photo by using the mouse?

    OK, now that the question has been clarified....
    Pressing and holding the Shift key as you move through the grid with the arrow keys will individually multi-select them, but that breaks down if you want non-contiguous selections, i.e. lifting off the shift key to skip a photo will cause all previous selections to be lost when you use the arrow key to advance. I think the only way for non-contiguous selection is ctrl-click.

  • I do not want all of the playlists in iTunes to be synced to my iPhone. With iCloud I do not seem to have a choice. How do I select only certain playlists for my iPone?

    I have many songs and playlists in my iTunes account.  I do not want all of them synced to my iPhone 5S, but that has happened via iCloud, and it has caused a storage problem on my phone.  How do I select only certain playlists to be synced to my iPhone? 

    You need to start over with Music. On the iPhone Music screen uncheck sync music. Also, on the Summary screen uncheck "Manually manage music and videos", then sync and it should clear off your phone.
    Next, choose the music you want to sync. If you want to fit more on check "Convert higher bit rate songs to 128 kbps AAC". This will reduce quality slightly, but it won't be noticable unless you are using $300 headphones.

Maybe you are looking for