Setting default button in JInternalFrame

hi
i had JInternalFrame screen which was added to an MDI Frame. when i am invoking my JInternalFrame screen from main menu, the default button is not working.
i have coded like this in JInternalFrame screen:
this.getRootPane().setDefaultButton(buttonOk);
can anybody pls help me regarding this?
thanx
sarabh.

try this
getRootPane().setDefaultButton(btnOK);
      FocusAdapter resetDefaultButton = new FocusAdapter() {
      public void focusGained(FocusEvent e) {
         JButton button = (JButton) e.getSource();
         getRootPane().setDefaultButton(button);
      public void focusLost(FocusEvent e) {
         getRootPane().setDefaultButton(btnOK);
      };he default button can be set by using: getRootPane().setDefaultButton( button );
However, the metal LAF and Windows LAF work differently once the default button has been set:
a) Metal - the default button never changes, even when another button gains focus.
b) Windows - when another button gains focus it becomes the default button. When you tab off this button, the original default button is never reset.
Hope this helps
Raheel

Similar Messages

  • How to set default button when press "Enter"

    Hi,
    I have a form and it has only one button (Submit). When I press "Enter", it can submit the form and do the action. However, when I add another button (Normal button, not submit), it cannot perform submit action directly when I press "Enter".
    If we press "Enter" and the form can submit automatically, it is more user-friendly than without this feature. Therefore, may I know the method of set the default button when users press "Enter"?

    At first I thought the order of the form controls might matter.  When I run this code:
    <cfdump var="#GetTickCount()#">
    <form action="TestCfgrid.cfm" method="post">
    <input name="x" type="text" />
    <input type="button" value="x" />
    <input type="submit" />
    </form>
    While I am in the text box, if I press the enter key the form submits.  I originally tried it with the submit and button inputs in the opposite order.
    Note that the enter button will not submit the form if you are in a select control (aka dropdown) or a textarea or if your focus is not on a form element.  That's the default behaviour.  If you want to override that, you'll have to write some javascript.

  • Set default Button and provide a KeyEvent to a component with focus !!!

    What is to do ???
    I have following program:
    public class DefaultButton extends Frame implements ActionListener
         private Button close;
         public DefaultButton()
              super("Default-Button");
              setLayout(null);
              setSize(400, 200);
              setLocation(150, 100);
              setBackground(Color.lightGray);
              addWindowListener(new WindowAdapter()
                   public void windowClosing(WindowEvent e)
                        setVisible(false);
                        dispose();
                        System.exit(0);
              // CloseButton
              close = new Button("Close");
              close.addActionListener(this);
              close.setVisible(true);
              close.setSize(100, 30);
              close.setLocation(290, 160);
              add(close);
              setVisible(true);
         public void actionPerformed(ActionEvent e)
              String cmd = e.getActionCommand();
              if (cmd.equals("Close"))
                   setVisible(false);
                   dispose();
                   System.exit(0);
         public static void main(String [] args)
              DefaultButton wnd = new DefaultButton();
    }If I click on "Close"-button, the window will be closed. But, if the button "Close" has focus, it schold be possibile to close the window with a press on the Enter-Key? How to do it? How can I provide an KeyEvent to button "Close"?
    Tanks for any help.

    Hi pitalica!
    It is possible using KeyListener:
    public class DefaultButton extends Frame implements ActionListener, KeyListener {
    close.addKeyListener(this);
    public void keyPressed(KeyEvent e) {
    if ((e.getSource() instanceof Button)
    && (((Button) e.getSource()).getActionCommand == "Close")) {
    int kc = e.getKeyCode();
    if (kc == KeyEvent.VK_ENTER) {
    performs any action
    public void keyTyped(KeyEvent e) {}
    public void keyReleased(KeyEvent e) {}
    I hope it helps.

  • Set Default Button Position

    In Question Slide buttons, is there a way to apply a position and size to 'all buttons of this type'?

    Thanks -- that worked.
    FYI, I did this within the template, too, but a new project based on
    that template reverted to the default settings for new question slides.
    I guess they're holding back that capability for the next version
    I appreciate your time.
    Jennifer Thomas
    Content Developer/Applications Specialist

  • Setting default button

    I have a JFrame which has many controls like jbutton, jtextfield, jtextpane. I want whenever i press enter key. one JButton is pressed irrespective of the fact whether that jbutton has focus or not. e.g . in any windows application when enter key is pressed, default OK button is pressed even it has not focus.

    frame.getRootPane().setDefaultButton(okButton);

  • How to set default button?

    How can make a button so when I press enter, the button is activated?

    Note: This thread was originally posted in the [New To Java|http://forums.sun.com/forum.jspa?forumID=54] forum, but moved to this forum for closer topic alignment.

  • Set default warehouse

    Hi, everybody!
    I want to find the filed that store information about default WH when i click +set default button+. that make type bold warehouse name and warehouse code.
    Thank you!

    its in OITM
    the field is called DfltWH
    if you're happy ...
    regards
    David

  • 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"};

  • 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

  • Setting default alert button at runtime

    Setting default alert button at runtime
    Sometime I want Button1 to be default and sometimes I want Button2 to be default.
    Please tell me how to change the default button at runtime.
    Thanks
    Claus Hansen [email protected]

    Beware of a slight bug in at least some versions. If the user dismisses the alert using the [X] close window control it fires a particular button which is not neccesarilly the default one. I always ensure that I make the default button the one which the control fires.

  • Default button is lost when JInternalFrame is iconified

    Hello, everybody!
    Have you already noticed that the default button is lost (loses its characteristics) when the JInternalFrame is iconified? Is there any workaround for this?
    Thank you.
    Marcos

    camickr wrote:
    So you already have a solution from the bug posting.No, because in my case the default button can change over time in the JInternalFrame. If it was fixed I could use the solution in the bug posting. Anyway I found a workaround in my case. I'm using an hierarchy listener to restore the default button. The code in the hierarchyChanged method below is called when the JInternalFrame is deiconified:
    @Override
    public void focusGained(FocusEvent e)
        getRootPane().setDefaultButton(_btnPesquisar);
        _focalizado = true;
    @Override
    public void focusLost(FocusEvent e)
        getRootPane().setDefaultButton(null);
        _focalizado = false;
    @Override
    public void hierarchyChanged(HierarchyEvent e)
        if (_focalizado && (e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0 && isDisplayable())
            getRootPane().setDefaultButton(_btnPesquisar);
    }I just would like to know, as this is a long standing bug, if a more elegant solution was found.
    Marcos

  • Ebusiness tax Rule setup - Set default rule button is disabled

    Hi All
    In ebusiness tax rule setup - Tax rule default values are not able to set. I cannot able to access the set default.
    set default value is disabled. can anyone help me know , how i can enabled button set default value in
    Tax Rules
    Thanks
    Venkatesan

    Pl ensure that you have defined all required default values set up. Ex Tax, Tax Status, Tax Jurisdiction, Tax Rate etc.

  • How to set default custom button in af:popup

    Hi,
    I am using JDeveloper 11.1.2. I have popup. In that there are two input fields and one custom button called "Login". At runtime after the popup is been launched , while pressing Enter key it needs to trigger the "Login" button. If I use *<af:subForm>* in jsff file, the default is getting triggered. Apart from <af:subform> Is there any way to trigger default button at runitime?
    Thanks & Regards,
    Praveen.

    You can use an af:dialog of type ok/cancel for your popup. If you hit enter it'll work like the OK button is clicked. In a dialoglistener you can destinguage all other buttons or ESC.
    Check out http://jdevadf.oracle.com/adf-richclient-demo/docs/tagdoc/af_dialog.html and http://www.oracle.com/technetwork/developer-tools/adf/learnmore/77-ok-cancel-support-in-dialog-351871.pdf for a sample.
    Timo

  • How to set default file path while downloading alv output

    Hi,
    Can anyone tell me that how to set default file path while downloading the ALV output to system using Local file button on tool bar.
    Please look below screenshots:
    Kindly help me resolve it.
    Thanks in advance.
    Regards,
    Ashutosh Katara

    This information initial value is (maybe) stored in Windows Register (register.exe) at Software\SAP\SAPGUI Front\SAP Frontend Server\Filetransfer -> PathDownload, you can read it thru class CL_GUI_FRONTEND_SERVICES method GET_UPLOAD_DOWNLOAD_PATH and update it thru method REGISTRY_SET_VALUE. (Else there may be some parameter ID to force data, but I'm no longer sure)
    Regards,
    Raymond

  • Default buttons not defaulting

    Hello. I am on the tail end of a DVD project and just begain encountering some unusual behavior with certain menus. This is a multiple-menu, multiple-video clips promotional DVD.
    Up to last week, the DVD has been working as expected in the simulator, in DVD Player (from the Video_TS folder and from a formatted disc), and in several set top players. Yesterday, though, in DVD Player from a formatted disc, the menus appear with no buttons visibly defaulted. The menu still behaves, though, as if the default button was selected (ie., if pressing "enter" activates the default button, and pressing an arrow button sends the selected state in the designated direction.) Each video asset returns to its menu with another default button, and these behave in the same way.
    I have already double-checked the connections between the buttons, menus, and videos, and they are set the way they have always been.
    - Can the preferences in DVDSP get corrupted (like they can in FCP)?
    - Can the DVDSP porject file become "bloated" or corrupted from going through too many revisions? If so, is there an easy way to put the current project into a new file?
    I expect that some people that view this disc will do so on a Mac, and I would like to clear this up if it is possible. Any ideas?
    Thank you!
    Listening,
    Aaron Kruse
    PowerMac G5, Dual 2GHz   Mac OS X (10.4.6)   3GB RAM, FCStudio 5.0 (DVDSP 4.0.3), Logic 7.2

    Aaron:
    I would try deleting all PAR and MPEG folders that DVDSP created during your authoring (inside the folders where your source files live) and make a clean build without reusing any of the previous VIDEO_TS folders. Probably some file is corrupted. If you want a FCP analogy, is like deleting your render files!
    Trashing preferences is a common preocedure . . . but like in FCP, ussually don't resolve problems. But it's like an aspirin, it will don't hurt your system. You can keep a copy of the pref file to restore in case you need.
    You could repair permissions and restart . . . just to be sure everything is cleaned in your system.
    I would try deleting all PAR and MPEG folders that DVDSP created during your authoring (inside the folders where your source files live) and make a clean build without reusing any of the previous VIDEO_TS folders.
    Probably with the specific experience in your problem psot something in the meantime!
    Hope it helps!
      Alberto

Maybe you are looking for

  • Cash Discount at header is not reducing line item price

    Hi Experts, While putting cash discount at header, it is not reducing price of the my total line item. I am having total line item price = 100 USD (10 USD * 10 Qty). I am entering 10 USD as cash discount at header. It is not reducing total line item

  • IMovie on ipad Mini export issues

    Does anyone else often get the pop up saying an error has occurred or that their video does not export? I'm trying to save to my camera roll a short 15 second time lapse with a song in the background, but when I try to export the movie it looks as if

  • Cloning from solaris 10 to solaris 10  RC-50013: Fatal failed to intantiate

    while cloning from solaris 10 to solaris 10 RC-50013: Fatal failed to intantiate Driver /applprod/oracle/prddb/9.2.0/appsutil/driver/instconfig.drv

  • Column headings in Hierachical-Sequential ALV

    Hi Friends, I'm trying to display a Hierarchical-Sequential by: 1. Using the class 'cl_salv_hierseq_table' and method 'factory' to create the binding. 2. Using the method 'display' to display the report. The issue I'm facing is that the column headin

  • Need help connecting to the Wii

    My sons just got the Wii and cannot get connected to the internet. Before I started messing with the Airport Admin Utility, it was at least detecting the access point but just not connecting. But now I can't even get it to detect the access point. I