How to set the the file selection mode of JFileChooser

hi,
i want to set the file selection mode to directories only for JFileChooser class but when i run the code it does not select the folder adn opens the folder instead. i want the user to select a folder from the file system . any ideas?

Sorry, I misunderstood you question. I thought that you already set it to choose Directories and wondered when you can't select them when you double-click.
use JFileChooser.setFileSelectionMode(int). This should solve your problem.
Here is an example:
        JFileChooser jf = new JFileChooser();
        jf.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        jf.showDialog(this, "Select");
        System.out.println(jf.getSelectedFile());
unformatted
JFileChooser jf = new JFileChooser();
jf.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
jf.showDialog(this, "Select");
System.out.println(jf.getSelectedFile());

Similar Messages

  • How to set the file transfer mode to binary

    Hi,
    I have a requirement to upload files from local machine to server, and it is working fine.
    But after uploading files junk characters are entered after each line, so want to set the file transfer mode to binary to get rid from this error.
    We have checked that if we ftp the files manually then also getting the same problem when the transfer mode is not selected as binary.
    Please give your valuable advice.
    Thanks,
    Ranita

    Hi,
    I want to set the file transfer mode through controller code, presently I am using the below code where no file transfer mode is specified ::
    public void upLoadFile(OAPageContext pageContext,OAWebBean webBean)
      String serverPath = null;
      OAApplicationModuleImpl am = (OAApplicationModuleImpl)pageContext.getApplicationModule(webBean);
       try {              
          Connection conn = am.getOADBTransaction().getJdbcConnection();     
          String query = "select  distinct variable_name, value from fnd_env_context where variable_name = 'XXCUST_TOP' and concurrent_process_id = ( select max(concurrent_process_id) from fnd_env_context )";
          PreparedStatement stmt = conn.prepareStatement(query);
           for (ResultSet resultset = stmt.executeQuery();
                          resultset.next(); )
                 serverPath  = resultset.getString("value");
            stmt.close();  
           catch(Exception ex)
             throw new OAException(ex.getMessage(), OAException.ERROR);
       String filePath = serverPath+"/"+pageContext.getParameter("FileType");
       //System.out.println("Default File Path---->"+filePath);
       String fileUrl = null;
       try
        DataObject fileUploadData =  pageContext.getNamedDataObject("MessageFileUpload");
      //FileUploading is my MessageFileUpload Bean Id
        if(fileUploadData!=null)
         String uFileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME"); 
         String contentType = (String) fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE");  
         //System.out.println("User File Name---->"+uFileName);
         FileOutputStream output = null;
         InputStream input = null;
         BlobDomain uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null, uFileName);
         //System.out.println("uploadedByteStream---->"+uploadedByteStream);
         File file = new File(filePath, uFileName);   //C:\\Ranita
         //System.out.println("File output---->"+file);
         output = new FileOutputStream(file);
         //System.out.println("input---->"+input);
         byte abyte0[] = new byte[0x19000];
         int i;
         while((i = input.read(abyte0)) > 0)
         output.write(abyte0, 0, i);
         output.close();
         input.close();
         HashMap map = new HashMap();
         map.put("fromPage","Y");
         pageContext.forwardImmediatelyToCurrentPage(map,true,OAWebBeanConstants.ADD_BREAD_CRUMB_YES);
       catch(Exception ex)

  • How to set the Data Synchronisation mode for ADF BC component?

    Hi All,
    How to set the Data Synchronisation mode for ADF BC component
    Thanks
    Raghavendra

    Can you clarify what you mean by the data synchronization mode?
    If you mean the Sync Mode, then in 10.1.3 you set this property by:
    1. Selecting your DataBindings.cpx file
    2. Expanding the "Data Control Usages" section in the structure window
    3. Selecting the ADFBC-based data control
    4. Setting the "syncMode" property in the property inspector.

  • How to set the file path dynamically based on sytem, username, and date

    Hi All,
    My requirement is upload the data into one  structure like xyz that is related to t.code MCSZ.
    file will be in  UNIx SERVER .
    PATH IS: /sapif
    file name is xy789 load .txt
    I have  to write code in one user-exit
    how can i set the file path for this.
    shall i put hard code file path?
    because i have to writecode in user-exit.
    plz tell me how to set the file path based ons syetem, username, date
    Thanks in advance
    Ram.A

    Concatenate the field SY-SYSID, SY-UNAME and SY-DATUM for the file path

  • How to set the default selection to "Select All" in a Multi valued parameter in SSRS 2008?

    Hello Everyone,
    How to set the default selection  to "Select All" in a Multi valued parameter in SSRS 2008?
    Regards
    Gautam S
    Regards

    You need to specify "Default Values" in the report parameter property. Choose similar option used in the "Available Values" option, this will allow the parameter to check "Select All".
    Regards, RSingh

  • How to set the full screen mode using setClip method

    hi all,
    how to set the full screen mode using setClip in that softkeys should not be used insteat on that need to create a own softkeys using commands.
    thanks & regards
    Bala.

    In CS5 there are changes made to how the screen mode is reported. In CS3-CS5 the screen mode has a corresponding number. So for instance if the ScreenMode is set to "Preview Off" and you ask indesign CS3 or CS4 to display the screen mode, it will report "1936552047", while in CS5 it will report "PREVIEW_OFF".
    try executing this simple command in respectively CS3, CS4 and CS5 and you will see what I am talking about:
    alert(app.activeWindow.screenMode);
    there is no difference if you do:
    alert(app.activeDocument.layoutWindows[0].screenMode);
    The CS5 solution is rather awkward to work with, unless I am missing something? PREVIEW_OFF is not a string, nor is it a number.
    Example -  doing:
    myScreenMode=app.activeDocument.layoutWindows[0].screenMode;
    and then trying to reset screenMode by something like:
    app.activeDocument.layoutWindows[0].screenMode= myScreenMode
    does not work in CS5 of course. It will throw an error. Neither will this line work:
    app.activeDocument.layoutWindows[0].screenMode=ScreenModeOptions.myScreenMode;
    Any way of working around this?

  • How to set the parameter selection *optional* for each subreport?

    Hi,
    I am using Crystal Reprots 11.
    I create 10 subreports, and each subreport contains a Parameters Field.
    The 10 subreports are put in 10 footer sections in increasing order, i.e. subreport1, subreport2, subreport3, ..., subreport10.
    When I use "Print Preview" to take a look at the whole report, CR prompts a "Edit Values" window for selecting parameter values for all 10 subreports.
    For example, if I only select parameter values for subreport1 and click "OK", 9 error messages on the "Edit Values" window come out above the selection list box of every other subreports (i.e. subreport2 ~ subreport10) showing that: 'The value is not valid'.
    Sometimes, I just want to review some specific subreports but not all.
    How should I do to set the parameter selection optional (not mandatory) for each subreport?
    Thank you in adavance.
    Edited by: Holdup on Feb 17, 2012 3:44 PM

    Hi,
    Here's how you can make the prompts optional (Assuming you're using CR 2008 or higher):
    1) Go into each subreport
    2) You should see the parameter in the Field Explorer. Right-click the name and select Edit > Look for an option called 'Optional Prompt'. Set it to true
    3) If you have a record selection in the subreport, then you need to modify the selection formula to something like this:
    if not(hasvalue({?Parameter_Name})) then True else = {?Parameter_Name}
    Hope this helps!
    -Abhilash

  • How to set the File Path to run a javascript using Plugin Code?

    Hi All,
    Im new to Indesign Plugin Development.Can any one help me out with my problem.
    What i want to do is to run a javascript using Plugin Code.When i went through this forum i was able to find out that i should use the IscriptRunner Class to automate this.I could also figure out that the Member Function to use is "CanHandleFile" &"RunFile".
    The first parameter in CanHandleFile & RunFile Member Function is to specify the path of the JavaScript File i suppose!I could also find out that IDFile has to used to set the file path Information.
    But im clueless how to set the Javascript FilePath using IDFile.Can any one help me how to do this?Any Code Snippets Please?
    Waiting for reply.
    Thanks
    myRiaz

    Hi,  Andreas<br /><br />  Can you explain this in detail? I found it in your post before.<br /><br />  The content of elements are returned through the Characters callback function:<br /><br />From ISaxContentHandler.h:<br /><br />/**<br />        Receives character data<br /><br />The parser will call this method to report each chunk of<br />        character data. SAX parsers may return all contiguous<br />        character data in a single chunk, or they may split it into<br />        several chunks. But all characters in any single<br />        event must come from the same external entity so the<br />        Locator provides useful information.<br /><br />Note some parsers will report whitespace using the<br />        IgnorableWhitespace() method rather than this one (validating<br />        parsers must do so).<br /><br />@param Chars The characters from the XML document.<br />        */<br />virtual void Characters(const PMString& chars) = 0; <br /><br />  What i have done is implement my own SAXContentHandlerServiceBoss, and in my file XXXSAXContentHandler.cpp, I override the fonctions StartElement, EndElement, and Characters() like below: I add the PMString xmlData to collect the file content:<br /><br />class XXXSAXContentHandler : public CSAXContentHandler<br />{<br />void XXXSAXContentHandler::Characters(const WideString& chars)<br />{<br />xmlData.Append(chars);<br />}<br /><br />void XXXSAXContentHandler::StartElement(const WideString& uri, const WideString& localname, const WideString& qname, ISAXAttributes* attrs)<br />{<br />xmlData.Append("<"); xmlData.Append(localname); xmlData.Append(">");<br />}<br />void XXXSAXContentHandler::EndElement(const WideString& uri, const WideString& localname, const WideString& qname)<br />{<br />xmlData.Append("</"); xmlData.Append(localname); xmlData.Append(">");<br />}<br /><br />}<br /><br />and in my program, I use the code below to call the fonction I overrided, but I dont know how I can get the String xmlData I defined in the XXXSAXContentHandler.cpp<br /><br />InterfacePtr<IK2ServiceRegistry> serviceRegistry(gSession, UseDefaultIID());<br /><br />InterfacePtr<IK2ServiceProvider> xmlProvider(serviceRegistry->QueryServiceProviderByClassID(kXMLParserService, kXMLParserServiceBoss));<br /><br />InterfacePtr<ISAXServices> saxServices(xmlProvider, UseDefaultIID());<br />InterfacePtr<ISAXContentHandler> saxHandler(::CreateObject2<ISAXContentHandler>(kXXXSAXContentHandlerServiceBoss));<br />saxHandler->Register(saxServices);<br />bool16 parseFailed = saxServices->ParseStream(readStream, saxHandler);<br /><br />Can you give me any help?<br /><br />Thanks and regards!

  • How to set the default selection screen

    I modified screen using screen-input = 0.
    then how to set the screen-input = 1.
    that is how to make that field input enable.
    if use the statement screen-input = 1 directly it is giving 2 fields to enter value

    In the PBO / AT SELECTION-SCREEN OUPUT
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF screen-name = <your FIELD>. " Fields by name
    *   IF SCREEN-GROUP1 = <your group of fields>. " Fields with MODIF ID
          IF <test>.
            screen-input = 1. " For input enable
          ELSE.
            screen-input = 0. " For input disable
          ENDIF.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    Regards

  • How to set the default selected option as NO_OPTION in a JoptionPane

    This is just an example program to create the same scenario in the project.When clicked on OK button, it will pop up a JOptionPane confirm dialog with YES-NO buttons.I want to set the default selected button as NO button. In the below program, the keyboard focus is set on NO button, but in the look and feel the selection is still YES button. Can anyone suggest a solution to make both the focus on NO button?
    public class Test extends JPanel implements ActionListener{
         Test() {
              JButton btn = new JButton("OK");
              this.add(btn);
              btn.addActionListener(this);
         public void actionPerformed(ActionEvent e) {
              Object[] o = {"Yes", "No"};
              JOptionPane p = new JOptionPane("Are u sure?",JOptionPane.QUESTION_MESSAGE,JOptionPane.YES_OPTION,null,o,null);
              //p.setWantsInput(false);
              p.setInitialSelectionValue(o[1]);
              try {
                   UIManager.setLookAndFeel(new MetalLookAndFeel());
              } catch (UnsupportedLookAndFeelException e1) {
                   // TODO Auto-generated catch block
                   e1.printStackTrace();
              //p.setFocusCycleRoot(false);
              p.setInitialValue(o[1]);
         //p.getRootPane().getDefaultButton().requestFocusInWindow();
              UIManager.put("Button.defaultButtonFollowsFocus", Boolean.FALSE);
              p.createDialog(this, "").setVisible(true);
              if(p.getValue() == o[0]) {
                   System.out.println("yes");
              }else if(p.getValue() == o[1]) {
                   System.out.println("no");
              //p.setWantsInput(true);
              //p.showConfirmDialog(this, "Are u sure?");
              //p.setInitialSelectionValue(new Integer(JOptionPane.NO_OPTION));
         public static void main(String[] args) {
              Test t = new Test();
              JFrame f = new JFrame();
              f.getContentPane().add(t);
              f.pack();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.setSize(500, 500);
              f.setVisible(true);
         }

    not sure what you're trying to do, but try this
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Test extends JPanel implements ActionListener
      Test()
        JButton btn = new JButton("OK");
        this.add(btn);
        btn.addActionListener(this);
      public void actionPerformed(ActionEvent e)
        Object[] o = {"Yes", "No"};
        int value = JOptionPane.showOptionDialog(null,"Are u sure?","",-1,-1,null,o,o[1]);
        if(value == 0) System.out.println("yes");
        else if(value == 1) System.out.println("no");
      public static void main(String[] args)
        UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);
        Test t = new Test();
        JFrame f = new JFrame();
        f.getContentPane().add(t);
        f.pack();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setSize(500, 500);
        f.setVisible(true);
    }

  • Urgent!How to set the default selected date for an OAMessageDateFieldBean

    Hi,
    There is messagetextinput on the page.the dataType is Date.
    if I do not input anything on this messagetextinput ,when I click on the date icon,the default selected date is today.
    But I want to set the default selected date base on another messagechoice.
    Is that possible?
    binghao.

    Sumit/Binghao,
    When u set deafult date in the OAMessageDateFieldBean, the OAInlineDatePickerBean (which are referring as datepicker popup windows), takes the default value from OAMessageDateFieldBean.
    If you explore OAMessageDateFieldBean in framework, u will find its nothing but a onClick js event is called on the imageicon attached with messagetextinput bean(in case the type is Date) and OAInlineDatePickerBean is opened in a modal js window.
    So, here is code for setting default value both in both in OAMessageDateFieldBean and OAInlineDatePickerBean :
    OAMessageDateFieldBean dateField = (OAMessageDateFieldBean)webBean.findIndexedChildRecursive(<item id>);
    dateField.setValue(pageContext,new Date(100, 06, 04)/* 4th July 2000*/);
    One more important thing, here Date class is java.sql.Date.I hope i am clear.
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to set the right filter mode?

    Hi All,
    I have a few applications deployed in Tomcat 5.5.9 for which i need to control access.
    I have created a policy to which I have added a rule of type URL Policy Agent and added a few users as subjects.
    Now that the policy is in place, I tried to change the filter.mode property in AMAgent.properties file to all the possible options and I have noticed the following:
    filter.mode=NONE              Allows all users without authentication
    filter.mode=SSO_ONLY          Allows all users after authentication against DS
    filter.mode=URL_POLICY          Disallows authentic users also (HTTP 403 error)
    filter.mode=J2EE_POLICY          Allows all users after authentication against DS
    filter.mode=ALL                      Disallows authentic users also (HTTP 403 error)
    In my case all the observations except the J2EE_POLICY option work as required.
    I conclude this as a part of my understanding gained through the following:
    http://docs.sun.com/source/816-6884-10/chapter3.html#wp21908
    I have failed to understand why the J2EE_POLICY option allows users which are not included as subjects in the realm as authentic.
    I have also tried setting the com.sun.am.policy.agents.do_sso_only=false property but dint get things working as needed.
    Any help in this regard would be appreciated.
    Regards,
    Saiesh Nayak,
    Persistent Systems.

    J2ee_policy allows users which are not included as subjects in the realm because the policy agent actually doesn't validate the URL policies configured in AM, it just validate j2ee declarative security from your web application.
    So, as I suspect, if you don't have security constraints in your webapp, you won't enforce security.
    With URL_POLICY option, you will enable url policy evaluations as you configure it in Access Manager. So, in this case and in the ALL option case, check that the url policy is correctly configured, mainly the rule.
    You can enable debug.level=message instead of debug.level=error in AMAgent.properties in order to see what's happening. When you enable message level debug, the agent will create some debug log files, please take a look on the amFilter and amWebPolicy log files.
    Hope it helps.

  • How to set the default selection in treetable

    Hi,
    Now I'm using jdeveloper 10.1.3.3, and using af:treeTable and af:tableSelectOne to represent a treetable and let the user select specific row by clicking the radio button in front of each row. I want to programmatically set a specified row to be selected by default when the page is loaded, I didn't find a way to implement this function.
    Anyone has ideas?
    Thanks in advance.

    Hi Karen,
    What is the type of data you are feeding to the drop down ? Is it a standard fixed list of items or a query ? From what i see you would be using a query as the dataprovider for the dropdown. In such a case, in your query, restrict Plant with value 7700 in the default values section of the query. This should do the trick that when you run the template, the dropdown would show 7700 by default.
    Hope this helps.
    Regards
    Snehith.

  • How to set the file.encoding in jvm?

    I have some error in showing Chinese by used servlet,
    some one tole me that I can change the file.encoding in jvm to zh_CN, how can I do that?

    Add the java argument in your servlet engine.
    e.g
    java -Dfile.encoding=ISO8859-1
    garycafe

  • How to set the default selection in a WAD dropdown

    Hi All
    We are on BW 3.5  I have the following dropdown box in a WAD template. Our users want by default when the query starts only to display Plant = 7700.
    Please can you kindly share ideas how I can do this.
    <object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="GET_ITEM"/>
             <param name="NAME" value="DROPDOWNBOX_2"/>
             <param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_FILTER_DDOWN"/>
             <param name="DATA_PROVIDER" value="DP_1"/>
             <param name="BORDER_STYLE" value="BORDER"/>
             <param name="WIDTH" value="200"/>
             <param name="CAPTION" value="Plant"/>
             <param name="IOBJNM" value="0PLANT"/>
             <param name="BOOKED_VALUES" value="Q"/>
             <param name="SHOW_LABEL" value=""/>
             ITEM:            DROPDOWNBOX_2
    </object>
    Thanks
    Karen

    Hi Karen,
    What is the type of data you are feeding to the drop down ? Is it a standard fixed list of items or a query ? From what i see you would be using a query as the dataprovider for the dropdown. In such a case, in your query, restrict Plant with value 7700 in the default values section of the query. This should do the trick that when you run the template, the dropdown would show 7700 by default.
    Hope this helps.
    Regards
    Snehith.

Maybe you are looking for

  • 10.6.8 Canon printer sharing

    Hello, I'm the head of IT for a non-profit and we're trying to share our Canon MF6530 between our two Mac Pros running 10.6.8. We're on a wireless network, with the Canon connected to ComputerA via USB and using Bonjour to share it wih ComputerB. Com

  • Charged twice for Slider Lock to be upgraded to paid version but application not downloaded

    I was on BB Applications and decided to buy the paid version of the slider lock, I used my credit card to buy this application, now my credit card has been charged twice for this application and all I have got is an error message stating that there w

  • Samsun SCH-LC11 4G Hotspot SLOW!

    Got mine today.  Luckily, I don't deal with VPN much which they apparently have screwed up (http://community.vzw.com/t5/4G-Discussion/Samsung-SCH-LC11-Blocks-Microsoft-VPN/td-p/489618), something about this being a Home device not a Business Device ?

  • Integrate Essbase with third party s/w (ETL)

    Hi Experts, I would like to integrate Essbase with third party s/w (ETL) which i am not sure have essbase adopters like DIM/ODI adopters available at e-delivery. Essbase Version: 9.3.1 Third party ETL : CostIron (from IBM) Any help will be highly app

  • Internet not working on OS 4.0.2

    hi, after updating to OS 4.0.2 from OS 3.1.3 on iphone 3gs, internet(3G) not working. only mail works on 3G networks. dont know how. except mail nothing works. can anybody tell me how to fix the problem?