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

Similar Messages

  • Wrong default button in alerts when using 64-bit JRE on Windows

    Hi guys,
    I'm facing a strange problem.
    My environment:
    Server:
    OAS 10.1.2.2.0 on Linux Suse (32-bit)
    Client:
    IE8 64-bit on Windows XP 64-bit and Java 1.6.0_18 also 64-bit
    When I run a form that opens an alert-window with a default-button (button that has the focus), it sometimes happens, that not the default-button, but another button is activated by default.
    I have to repeat:
    It only happens sometimes and is hard to reproduce. Within 50 attempts it may happen 5 times or just 1 time.
    I never saw that happening with 32-bit JVM.
    Anyone else seeing this?
    br
    Michael

    Ok... here is what I see:
    1. Create a form with an alert and set button 2 as the default
    2. Run the form and display the alert. Button 2 has focus (proven by the bold solid line (shadow) and dotted line that surround the button)
    3. Open any other app (Notepad, Explorer, etc) and move focus to that app
    4. Slide this other app out of the way so that you can see the running form under it.
    5. While the other app has current focus, the buttons on the form's alert appear to lose focus (this is expected). However, now button 1 has a bold line (shadow) surrounding it. This gives the appearance that button 1 has focus.
    6. Click on the alert box to move focus back to the form. Do not click on the alert buttons.
    7. Focus lines are now redrawn on the correct button (button 2).
    This is probably not the best behavior, but certainly not something that I would call an area of concern. If what I described here is what you are seeing and you feel that this is a significant issue, I would recommend filing a Service Request with Support (assuming you have a support contract) and request that a bug/defect is filed. You will need to provide a test case and I would recommend that you provide screen shots or a video of what you are seeing. If you have not already applied all the previously mentioned patches, I would not recommend contacting Support until you do so, as this will be the first thing they require you completed anyway.

  • 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

  • Default button being clicked multiple times when enter key is pressed

    Hello,
    There seems to be a strange difference in how the default button behaves in JRE 1.4.X versus 1.3.X.
    In 1.3.X, when the enter key was pressed, the default button would be "pressed down" when the key was pressed, but wouldn't be fully clicked until the enter key was released. This means that only one event would be fired, even if the enter key was held down for a long time.
    In 1.4.X however, if the enter key is pressed and held for more than a second, then the default button is clicked multiple times until the enter key is released.
    Consider the following code (which is just a dialog with a button on it):
    public class SimpleDialog extends JDialog implements java.awt.event.ActionListener
    private JButton jButton1 = new JButton("button");
    public SimpleDialog()
    this.getContentPane().add(jButton1);
    this.getRootPane().setDefaultButton(jButton1);
    jButton1.addActionListener(this);
    this.pack();
    public void actionPerformed(ActionEvent e)
    if (e.getSource() == jButton1)
    System.out.println("button pressed");
    public static void main(String[] args)
    new SimpleDialog().show();
    When you compile and run this code under 1.3.1, and hold the enter key down for 10 seconds, you will only see one print line statement.
    However, if you compile and run this code under 1.4.1, and then hold the enter key down for 10 seconds, you will see about 100 print line statements.
    Is this a bug in 1.4.X or was this desired functionality (e.g. was it fixing some other bug)?
    Does anyone know how I can make it behave the "old way" (when the default button was only clicked once)?
    Thanks in advance if you have any advice.
    Dave

    Hello all,
    I think I have found a solution. The behaviour of the how the default button is triggered is contained withing the RootPaneUI. So, if I override the default RootPaneUI used by the UIDefaults with my own RootPaneUI, I can define that behaviour for myself.
    Here is my simple dialog with a button and a textfield (when the focus is NOT on the button, and the enter key is pressed, I don't want the actionPerformed method to be called until the enter key is released):
    package focustests;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;
    public class SimpleDialog extends JDialog implements java.awt.event.ActionListener
    private JButton jButton1 = new JButton("button");
    public SimpleDialog()
    this.getContentPane().add(new JTextField("a text field"), BorderLayout.NORTH);
    this.getContentPane().add(jButton1, BorderLayout.SOUTH);
    this.getRootPane().setDefaultButton(jButton1);
    jButton1.addActionListener(this);
    this.pack();
    public void actionPerformed(ActionEvent e)
    if (e.getSource() == jButton1)
    System.out.println("button pressed");
    public static void main(String[] args)
    javax.swing.UIManager.getDefaults().put("RootPaneUI", "focustests.MyRootPaneUI");
    new SimpleDialog().show();
    and the MyRootPaneUI class controls the behaviour for how the default button is handled:
    package focustests;
    import javax.swing.*;
    * Since we are using the Windows look and feel in our product, we should extend from the
    * Windows laf RootPaneUI
    public class MyRootPaneUI extends com.sun.java.swing.plaf.windows.WindowsRootPaneUI
    private final static MyRootPaneUI myRootPaneUI = new MyRootPaneUI();
    public static javax.swing.plaf.ComponentUI createUI(JComponent c) {
    return myRootPaneUI;
    protected void installKeyboardActions(JRootPane root) {
    super.installKeyboardActions(root);
    InputMap km = SwingUtilities.getUIInputMap(root,
    JComponent.WHEN_IN_FOCUSED_WINDOW);
    if (km == null) {
    km = new javax.swing.plaf.InputMapUIResource();
    SwingUtilities.replaceUIInputMap(root,
    JComponent.WHEN_IN_FOCUSED_WINDOW, km);
    //when the Enter key is pressed (with no modifiers), trigger a "pressed" event
    km.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ENTER,
    0, false), "pressed");
    //when the Enter key is released (with no modifiers), trigger a "release" event
    km.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ENTER,
    0, true), "released");
    ActionMap am = SwingUtilities.getUIActionMap(root);
    if (am == null) {
    am = new javax.swing.plaf.ActionMapUIResource();
    SwingUtilities.replaceUIActionMap(root, am);
    am.put("press", new HoldDefaultButtonAction(root, true));
    am.put("release", new HoldDefaultButtonAction(root, false));
    * This is a copy of the static nested class DefaultAction which was
    * contained in the JRootPane class in Java 1.3.1. Since we are
    * using Java 1.4.1, and we don't like the way the new JRE handles
    * the default button, we will replace it with the old (1.3.1) way of
    * doing things.
    static class HoldDefaultButtonAction extends AbstractAction {
    JRootPane root;
    boolean press;
    HoldDefaultButtonAction(JRootPane root, boolean press) {
    this.root = root;
    this.press = press;
    public void actionPerformed(java.awt.event.ActionEvent e) {
    JButton owner = root.getDefaultButton();
    if (owner != null && SwingUtilities.getRootPane(owner) == root) {
    ButtonModel model = owner.getModel();
    if (press) {
    model.setArmed(true);
    model.setPressed(true);
    } else {
    model.setPressed(false);
    public boolean isEnabled() {
    JButton owner = root.getDefaultButton();
    return (owner != null && owner.getModel().isEnabled());
    This seems to work. Does anyone have any comments on this solution?
    Tjacobs, I still don't see how adding a key listeners or overriding the processKeyEvent method on my button would help. The button won't receive the key event unless the focus is on the button. There is no method "enableEvents(...)" in the AWTEventMulticaster. Perhaps you have some code examples? Thanks anyway for your help.
    Dave

  • Changing Default Button in Pop-Up Message When Deleting a Song

    When deleting a song from iTunes, a message pops up asking, "Do you want to move the selected songs to the Trash, or keep them in the iTunes Music folder?" The user has the option of selecting Cancel, Keep Files or Move to Trash. Keep Files is highlighted blue and is the default button if one presses Return. Is it possible to make Move to Trash the default button?

    The reason Keep Files is the default button is so you don't accidently trash a file by hitting the return button. I think all of the dialogue boxes in Mac OS are that way– better safe than sorry. However, Its probably possible to change it in either Terminal or accessing the localizable.strings file in the iTune app file.

  • 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.

  • Called transaction (authorisation default) lost when breaking parent link

    Hi
    Been a googling for this one and I'm still stuck.
    One for techies I guess?
    We are on ECC^ release702 support pack SAPKB70212
    I've broken the link between parent and derived roles where cost centre objects are present (these are brand new roles created using option three in expert mode when generating)
    Then I notice that the transactions hidden from the user menu by inserting using the option authorisation default have been lost - just their description remained so I tested this by creating a parent role with just a called tcodes in it, deriving a new role off it and then deleting the link.
    The menu is lost and the authorisation object S_TCODE is lost when using the third option to generate. The history shows the transaction being deleted but this doesn't happen for normally assigned transactions in  the menu.
    Anybody got any ideas please?
    One other thing is that it also lost the folder name probably because I had not included any normal transactions?
    Kind regards
    David

    Hi Julius
    Yep - already tried this as I found that some existing roles had lost their called tcode technical name so I built a new role from scratch with FB03 as the called transaction, derived from it and then broke the link to the first role leaving the derived being a straightforward single role.
    It immediately had a red menu tab since FB03 was the only entry.
    Going into the authorisations with option 3 edit old and merge new removed the associated authorisations including the S_TCODE.
    I then tried again with a new role having both a standard menu transaction and called transaction and it repeated the actions but left the standard transaction intact.
    I had a wander through the SSM_CUST to see if there was a flag/setting mentioning delete authorisation defualt transaction if breaking the derived-parent links but didn't see anything apart from the usual ones about compressing menus etc which don't look to be affecting it.
    Thanks for your time to date but I think it's one for SAP now?
    Kind regards
    David

  • Focus loss? bad modality? wrong default buttons?

    Hi Fort&eacute; Users,
    Can I ask if anyone has experienced any of the following problems?
    We are using Fort&eacute; 3.0.G2 on NT4.0 SP3 using Compaq Deskpro PCs.
    1. Occasionally, the modality is lost when a modal child window is
    displayed for the first time.
    2. Sometimes the closing of a child window doesn't correctly return the
    focus to the parent window. This may be related to using the keyboard to
    "click" the default button rather than actually clicking with the mouse, but
    I'm not sure of that.
    3. Also the default button is set correctly when a child window closes,
    but the window indicates that a different button is the default button. The
    highlighting is on the wrong button.
    All these problems happen in both distributed and standalone runs.
    I ask because I don't want to waste time with Fort&eacute; Support if they aren't a
    generic problem.
    Thanks,
    Nick.
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Troubleshooting Update:
    If I first import my project using the RH7 WYSIWYG as default
    editor, the Russian ToC is produced. I can then change the default
    editor, (say, to Word2003 or FrontPage) and the Russian ToC is then
    preserved. Very strange!
    That still leaves a css problem. On import of a Word file,
    the styles belong to some unknown (default?) stylesheet, and
    editing and correcting is an intolerable job. Why is the Word
    template not being imported to become the RH7 topic template?
    Your assistance much appreciated.

  • I had my Ipod touch 4gen on itunes of computer that crashed. On new computer i updated it, hit the wrong button, and lost everything. How do i get my old songs, apps, and account money back?

    I had my ipod 4gen itunes on a computer that crashed. With the new computer I update it to the lastest version. I hit the wrong transfer button and lost everything. How do I get my old songs, apps, and money back from my old account, if thats possible?

    I cant find any of my recently bought songs or the apps i have purchased. When I was updating my ipod there was a button that asked about transfering purchases and I didnt read it, and I didnt update manually so i think thats why i lost everything. I clicked on the intrustions and clicked on apps and i coulnt find any of my old stuff.

  • 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

  • My Firefox start page had a check box for searching Canadian pages which was lost when I upgraded to 4.0. How can I get this back?

    My Firefox start page had a check box for searching Canadian pages which was lost when I upgraded to 4.0. How can I get this back?

    The default about:home page in Firefox 4 doesn't give such features. You can set the home page to http://www.google.ca to get that possibility. The results page has a "Pages from Canada" link in the side menu at the left.

  • Default button in BOV should always be #1

    I have a number of Tracks with button overlay in a subtitle stream and Button Highlight activated (cyan/yellow marker).
    The buttons are used to change audio stream during playback.
    From a menu with 6 buttons I select a Track:
    Button 1 = Track 1
    Button 2 = Track 2
    and so on.
    What happens when I play the Track(s) is this:
    Track 1 > Button 1 selected
    Track 2 > Button 2 selected
    Track 3 > Button 3 selected
    etc.
    Is it possible to always select button #1 when starting to play a Track, no matter which menu button was used?
    As it is now, the user gets confused, since the Track is setup to play audio stream 1 in a pre-script (and this works fine).
    TIA
    Message was edited by: Niklas Wikman

    Problem solved. Double-click on the subtitle in the Track and set the Default button in the Button tab in the PI.

  • 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

  • Default Buttons

    Hi,
    I've got a simple application that needs a custom "search" dialog.
    I've created a subclass of JDialog and it comes up just fine...
    Basically I have a JTextField for them to put in the search, a few checkboxes for the options, and two buttons at the bottom of the dialog. The buttons are named "find first" and "find next."
    I've seen in many programs that when a dialog comes up and has several buttons, i.e. "yes"/"no", then often it will have one of them selected for you and if you hit [enter] it'll just activate that one. I would like to do this to my "find next" button, but am not sure how to do so.
    How do I make my "find next" button be the default for the dialog?
    Right now, I have an ActionListener set up on the text field so that if a user hits [enter] in the search box, the "find next" is activated. I think that this isn't the right way to go, though, since the text box has to be focused.
    Thanks,
    Jared

    I add this code in the constructor of the JDialog to support a default button when no button has focus. (Note. when a button has focus it automatically becomes the default button)
    getRootPane().setDefaultButton( findNextButton );
    FocusAdapter resetDefaultButton = new FocusAdapter()
         public void focusLost(FocusEvent e)
              getRootPane().setDefaultButton( findNextButton );
    replaceButton.addFocusListener( resetDefaultButton );
    replaceAllButton.addFocusListener( resetDefaultButton );
    closeButton.addFocusListener( resetDefaultButton );

  • Cursor becomes invisible in JTextField after using default button

    In my application there is an update screen (JPanel). I am using default button in that panel. The input field is a normal JTextField. When the update is over the cursor goes back to the input JTextField.
         Now my problem is that when I carry out update with mouse, the cursor is correctly placed into the input JTextField and is visible after the update is over. On the other hand, if I carry out the same update operation using default button (using keyboard), the cursor gets placed correctly in the input JTextfield column, but becomes invisible. If I minimize and then again maximize the window, the cursor appears back. What am I missing ? Note that I am using component.requestFocusInWindow() to get focus back to the input JTextField.
    regards,
    nirvan

    While trying to reproduce the behaviour for SSCCE, I found that it is the JOptionPane.showMessageDialog() that is causing the problem. Here is the SSCCE.
    package com.ns;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.WindowConstants;
    public class TestFocus extends javax.swing.JFrame {
        // Variables declaration - do not modify
        private JTextField field1;
        private JTextField field2;
        private JPanel jPanel1;
        private JButton reset;
        private JButton update;
        // End of variables declaration
        public TestFocus() {
            initComponents();
            setDefaultButton();
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
            jPanel1 = new JPanel();
            field1 = new JTextField();
            field2 = new JTextField();
            update = new JButton();
            reset = new JButton();
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            field1.setPreferredSize(new Dimension(40, 20));
            jPanel1.add(field1);
            field2.setPreferredSize(new Dimension(40, 20));
            jPanel1.add(field2);
            update.setText("Update");
            update.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    updateActionPerformed(evt);
            jPanel1.add(update);
            reset.setText("Reset");
            reset.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    resetActionPerformed(evt);
            jPanel1.add(reset);
            getContentPane().add(jPanel1, BorderLayout.CENTER);
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-385)/2, (screenSize.height-258)/2, 385, 258);
        }// </editor-fold>
        public void setDefaultButton(){
            this.getRootPane().setDefaultButton(update);
        private void updateActionPerformed(ActionEvent evt) {
            // TODO add your handling code here:
            JOptionPane.showMessageDialog(this,"Activity Updated Succesfully in Database.",
                                            "Information",
                                            JOptionPane.INFORMATION_MESSAGE);
            update.setEnabled(false);
            field1.setEditable(false);
            reset.setEnabled(true);
            this.getRootPane().setDefaultButton(reset);
        private void resetActionPerformed(ActionEvent evt) {
            // TODO add your handling code here:
            field1.requestFocusInWindow();
            field1.setText("");
            field1.setEditable(true);
            reset.setEnabled(false);
            update.setEnabled(true);
            this.getRootPane().setDefaultButton(update);
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new TestFocus().setVisible(true);
    }If I remove the JOptionPane.showMessageDialog() method, everything works fine with mouse as well as keyboard.
    regards,
    nirvan.

Maybe you are looking for

  • Delete data from infocube which is older than 7 days.

    Hi Gurus, I have a Cube with the time dimension characteristic as 0CALDAY. This cube gets data from a DSO ,which has 0calday as one of its key fields, in Delta mode. I am in a need to delete the data with calday in the previous week. i.e SY-DATUM - 0

  • Getting first and last day of week

    Dear all . Is there any funcion module which gives first and last day of the current week . Eg . todays day is 15.11.2006 start date of week : 13.11.2006 end date of week : 19.11.2006 in the same way I want how many days are there in month . Eg : for

  • SQL1139n The total size of the table space is too big.

    Hi Our R3 QA system runs on Solaris 10, using DB6 822. We have now run into a problem, where we cannot extend a table. It is 66GB in size. Because the page file size is 8 kb, the limit is apparently 64 GB (we got it to 66GB). It seems we will have to

  • F.01 Difference with GL Account

    Hi All, Can any one help for finding the difference between F.01 & GL Account Balance.As I am getting this difference for my closed period. GL Account shows NIL balance whereas F.01 shows balance in that particular account,specifically for Excise Acc

  • Customizing ESS Business Package using Web Dynpro

    Hi Does anyone know how we can customize the ESS Business Package using web dynpro. I tried opening one of its application but since it doesn't carry any .project file, it cannot be opened in the NWDS for customization. Also, if there is any document