Close « Dialog « Java Swing Q&A





1. Swing: how do I close a dialog when the ESC key is pressed?    stackoverflow.com

GUI development with Swing. I have a custom dialog for choosing a file to be opened in my application; its class extends javax.swing.JDialog and contains, among other components, a JFileChooser, which can ...

2. Programatically closing currently displayed Java Swing JDialog box    stackoverflow.com

Hi there I am working on an Java Swing application that performs a search on a database. It has 2 JDialog boxes that popup during the search. The first tells the user ...

3. Can I set a timer on a Java Swing JDialog box to close after a number of milliseconds    stackoverflow.com

Hi is it possible to create a Java Swing JDialog box (or an alternative Swing object type), that I can use to alert the user of a certain event and then ...

4. Programmatically close a JDialog    stackoverflow.com

Is there a way to close a JDialog through code such that the Window event listeners will still be notified? I've tried just setting visible to false and disposing, but neither ...

5. java wait for dialog to be closed    stackoverflow.com

i have a small program where an element is draged and dropped, when the drop is performed i open a dialog (extends Jframe) where some text should be entered. The Problem ...

6. How to close a modal JDialog when user clicks outside of JDialog?    stackoverflow.com

I have a Undecorated Modal JDialog which I want to setVisible(false) when the user clicks outside of the modal dialog. Is this possible in Swing? What I am doing is popping up a ...

7. how to know if JDialog is closed or not?    stackoverflow.com

I have used a JDialog to display a form ( I could have used JFrame, but I have my reasons). There is an event in my application that will cause a ...

8. How to enable ESC-Close for an JPopupMenu, if the underlying window closes on ESC?    stackoverflow.com

Imagine two common situations combined: A JDialog(or JFrame) which closes on VK_ESCAPE (set as key binding on the root pane) and an inner JPopupMenu which is supposed to close on ESC ...

9. Swing modal dialog refuses to close - sometimes!    stackoverflow.com

// This is supposed to show a modal dialog and then hide it again. In practice,
// this works about 75% of the time, and the other 25% of the time, the ...





10. What is the right action to take upon closing JDialogs?    stackoverflow.com

I just wrote this test code in my CustomUIPanel class:

