The default button in JFileChooser

Is it possible to make either the 'save' or 'cancel' button the default button (the one that will be pressed when the user presses the 'enter' key after the dialog is shown) in a save-dialog ?
It will probably involve setting the focus to either one of these buttons, but it is unclear how I can do that.
Thanks in advance.

public static JButton searchByText(Component comp, String[] texts) {
    if (comp instanceof JButton) {
        JButton btn = (JButton) comp;
        String text = btn.getText();
        for(int j=0; j<texts.length; ++j)
            if (text.equals(texts[j]))
                return btn;
        return null;
    if (comp instanceof Container) {
        Container cont = (Container) comp;
        for(int j=0, ub=cont.getComponentCount(); j<ub; ++j) {
            JButton result = searchByText(cont.getComponent(j), texts);
            if (result != null)
                return result;
    return null;
}You can call this method, passing it your JFileChooser and:
String[] approves = {"Open", "Save"};

Similar Messages

  • Pointer does not move to the default button in the dialog box

    example: when cleaning out trash the pointer does not go to the default button in the dialog box, you have to manually go there.
    This happens all the time.

    Hi Abhishek,
    In SAP this job shows completed till the 3rd step. and no error in the job log. but it does not execute the 4th and the 5th steps. And in Redwood, it shows completed for 1st and 2nd steps, 3rd step is in Error but has no error log. The 4th and 5th steps are in chained status. I have not amended the job chain after import. I have just scheduled it as it was running in the SAP system.
    Let me know if you need some further information on this.
    Regards
    madhu

  • How to bring mouse cursor to the default button of a dialog, like in windows

    Anybody know how to achieve this in LV?
    Please see the attached screenshot.
    - Partha
    LabVIEW - Wires that catch bugs!
    Attachments:
    Automatically move mouse pointer to the default button.PNG ‏34 KB

    Dear partha,
    1) You can be able to trace out the location of the button
    2) You can be able to move the cursor to that location
    3) You can be able to automatically generate a click on that button
    Use user32.dll to achieve all this. when u use it in CLN(Call Library Node), u can c functions 4 that.
    Try and ask if further help needed!!!!!
    Thanks,
    Mathan

  • How to set the default button of an ALERT

    Can someone help me how to set the alert propety to change the default button from button1 to button2.Not from the prioperty palette, but inside the code using like set_alert_property.I am using the Oracle Forms 10g.
    Thanks in advance.
    Srini

    To the best of my knowledge, the default button cannot be set at runtime. This must be set at design time in the Builder.
    Refer to the Forms Builder online help for details:
    http://www.oracle.com/webapps/online-help/forms/10g/topics/f1_help/builts/setatpro.html

  • OutlineField and the Default Button

    Hello all,
    We are currently using the Forte 3.0.G.2. I have recently come
    across the situation where I am unable to understand the behavior of the
    default button. The situation is this:
    Whenever I am including the Outline Field as one of the widgets in
    any of my windows that particular window will not respond to the default
    button. I am attaching the pex file so you can run the test windows and see
    the problem.
    Can someone please tell me if I am doing something wrong or is this a
    known/unknown bug?
    <<DefaultBtn.pex>>
    Thanks in advance.
    Kamran Shafi
    Systems Engineer
    EDS Medi-Cal XIX
    Phone: (916) 636-1093
    Email: [email protected]

    Hi Kamran!
    What happens is that when the focus is on outline fields, the enter key
    fires a doubleclick event and ignores the default button. So you need to
    capture the doubleclick event and do whatever you want your button to do.
    Here's a quote from Forte support
    "Unfortunately, this is a documentation issue. The IsDefaultButton only
    works when focus is on a simple DataField, because in all of the complex
    fields, including TextField, TextEditField, TreeView and ListView as well
    as OutlineField, the Enter key has a separate and defined action. On
    Tree/ListViews and OutlineFields that is DoubleClick.
    You COULD catch the DoubleClick on the OutlineField and post a click event
    on the default button, however I'd encourage caution with that, since this
    could cause some unexpected behavior if someone were counting on the Enter
    (or a mouse double-click) to behave in our standard way."
    Andrew Small
    Enterprise Distributed Solutions National Practice
    BORN Information Services
    [email protected] <mailto:[email protected]>
    -----Original Message-----
    From: Shafi, Kamran [mailto:[email protected]]
    Sent: Thursday, July 08, 1999 12:49 PM
    To: [email protected]
    Subject: OutlineField and the Default Button
    Hello all,
    We are currently using the Forte 3.0.G.2. I have recently come
    across the situation where I am unable to understand the behavior of the
    default button. The situation is this:
    Whenever I am including the Outline Field as one of the widgets in
    any of my windows that particular window will not respond to the default
    button. I am attaching the pex file so you can run the test windows and see
    the problem.
    Can someone please tell me if I am doing something wrong or is this a
    known/unknown bug?
    <<DefaultBtn.pex>>
    Thanks in advance.
    Kamran Shafi
    Systems Engineer
    EDS Medi-Cal XIX
    Phone: (916) 636-1093
    Email: [email protected]
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

  • Jump the cursor to the default button in Mavericks?

    Does anyone know of a way to jump the cursor to the default button in Mavericks? I found a third-party product called Steer Mouse, but it's $20 and that seems high for a one trick pony.
    Any help would be appreciated.

    Unfortunately, it's not that easy with setButtonIcons because it forces you to specify rollover and disabled icons, for instance. So it doesn't help if you just want the default grey filtered icons when disabled. Also, you can't just subclass JUNavigationBar either since most of what you need is private. We took the brute force approach and just copied the JUNaviationBar source and modified it.
    Basically, just create a new class with the same source as JUNavigationBar and replace the private icon filename strings to your icon file names:
    public class NavigationBar
        extends JToolBar
        implements ActionListener, RowSetListener, JUNavigationBarInterface, JUTransactionStateListener
      private static final String BUTTON_FIRST_ICON = "first.png";
      private static final String BUTTON_PREV_ICON = "single_arrow_left.png";
      private static final String BUTTON_NEXT_ICON = "single_arrow_right.png";
      private static final String BUTTON_LAST_ICON = "last.png";
      private static final String BUTTON_INSERT_ICON = "add.png";
      private static final String BUTTON_DELETE_ICON = "delete.png";
      private static final String BUTTON_COMMIT_ICON = "save.png";
      private static final String BUTTON_ROLLBACK_ICON = "refresh.png";
      private static final String BUTTON_FIND_ICON = "find_next.png";
      private static final String BUTTON_EXECUTE_ICON = "query.png";
    ...We also modified some calls in the class' constructor during button setup that made the toolbar not floatable and various other things.
    Hope this helps.
    Erik

  • How to place the mouse pointer over the default button automatically ?

    I am not content with the mouse capability in Mac OS.
    In Windows I used to have a mouse seetting that automatically placed the mouse pointer over the default button in a dialogue box
    Any suggestion for a mouse app for more settings ? is there a free app ?

    You might try SteerMouse 4.1.5 or if all you want is this one feature then try LazyMouse 2.5.

  • How to Make the Default Button Marker Not Show Upon Launching...

    I am trying to only have the markers show up on the menu item when you roll over it.  However, when the menu is first launched, the marker is automatically showing up on the first button.
    I have selected "None" as the default menu button in the menu config.  I am also using Photoshop to make the menu and creating the (+) buttons there.
    Any help would be greatly appreciated.
    Thanks.
    Dave

    Create an invisible button (turn off the visibility of all layers) and
    set it to use Highlight Group 2 (edit the Menu Color Set).  Set the
    opacity of all the highlight states to 0%.  Make the invisible button
    the default button.
    -Jeff

  • How to change the text in the Cancel button of JFileChooser ?

    Hello,
    In french the standart text in the Cancel button of the JFileChooser class is "Annuler". For a good reason which will be too long to explain, I need to change it by another term.
    I tried to create a super class and redefine the CANCEL_SELECTION string, but this does not work. I can't either change it directly because it has the final attribute.
    Where does JFileChooser get this word from ? ( I guess it is not hard coded for multilanguage support purpose).
    Any help would be appreciated
    Gege

    I believe the standard Look and feel implementations look in UIManager for a string called FileChooser.cancelButtonText.
    Therefore you might be able to change it after you've loaded your LnF by using the following code:
    UIManager.put("FileChooser.cancelButtonText", "---change me---");Note that this would change all file choosers in your application.
    If you only want to update one type of file chooser you could extend, for example, MetalFileChooserUI and set its cancel button text by overriding installStrings. You'd then need to install this UI on the file chooser you want to change.
    There may be an easier way to do this!
    Hope this helps.

  • Move cursor directly to the default button "Print" when printing documents

    In internet explorer when the print dialog box opens, the cursor automatically goes to the "print" button so that all I have to do is click. In Mozilla Firefox, I have to move the cursor across the screen to the "print" button. Is there any way to set this up as a default action in Mozilla? Thanks for your help!

    No there isn't that I have ever head about, but the '''OK''' button has "focus" so you can hit the '''Enter''' key to start printing.

  • How to get my Logitech Trackball to automatically move pointer to the default button in a dialog box while using Firefox?

    It does it for Internet Explorer but doesn't do it for me on Firefox.

    Dear partha,
    1) You can be able to trace out the location of the button
    2) You can be able to move the cursor to that location
    3) You can be able to automatically generate a click on that button
    Use user32.dll to achieve all this. when u use it in CLN(Call Library Node), u can c functions 4 that.
    Try and ask if further help needed!!!!!
    Thanks,
    Mathan

  • How do I remove the default buttons on the bookmarks toolbar?

    I hate the "Latest Headlines" and "Getting Started" and "Most Viewed" icons. I want to replace them with bookmarks of my choosing. I tried using the customize option but it didn't work. Is there an option to choose a different news site for the "Latest Headlines"?

    Never mind, figured it out! can delete it by going to Bookmarks>Organize> then highlight the unwanted link, go to Edit on Firefox toolbar, click Delete or Remove.

  • Automatically press the default button of dialog box

    Hello!
    I have macmini like mediaserver. But when internet is mising, or error when iTunes can't get album artwork it display dialog window. And i need conect to serve via VNC, and press "OK" Botton. What app can close this widnows avtomaticly? AppleScript?

    I have demons that synchronize automatically iPad/iPhone, if iPhone is not available in Wi-Fi network iTunes pops up an error. Demon that take artworks- when there is no internet, iTunes pops up error. There is problems that i can't fix, so i need program or script that will close dialog box. Like SteerMouse, but it don't press the botton

  • How to set a default button in a JFileChooser dialog?

    How do I set the default button in a JFileChooser dialog?
    Thanks in advance!
    Thomas

    public static JButton searchByText(Component comp, String[] texts) {
        if (comp instanceof JButton) {
            JButton btn = (JButton) comp;
            String text = btn.getText();
            for(int j=0; j<texts.length; ++j)
                if (text.equals(texts[j]))
                    return btn;
            return null;
        if (comp instanceof Container) {
            Container cont = (Container) comp;
            for(int j=0, ub=cont.getComponentCount(); j<ub; ++j) {
                JButton result = searchByText(cont.getComponent(j), texts);
                if (result != null)
                    return result;
        return null;
    }You can call this method, passing it your JFileChooser and:
    String[] approves = {"Open", "Save"};

  • Is there a way to change the defaulted (press 'Enter or Return on keyboard) button in a dialog box? Specifically,

    When the cookie preference is set to "ask every time" the default button (highlighted & selected when I hit return or enter) is "allow." Can I change the default button to "allow for session" so I don't have to use the mouse to select it?

    Your question/suggestion got me thinking about making a programmable function key (PFK), but I couldn't think how to make a PFK represent a mouse click. Then I tried the option [ ⌥ ] key (I don't have Alt [⎇ ] ) and the s, with or without the shift. I tried the command [⌘] key, and finally the control [⌃] key with the s — that's the one that worked. 8¬D
    I remembered scripting radio buttons, which might apply here, but it's been too long ago.
    Thank you for pointing me in a new direction, that will do well enough 'till I find out if the default button(s) can be changed in dialog boxes in general.

Maybe you are looking for

  • ESS roadmap button where is it in DC?

    Hi, I'm customising ESS addresses screen, I could see the detail, review, bizcard view layout screens using the NWDS where is the Review and Save buttons actions and their source code located? Is it at the addresses DC level or elsewhere? I want to c

  • Workflow 50000042- PCRs in MSS

    Hi All, We have some PCRs like Change in PA/PSA workflow used is 500000042. But i am not understanding to whom mail will go and where to set in config that mail should go to Line manager and HR. Please its very urgent.... Thanks

  • Messaging only: WCF-BasicHTTP adapter Request-Response correlation

    Hi, we have a solution where we make a soap web service call to a third party. we do not want to use orchestrations. we are in need to pass a value to the third party service and we would like to have that value passed back to us in the response. How

  • Weird color profile problem after SMC update

    Although I've managed to resolve this particular problem, I wonder if anyone has suffered the same thing. Software update says that I should do the firmware update, so I did that yesterday night. Also, at the same time, I went and removed MS Office 2

  • Differing levels of form security

    I have a certificate form that anyone should be able to open and print, but only certain people should be able to fill out (so people who receive the certificates can't go changing them and printing copies for all their friends). Both password and ce