Calling File Chooser from a Button

I create a new JFileChooser when a button in a main control panel is pushed but when the Chooser pops up it only responds to the keyboard and not to the mouse. How do I get the Chooser to respond to the mouse after it has been opened? (By the way, when I don't use the button to access the Chooser it works fine)
Thanks.
Scott

I have no problem opening the file chooser using the button, the problem is that the file chooser does not listen to the mouse once it is opened. I know the file chooser normally works properly because when I comment out the buttons I can use the same file chooser method that I have created it works fine. Here is the code that I have for these parts:
JButton getFile = new JButton("Get Files");
          JButton displayImage = new JButton("Display Scans");
          JButton calculate = new JButton("Calculate Rotations");
          panel.add(getFile, BorderLayout.WEST);
          panel.add(displayImage, BorderLayout.CENTER);
          panel.add(calculate, BorderLayout.EAST);     
          frame.getContentPane().add(panel, BorderLayout.CENTER);
          frame.pack();
          frame.setVisible(true);
          getFile.addActionListener(new ActionListener() {      
               public void actionPerformed(ActionEvent e) {
               JFileChooser choser2 = new JFileChooser();
                    File[] files = getDirectory(choser2);
public static File[] getDirectory(JFileChooser fc){
     File[] files;
     files = new File[200];
     File file;
     fc.setMultiSelectionEnabled(true);
     JFrame frame = new JFrame("File Selector");
     int returnVal = fc.showOpenDialog(frame);
     if (returnVal == JFileChooser.APPROVE_OPTION) {
     files = fc.getSelectedFiles();
} else {
     file = null;
System.out.println("Open command cancelled by user.");
     return files;
}

Similar Messages

  • Need a way of calling this code from a button

    Hi all
    I am sorry to have to ask this but I can not find any info on this.
    I found this code somewhere on the net. I should be able to delete a folder with file inside of it.
    I need to call this when a button is clicked.
    CAN ANYONE HELP ME or show me away of deleting a folder with files inside from a button?
      public  static boolean deleteDir(File dir) {
       dir = new File ("Epod Configuration/Config Files/Temp Image Files/");
        if (dir.isDirectory()) {
          String[] children = dir.list();
          for (int i = 0; i < children.length; i++) {
            boolean success = deleteDir(new File(dir, children));
    // The directory is now empty
    return dir.delete();

    First have your class implement the Actionlistener interface then do this:
    //create a button object
    Button b = new Button("Delete");
    //listen for action on the button.
    b.addActionListener(this);
    //add the button to the container.
    add(b);
    //call the method to delete the directory when button is clicked.
    public void actionPerformed(ActionEvent e) {
    if ("Delete".equals(e.getActionCommand())) {
    deleteDir(File dir);

  • Calling a Procedure from a Button? (REVISITED)

    Hi All,
    I once asked a question Re: Calling a Procedure from a Button? & that problem was resolved when i was working on the online ApEx.
    On my application, requirements have changed a bit: I have one form based on two tables. One table contributes two fields (name & surname) to the form while the remaining fields are contributed by another table to make a total of 17 fields on the form.
    My process is in such a way that a user enters an id number & clicks Search button, if the apllicant exists then both name & surname corresponding with the id number will be retrieved from the database. If the applicant does not exist then an error message will be displayed inline with the id number field. Here's the PL/SQL anonymous block to that:
    DECLARE
    vNAME APPLICANTS.name%TYPE;
    vSURNAME APPLICANTS.surname%TYPE;
    BEGIN
    SELECT count(*)
    INTO :P2_COUNT
    FROM applicants
    WHERE id_number = :P2_ID_NUMBER;
    IF :P2_COUNT > 0 THEN
    SELECT name,surname
    INTO vNAME, vSURNAME
    FROM applicants
    WHERE id_number = :P2_ID_NUMBER;
    :P2_NAME := vNAME;
    :P2_SURNAME := vSURNAME;
    ELSE
    apex_application.g_print_success_message := '<span style="color:red">Applicant does not exist.</span>';
    END IF;
    EXCEPTION WHEN NO_DATA_FOUND THEN
    apex_application.g_print_success_message := '<span style="color:red">Exception Caught.</span>';
    END;The PL/SQL block works except for error displaying part (but that's a problem for another day).
    NB: On my application, there’s already Automated Row Fetch & Automatic Row Processing (DML) processes for one table. Furthermore, there is also a javascript for verifying the validity of an id number. As a result, I decided to include Automated Row Fetch & Automatic Row Processing (DML) processes for the other table. When I click a Search button the javascript is activated even though I did not specify a URL target for the button - because this is a simple button among region items – it does not have Optional Url Redirect section.
    I'm not sure what I'm doing wrong here - any help is appreciated.
    Regards
    Kamo

    Hi Dan,
    Sorry for causing confusion with my post - it's just that I was asking the same question (with different constraints) as I had asked before so I didn't feel like going to details was necessary because in my post I included a link to the previous thread. Interestingly, I was working on apex.oracle.com when I posted the original thread - the only problem came to be when I started to move the solution to my application on my machine.
    Anyway, thanks for the response!
    Regards
    Kamo

  • Calling a Procedure from a Button?

    Hi All,
    I'm using Oracle Application Express 11g & I'm currently working on an application. One of the requirements for this particular application is that a user has to be able to enter an applicant's id number (in the id textfield) & if a user clicks a button then they should be able to check in the db whether the applicant exists or not. If the applicant exists then name & surname textfields should be populated with values from the database corresponding to the id number & all these three textfields should be read only. If the applicant doesn't exist then the user will be directed to a page where he/she will fill in new applicant's details.
    So, I wrote the following procedure to do that:
    CREATE OR REPLACE PROCEDURE search_applicant(
    P17_APPLICANT_IDNUMBER IN FIR_APPLICANT.applicant_idnumber%TYPE,
    P17_NAME OUT FIR_APPLICANT.name%TYPE,
    P17_SURNAME OUT FIR_APPLICANT.surname%TYPE,
    P17_COUNT IN FIR_CURRENCY.currency_id%TYPE) IS
    BEGIN
    SELECT count(*)
    INTO P17_COUNT
    FROM fir_applicant
    WHERE applicant_idnumber = :P17_APPLICANT_IDNUMBER;
    IF P17_COUNT > 0 THEN
    SELECT name,surname
    INTO P17_NAME, P17_SURNAME
    FROM fir_applicant
    WHERE applicant_idnumber = :P17_APPLICANT_IDNUMBER;
    dbms_output.put_line('Name: ' || P17_NAME || ' & Surname: ' || P17_SURNAME);
    ELSE
    dbms_output.put_line('Applicant does not exit.');
    END IF;
    EXCEPTION WHEN NO_DATA_FOUND THEN
    dbms_output.put_line('Applicant does not exit.');
    END;
    So far I have not been able to find any help in this regard. I know how to invoke a javascript from a button but I'm not sure how to go about this one.
    Any help in this regard is highly appreciated.
    THANK YOU
    Kamo

    Thanx PaulD & Chris,
    Sorry for the delay in response - I couldn't implement the solutions you recommended for me. My ApEx instance is down (& has been for the past week). It finally dawned on me that I could recreate my problem @ apex.oracle.com. Please take a look at the following application & see if you can help:
    http://apex.oracle.com/pls/otn/f?p=45267:2:714925804498386:::::
    Username: Kamo
    Password: admin
    PS: I have tried to call a Procedure from a button using a page process but it still couldn't work.
    THANK YOU!
    Kamo
    Edited by: user5429001 on 2009/01/28 6:10 AM
    Edited by: user5429001 on 2009/01/28 6:21 AM

  • Calling ASP script from APEX button passing Bind variable

    I am looking for some examples or best form for calling asp script from apex button that will pass apex bind variable to asp script to process.
    Thanks,s
    Bob

    I am surprised by the degree of no replies. I have solved this by using asp redirects such as:
    Response.Redirect("test.aspx?UserName="&user)
    My formulated solution contains a page with a manually built interactive report. I have a number of bind variables at the top of the reoprt where users can query the information they want based on desginated database columns for this particular report. Once they have the "manual" interactive report displaying what they want, they click a button where a asp script is called with parameters passed that calls a Java based Crystal Reports plugin with the called correspnding report displayed with passed parameters.
    Works like a charm!
    This solves our reporting needs without having to resort to Bi Publisher (much too expensive) and other third party applications that kinda indicate it can work with apex but provide limited help or best form for doing so.
    Bob

  • Get cardname along with cardcode usuing Choose From List Button

    Hi,
    I am using Choose From List button in my form. If I click the button then I can see the matrix containing business partners list and if I choose any business partner from that list then I can see the business partners id or cardcode from ocrd table in the corresponding textbox.
    But I want the business partner's name or cardname also should come simultaneously in the next textbox of my form. Can some one provide me any code help for this process.
    Regards,
    Sudeshna.

    Hi Sudesha,
    You can get the CardName with the following code:
    sCardCode = oDataTable.GetValue(0, 0)
    sCardName = oDataTable.GetValue(1, 0)
    Hope it helps,
    Adele

  • Calling a page from a button url

    Can you give me a hint how to call (branch to) a page from a button which is placed behind an item in a region. If I choose button to be a HTML button this should be possible. I think it's documented in User Guide Page 6-22. But description is not very informative. It's easy to do if the button is in a region position.
    Regards Christoph

    Christoph,
    For buttons in region positions the branches can be associated with the button by picking the button from the "When Button Pressed" select list. For buttons displayed among the region items, you need to conditionally branch based on the request send by the button. Assuming you already created the button and a branch that takes you to the target page, edit the button, scroll down to "Button Request Value" and type in your request string, e.g. BUTTON_PRESSED. Then edit your branch, and make it conditionally based on a request "Request = Expression 1" and type in your request string BUTTON_PRESSED into the Expression 1 field.
    Hope this helps,
    Marc

  • Calling java script from a button

    Hi,
    I have a Form and I would like to let the end-user to confirm some action that was initiated by pressing a button. The best way would be to call Java script, but the button is an 'item' button and not a 'region' button - i..e it is placed between items and not above the region, like Save, Cancel etc.
    In case of 'item' buttons I do not have 'Optional URL Redirect' field where to place the javascript call.
    Tamas

    You can try this..
    Instead of using button
    Edit the Item to which you want to associate a button.
    Go to Element tab
    Under Post Element Text enter
    </ br> <a href="#" -onclick=call_me() class="t20Button">Click me</a>Note : you need to change class="t20Button", i'm using theme 20 and in that the look and feel of button is derive from t20Button.
    remove the hyphen before onclick ..
    Regards,
    Shijesh

  • Call file(*.pdf) from form

    can we call file ex: d:\lat.pdf into web from form 9iDS?
    thanx
    pipin

    Put the PDF to a directory within the webserver and call it with
    web.show_document('http://webserver/pdf/lat.pdf', '_blank');

  • File chooser disabling the buttons

    i want to disable the buttons unless the user chooses a file or inputs
    name of the file how can i do that

    Hello,
    you could use FileChooser's setControlButtonsAreShown(boolean)-method:import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.File;
    import javax.swing.*;
    import javax.swing.filechooser.FileSystemView;
    public class FileChooserTest extends JFrame
         public FileChooserTest()
              super("File-Chooser Test");
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              final JFileChooser fileChooser = new JFileChooser(FileSystemView.getFileSystemView());
              fileChooser.setControlButtonsAreShown(false);
              fileChooser.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e)
                        getContentPane().invalidate();
                        fileChooser.setControlButtonsAreShown(true);
                        getContentPane().validate();
                        getContentPane().repaint();
              getContentPane().add(fileChooser);
              pack();
              setLocationRelativeTo(null);
              setVisible(true);
         public static void main(String[] args)
              new FileChooserTest();
    }regards,
    Tim

  • Calling Forms/Reports from a button

    How to call a Report or a Form which had been developed using the Wizard from a button created in a region of a page flow?
    National Steel
    Harirajan

    There are two ways to achieve this.
    1) Assign a URL for the button to redirect to. You will have to use the f?p syntax to do this, so for example, if your FlowID is 100 and your page ID is 4, you could redirect to:
    f?p=100:4:&SESSION
    Note the use of the substitution variable for the user's session.
    2) Create a branch that is fired by the button when the page is submitted. A branch is an instruction that tells the Flow which page to go to next. You only need to specify the page ID which has your form or report on it when you create the branch.
    Team Project Marvel

  • Automation server can't create object when calling a jsp from a button

    Hello,
    I have created the following jsp that allow me to execute an external program that is located on the client side:
    <script language="JavaScript" type="text/javascript">
    <!--
    function execAppli(app)
    var wshShell = new ActiveXObject("WScript.Shell");
    wshShell.Run(app+".exe", 1, true);
    -->
    </script>
    If I call this jsp in a simple html page is works correctly when i call it from a button in apex (3.0) I got the error message Automation server can't create object.
    Any idea ?
    Thanks,
    Claude-Alain

    Hi Claude,
    Just be sure that you really (like really) trust your endusers, because I can see some huge opportunities for exploiting that JavaScript routine you've shown. If you're not taking steps to prevent cross site scripting (search this forum or Google for details on what that is), then it's not beyond the bounds of possibility for someone to do something 'nasty' which would do horrible things to your end users if your executing a program on their client machines without any warning or validation of what that program actually does.
    Sometimes it's best to work backwards from the point of view of....what if you walk into work one morning and find that 400 end users machines have had their hard-drives wiped because the script arbitrarily executes whatever command you pass to it? Then you can perhaps see that what sometimes looks like a good idea might not be such a good idea after all ;)

  • Calling a popup from FPM button

    Hi All,
    The scenario is from SRM (7.0).
    1. I click on a button in the FPM Identification Region lets say - Create PO.
    2. When I click on the button Create PO, it creates a PO in the back ground and gives me a confirmation pop up saying that the PO is created.
    Now my requirement is such that I need to populate the header/ Payment terms texts in the PO.
    As the button being clicked is in FPM frame work, how do I call a pop up and pass the texts in to the PO.
    Best Regards,
    Basha

    I hope someone has an answer to this. I am looking for a similar solution. I do know the Web Dynpro Component for that screen is FPM_OIF_COMPONENT, the view is CNR_VIEW, the "Create Purchase Order" button is OTHER_FUNCTIONS_22 and the method ONACTIONBUTTON_PRESSED controls all of the other buttons (ie. Print Preview, Close, etc.). However, I can't find what happens when the Create PO button is pushed.
    Edited to Add: The Web Dynpro info only applies to the RFx Response screen. Probably not what you are looking at.
    Edited by: Sharina Smith on Apr 28, 2009 8:45 PM

  • Method required to calling file/shellscript from XI

    Hi All,
    My scenario is to read multiple records from a stored procedure in DB2 and creating one file for each record retreived. i use a NFS and add timestamp for each file i write. i have completed this part. Now, i will have to call an external executable file or shell script with each file i create in the target directory. I read the blog
    <a href="/people/sameer.shadab/blog/2005/09/21/executing-unix-shell-script-using-operating-system-command-in-xi Unix shell script using Operating System Command in XI</a> which tells about passing the Absolute path of the target file as parameter while calling a shellscript.
    My question is when i am appending a timestamp to the target file, how can i call the shellscript using the Operating System Command.
    And using the Operating System Command, can i call only a shell script or an any sort of executable file as well?
    Appreciate any response that helps.
    Thank you,
    Regards,
    Balaji.M

    Hi Archana,
    My question is when i am appending a timestamp to the target file, how can i call the shellscript using the Operating System Command.
    Say -
    Target Directory = /home/xd1/folderB
    File Name = Test.xml
    File Construction Mode = Add Time Stamp
    Operating System Command = /home/xd1/executables/runthis.sh %F
    Now, the output files created are this sequence (after appending timestamp to file name)
    Test20070111-141338-376.xml
    Test20070111-141343-213.xml
    Test20070111-142958-615.xml
    My Question meant:
    would only the <b>/home/xd1/folderB/Test.xml</b> be passed runthis.sh
    or
    Test20070111-141338-376.xml be passed runthis.sh - first
    Test20070111-141343-213.xml be passed runthis.sh - second
    Test20070111-142958-615.xml be passed runthis.sh - third
    in short, would the output file be passed to the shellscript after adding the timestamp to the filename?
    Regards,
    Balaji

  • Calling file upload from outside APEX

    Hi,
    I would like to mass upload documents to apex flows_files schema. Initially I thought I could 'just' inserts records into WWV_FLOW_FILE_OBJECTS$ table, but now I think it is not a good idea, since I do not know how to generate all columns (primary key for example.)
    Is there any other legal way to do this? Calling a web service or something? Every hint is highly appreciated.
    Tamas

    Tamas,
    as you say, this is unstructured data, but are these documents coming from a single directory?
    I mean, how do you find a particular document in a 3000 folder?
    There must be some rule, some method for retrieving one particular document, by name, by modification date, by owner, you can't browse 3000 documents every time, can you?
    If this new application takes care of everything as far as the document organization is concerned, then you may create your own table containing a BLOB column and take advantage of Apex's declarative BLOB support for uploading and downloading files.
    Said that, probably the best method of doing a mass upload would be to put all these files in a folder that you make available to the DB using the CREATE DIRECTORY command, then you process the files using an utility built on top of DBMS_LOB.LOADBLOBFROMFILE.
    You must find some way of storing the file names upfront though, because you cannot browse the directory contents, you must know in advance the name of the file to be loaded, but i guess you can create a table holding the names of the files and then you can loop through the rows of this table.
    Clearly this method makes sense if it is a one-off operation, if you need to repeat this operation over time then it may be advisable to engineer this process a little bit.
    Flavio
    http://oraclequirks.blogspot.com

Maybe you are looking for

  • Call ejb from another class?

    there are some codes form someone I dont understand, can anyone help me out ? the class Call will run on the same VM as the CMP entity bean Subscriber. what I am not sure is the call in method f2() , i.e. s.setName() will really wirte data to databan

  • IPhot and Kodak Gallery

    New iMAC owner here. Can anyone explain to me how I can upload photos from my iPhoto files to KodakGallery.com, to share with other people? I have been able to upload a single photo at a time but only thru many clicks. With my PC, I was able to uploa

  • Video download error =-.50 - how do I fix this

    I tried to download breaking bad and it stopped prematurely - download error =-.50. How do I fix this?

  • How do I remove 'no sender' messages from my iphone 4?

    Hi, This is my second iPhone and am having the same issue with the 4 as I had with the 3.  E-mails sometimes appear as 'no sender' and 'this message has no content'.  I would like to know how to get them off of the phone since the delete option is no

  • Key figures in row and column.

    Dear all, I have a requirement in my BEx query to have to key figures in both the row and column. This is the scenario, I have a formula defined in the row which does a total up and the user would like to see this key figure formula in the column whi