Focus « Dialog « Java Swing Q&A





1. JDialog lets main application lose focus    stackoverflow.com

I wonder why my JDialog pushes my main application into background. That means if the JDialog will be shown and the user clicks "OK" or "CANCEL" the main application looses its ...

2. Put focus on JDialog    stackoverflow.com

I have class InfoDialog which extends JDialog class in Java. I show InfoDialog while I am establishing SSH connection ( 5 or 6 seconds ) with info text. How to put ...

3. removing focus from JDialog if main application is minimised    stackoverflow.com

I have a JDialog which popup whenever my main application recieves an event. The problem I'm facing is that the dialog pops up evenif the main window is minimised. A similar question ...

4. JDialog box not gaining focus    stackoverflow.com

I have a modeless dialog box being generated which prompts users to open a new window. The box can be opened in two ways, either directly from the file menu ...

5. Setting focus to a dialog button?    coderanch.com

Hi, I have a dialog window composed of two panels: a message panel with gridLayout(1,1), and a buttonsPanel with gridLayout(1,3). When the parent application instantiate the dialog with the message, it packs the dialog, and set its visibility to true, then "yesButton.requestFocus()" but the focus is always in the message panel! Could somebody provide any hint on this please? Thanks.

6. JDialog: How to set focus on second JButton?    coderanch.com

public class DialogTest extends JDialog { JButton ok = new JButton("OK"); JButton cancel = new JButton("Cancel"); public DialogTest () { super (); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("OK"); } }); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Cancel"); } }); getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER)); getContentPane().add(ok); getContentPane().add(cancel); getRootPane().setDefaultButton(cancel); cancel.requestFocus(); pack (); } }

7. Focus on JDialog lost    coderanch.com

It really *should* be working if you are passing in the owner correctly. Is something happening like your current class extends JFrame, but the actual visible JFrame is another JFrame instance? You can also try out the code below and see the differences between launching a dialog using the actual parent frame and other references. Just to make sure there are ...

8. JDialog Focus    coderanch.com





10. Focus problem with setModal in JDialog    coderanch.com

11. Focus problem: glasspane + dialog    coderanch.com

Hi, I have a problem in my application with focus handling. I am using a glass pane to prevent the user from interact with data while a lengthy process is running. So far, so good. However, if the process fails, I would like to display a warning dialog via JOptionPane.showMessageDialog. My problem is, that the "Ok" button in the dialog is ...

12. Focus on JPanel field inside a Confirm Dialog    coderanch.com

// anonymous subclass of JPanel to give focus to a text field JPanel panel = new JPanel( /* specify layout manager here if you wish */ ) { public void addNotify() { super.addNotify(); SwingUtilities.invokeLater(new Runnable() { public void run() { try { Thread.sleep(20); } catch(InterruptedException ignored) { } theTextField.requestFocusInWindow(); } } ); } };

13. showInputDialog( ) focus    coderanch.com

I have an application in which the user drags an object onto a canvas. When the drop occurs the drop target (canvas) executes the statement: data = JOptionPane.showInputDialog(...). The cursor is blinking in the dialog's text field, but the user has to click on the field (or the dialog window) before input is accepted. Is there a way to automatically set ...

14. No focus in JFrame fro JDialog    coderanch.com

15. No focus to Dialog box    coderanch.com

I'm developing a console application. But for better interaction I am using Information Dialog box with the following code: JFrame frame = new JFrame(); JOptionPane.showMessageDialog(frame, "Invalid Number.", "Error", JOptionPane.ERROR_MESSAGE); It works perfectly. But the problem is when the application is running when the Information Dialog Box appears for the first time it doesn't get the focus. I have to press ALT+TAB ...