public static void main(String[] args) {
    final JDialog dialog = CustomUIPanel.createDialog(null, 
       CustomUIPanel.selectFile());
 ...

11. Adding a message box to a Java program that opens and closes at a certain point    stackoverflow.com

I was able to figure out getting input from the user and displaying the final product by myself, but I would like to add a "busy" message that displays at a ...

12. JDialog Close Icon Query?    stackoverflow.com

I would like remove the close icon present in the JDialog Option. How can I Achieve this? Requirement: Trying to re-design the default Dialog Structure by removing the 'x' or close icon Thank ...

13. Close application from task-bar when a modal dialog is opened    stackoverflow.com

When a modal dialog is opened, is there any way to allow user close a JFrame by clicking Close on task-bar icon? I see that even if the dialog is orphan ...

14. Make a JDialog stick or snap to another one when moving it close to it    stackoverflow.com

I'm trying to reproduce a feature I've seen on several apps: I have a GUI app with several JDialogs. I'd like to easily organize them tightly on screen: when I move one JDialog, and ...

15. Button for closing a JDialog    stackoverflow.com

I want to add a button (JButton) at the bottom of a JDialog which should close the JDialog when pressed. The problem is I don't know what to write in the ...

16. Closing a java program properly when JDialog is the main window    stackoverflow.com

I have a JDialog as the main window in my application (originally it was a JFrame but it showed in the taskbar which I didn't want). Currently I am doing:

setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
and ...





17. Java beginner: pattern to track object properties changes in dialog box (save prompt on dialog close)    stackoverflow.com

There is some entity:

public class Entity
{
  private String name;

  public String getName()
  {
    return name;
  }

  public void setName(String name)
  {
  ...

18. Counter to Close JFrame, bring up Confirm Dialog    stackoverflow.com

This post relates to my last one regarding a timer. I decided the easiest thing to do for immediate results was to just write a Counter thread that counts down from ...

19. Java listener on dialog close    stackoverflow.com

I have a Java app that displays a list from a database. Inside the class is the following code to open a new dialog for data entry:

@Action
public void addNewEntry() {
  ...

20. Why can't java close properly even though I'm using dialog.dispose()?    stackoverflow.com

I tried looking high and low for a solution to a similar problem, but it's sort of too generic to find. I'm posting the full code below, but basically I ...

21. Swing Dialog/Optionpane event handling: Optionpane closes parent frame in modal mode?    stackoverflow.com

In the constructor of a JFrame Mygraph i invoke some work (retrieving remote data for a graph and painting it) to be done via invokeLater in the constructor:

SwingUtilities.invokeLater(doWorkRunnable);
This is all fine, ...

22. wait for jdialog to close    stackoverflow.com

I have a class FilePathDialog which extends JDialog and that class is being called from some class X. Here is a method in class X

    projectDialog = new ...

23. How do I close a JDialog window using a JButton?    stackoverflow.com

I've tried a bunch of different ways to close the window, but since you can't send additional parameters to to Action Listener method I can't dispose the frame due to a ...

24. [SOLVED] XML Warning after jDialog closed    forums.netbeans.org

Hi, I tried a Linux Mint, Ubuntu 10.04 or others distributions with GNOME. I have a problem with jDialogs. Dialogs no member own position state and after closing generated XML error ...

25. how to close a JDialog with escape using netbeans    forums.netbeans.org

Hi, I have this app where a configuration jdialog can be opened. I want it to close when escape-key is pressed. I found out how to do this (http://www.javaworld.com/javaworld/javatips/jw-javatip72.html), but not how to do it in the netbeans GUI designer. I'm guessing it's something in the JDialog properties panel under Events>keyReleased, but everything i tried does not work. Can anyone explain ...

26. closing a JDialog box    coderanch.com

27. actionPerformed to close dialog    coderanch.com

First, use the getSource() method of ActionEvent, to get the Button ( or other Component ) that caused this ActionEvent. Then, use the getParent() method of the Button ( inherited from Component ) to return the container that this Button is in... you may want to put this in a loop until you can't get a parent anymore... if a Button ...

28. JDialog Box closes main application    coderanch.com

Hi. I am trying to create a JDialog box that prompts users to log on to a database before they can do anything else with the main application. For some reason, whenever I click on the "X" on the JDialog box I created, it closes the main application also. Could someone take a look at my code and see what I'm ...

30. closing JDialog when focus is lost    coderanch.com

31. Strange problem, closing dialogs    coderanch.com

In my application I use JmenuBar and JmenuItems and a class adapter for event handling //Help | About action performed public void jMenuHelpAbout_actionPerformed(ActionEvent e) { myApp_AboutBox dlg = new MyApp_AboutBox(this); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); } and ...

32. Auto close of MessageDialog??    coderanch.com

Hi all friends, I want that my first Dialog should close automatically when my next Dialog pop up.My application requirement is i want to show two types of dialog one is when my work is going on "Please wait.." and another is when my work has beeen completed confimation message "Work has been completed".I want that when my work has beeen ...

33. How to disable JDialog close window button?    coderanch.com

Hi Folks, I have a JProgress Bar inside a Jdialog box, which has the close window button. I want to disable the close window button when the progress bar is progressing!. ie I want to discolor it ideally(grey color). How to do that? Any suggestions, NOTE: DONOTHING_ON_CLOSE,HIDE_ON_CLOSE,EXIT_ON_CLOSE is not the required solution. Pls Reply ASAP, TAI, Murali

35. JDialog - remove close option    coderanch.com

36. JFrame not repainting when overlayed JDialog is closed    coderanch.com

If you've called wait() in an event handler, then the thread that would be doing the repainting is blocked waiting for wait() to return. Swing uses just one thread to do both painting and event handling. You should never, ever call wait() or do anything else time consuming in an event handler for this very reason. The right thing to do ...

37. close option in JDialog    coderanch.com

38. Closing a dialog in Swing?    coderanch.com

40. Closing a dialog box    coderanch.com

41. why no default close button in JDialog    coderanch.com

42. Setting cursor after a dialog closes    coderanch.com

Hello, I am experiencing problems trying to change the cursor. My code first opens a JFrame, then a modal dialog is opened hiding a part of my JFrame and finally some long task is performed after the dialog closes. I'd like to set a wait cursor on my JFrame before starting the long task but the modal dialog thing seems to ...

43. How to create is Dialog or JDialog without close button?    coderanch.com

Although i am no expert and dont have an answer for you.What these other kind folks are suggesting could post an iriatbility issue with the user.Meaning that if they see the "x" there to close the window but when the user clicks it nothing happens, i think users will get pissed off. I'm actualy looking to find out how to manipulate ...

44. Close a JDialog?    coderanch.com

45. JDialog without close button    coderanch.com

47. closing a JDialog    coderanch.com

the part creating the extra taskbar item is caused by the code in addCust going around in circles i.e. you seem to be creating a separate dialog/frame within the dialog itself, instead of using the class as a dialog (extends JDialog) a couple of changes in mainFrame 1) starting at line 587 class AddListener implements ActionListener { public void actionPerformed(ActionEvent e) ...

48. close the error dialog using space bar.    coderanch.com

I Created a Frame and a customised dialog box. if some of the fields in dialog box is empty i am throwing a JOptionpane dialog with a error message . The probelm is while throwing the error dilaog the focus is on the OK button but still it doesnt closing while i'm pressing the space bar. how to close the error ...

49. Closing a Dialog Box after a certain time.    coderanch.com

Hi, In my eclipse plugin, what i am trying to do is ask a user if he / she wished to perform an activity through a dialog box. Also, if there is no response from user for say about 3 minutes, I want to perform the activity and close the dialog. I tried doing the above as follows, My main thread ...

50. Closing dialog box using windows listener    coderanch.com

hi i have the following situation: The user clicks a button and a dialog is displayed showing the status of the computations that it is undergoing in the background. It is an iterative step. I would like to add a feature where i will have to close the dialog and stop the execution of the computations on clicking the 'X' button ...

51. closing a JDialog with a button    coderanch.com

moin, i have a problem with the following code: package testen; import java.awt.event.*; import javax.swing.*; public class ProbDialogClose { static JFrame f = new JFrame("test"); static JDialog dialog = new JDialog( f, true ); ProbDialogClose() { f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); f.setVisible( true ); showWelcomeMessage(); } private void showWelcomeMessage(){ JDialog dialog = new JDialog( f, true ); dialog.setSize( 450, 400 ); dialog.setLayout(null); JButton ...

54. Swing - Parent window goes back on closing the model dialog    coderanch.com

Hi, I have application which will show the model dialog in the middle of the operation. In that, once I close the model dialog the main application is going back to other applications opened in my machine. My Sample Code import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; public class ABCDEF extends JFrame implements ActionListener { private JButton btnStart; ...

55. jdialog closing event.    coderanch.com

56. JDialog not closing on 1st click    coderanch.com

the problem is here newEvent = new NewEventForm(cg); newEvent.requestFocus(); newEvent.setVisible(true); NewEventForm is a modal dialog, so the requestFocus and setVisible lines are not executed until the dialog closes, then, when closed, setVisible(true) is executed. remove those requestFocus and setVisible lines and it should work OK. [edit] forgot to add that NewEventForm contains a setVisible(true) in it's constructor

57. Forcibly closing all open dialogs on an Applet    coderanch.com

Hi All, Had a query-- if we can forcibly close all the open dialogs on an Applet. Googled about it but did not get any easy way to do it. Actually I want to do this because my applet can logout due to many reasons, one of which is network failure, which can occur to a background thread, in this case ...

58. Checking input in Dialog box before closing    coderanch.com

Here's the code I have found online at http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html and I changed it up to what I have below. When I try an incorrect username and or password it does what it's supposed to and clears the text boxes. But if I try to login again it then does not work whether I use the correct username/password or not. import javax.swing.*; ...

59. hide x-Close-Button in a JDialog    coderanch.com

60. Close JDialog without hide    coderanch.com

Hi, Main GUI import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.sql.*; import javax.swing.event.*; import javax.swing.table.*; import java.awt.print.*; public class transaction implements ActionListener { static JDialog trafr=new JDialog();// JTextField tdwho=new JTextField(); DefaultListModel model = new DefaultListModel(); JList jlist=new JList(model); JScrollPane scrollPane1 = new JScrollPane(jlist); JPanel lspan=new JPanel(); JButton sb=new JButton("Show"); JLabel tracno=new JLabel("Case Number"); DefaultTableModel dom1=new DefaultTableModel(); JTable trtab1=new JTable(dom1); JScrollPane trpan1=new ...

61. Main JFrame doesn't always regain focus when modal dialog closes    coderanch.com

Hi all, I'm new to this forum so hopefully this is the right place to put this question. I have a relatively simple GUI application written in Java 6u20 that involves a main gui window (extends JFrame). Most of the file menu operations result in a modal dialog (either JFileChooser or JOptionPane) being presented to the user. The problem is that ...

63. To remove close button form Jdialog?    coderanch.com

64. Help with JDialog Close Operation    coderanch.com

Thanks Guys, I have already tried that, it works but it doesn't work for my application becouse the dialog box asks for user name and password and it contains a Login Button, and checks weather the user name and password is correct or incorrect, if it is correct it close the Dialog box and allows you to use the application, the ...

65. Extended JDialog not closing in JAR    coderanch.com

66. Close JDialog    java-forums.org

private void windowAction(Object actionCommand) { boolean closeWindow = false; String cmd = null; if (actionCommand != null) { if (actionCommand instanceof ActionEvent) { cmd = ((ActionEvent)actionCommand).getActionCommand(); } else { cmd = actionCommand.toString(); } } if (cmd != null) { if (cmd.equals(CMD_CANCEL)) { System.out.println("CANCEL"); closeWindow = true; } else if (cmd.equals(CMD_OK)) { System.out.println("OK"); closeWindow = true; } else { System.out.println("Command invoked: " ...

67. Dialog boxes closing on EVERY application.    java-forums.org

Hi - really bad problem, Every single JFileChooser and dialogue box that I use dissapears after about 3 seconds... But this also happens with: Tutorials, Programs, applications and games made by other people! I tried reinstalling Java but the problem persists and I haven't a clue what to do - there are no results on this for Google. In fact the ...

68. JDialog close option    java-forums.org

But which WindowListener event is called for each action? To test this, I like to create an SSCCE (as per our previous discussions): Java Code: import java.awt.Window; import java.awt.event.*; import javax.swing.*; @SuppressWarnings("serial") public class DialogClose { private static JDialog dialog; private static void createAndShowGui() { JButton showDialogBtn = new JButton(new AbstractAction("Show Dialog") { @Override public void actionPerformed(ActionEvent arg0) { if (dialog ...

69. How JFrame can detect that child JDialog is closed?    forums.oracle.com

Maybe I'm wrong but I think you might be doing things in reverse order. Normally you check if the user click 'Ok' or 'Cancel' before closing the dialog isn't it? If it is that way you can invoke a method in the JFrame with the parameters you need and then close the dialog. You can even trap the event of closing ...

70. how to close a JDialog with escape using netbeans    forums.oracle.com

Hi, I have this app where a configuration jdialog can be opened. I want it to close when escape-key is pressed. I found out how to do this (http://www.javaworld.com/javaworld/javatips/jw-javatip72.html), but not how to do it in the netbeans GUI designer. I'm guessing it's something in the JDialog properties panel under Events>keyReleased, but everything i tried does not work. Can anyone explain ...

73. Closing a JDialog...    forums.oracle.com

74. JDialog with out close button    forums.oracle.com