jdialog

Returning value from JDialog; dispose(), setVisible(false) - example

旧城冷巷雨未停 提交于 2019-12-06 00:02:14
问题 I know, that this question appears quite frequently in SO like here: but I would like to present some very specific example... I'm simply not sure if I make things right. I've got a JDialog in which I can type some values, select some checkboxes... whatever... I've got also some Response object created in MyDialog which represents the MyDialog's "answer". In JFrame which calls/creates JDialog: MyDialog d = new MyDialog(this, ...); d.showDialog(); // After MyDialog is closed (it's modal):

JFileChooser vs JDialog vs FileDialog

倖福魔咒の 提交于 2019-12-05 19:50:36
I need to know which of the 3 is best for me. My requirements are as follows in order of importance: Save and load files with ease. File type filter during file selection (not afterwards). Look and feel is exactly the same as the native OS L&F. If there is a dialog that I've not mentioned that would be more ideal, please let me know. What is the rest of your application written in? If you used AWT you should use FileDialog . If you used Swing you should use JFileChooser . Both classes meet all of your requirements. (A JDialog is simply an empty window, you can only use it to open files if you

Custom Cursor in a Swing JDialog

假如想象 提交于 2019-12-05 12:46:09
I have a Java Swing application, developed on Mac OS X 10.5 using Java 1.5. I'm trying to make a custom cursor appear when the user moves the mouse over some text in a dialog. The cursor never changes, though. When I don't use a JFrame instead of a JDialog, the cursor does change. But then I'll have to write all the dialog code myself. How can I get the cursor to appear? Here's the simplest code I could create to demonstrate the problem: import javax.swing.*; import java.awt.*; public class CursorTest { public static void main(String[] args) { JLabel label = new JLabel("Move mouse here for

Retrieve input entered in a JDialog

对着背影说爱祢 提交于 2019-12-05 09:07:47
I extended JDialog to create a custom dialog where the user must fill some fields : How should I retrieve the data entered ? I came up with a solution that works. It mimics JOptionPane but the way I do it looks ugly to me because of the static fields involved... Here is roughly my code : public class FObjectDialog extends JDialog implements ActionListener { private static String name; private static String text; private JTextField fName; private JTextArea fText; private JButton bAdd; private JButton bCancel; private FObjectDialog(Frame parentFrame) { super(parentFrame,"Add an object",true); //

How do I close a JDialog and have the Window Event Listeners be notified?

房东的猫 提交于 2019-12-05 08:43:48
问题 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 seem to do it. 回答1: Closing a window (with dispose() ) and hiding it (with setVisible(false) ) are different operations, and produce different events -- and closing it from the operating system is yet another different operation that produces yet a different event. All three will produce windowDeactivated to tell you

Swing modal dialog refuses to close - sometimes!

為{幸葍}努か 提交于 2019-12-05 07:23:31
// 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 dialog // stays visible. // This is on Ubuntu 10.10, running: // OpenJDK Runtime Environment (IcedTea6 1.9) (6b20-1.9-0ubuntu1) // This always prints // setVisible(true) about to happen // setVisible(false) about to happen // setVisible(false) has just happened // even when the dialog stays visible. package modalproblemdemo; import java.awt.Frame; import javax.swing.JDialog; import javax.swing.SwingUtilities; public class Main { public static

wait for jdialog to close

妖精的绣舞 提交于 2019-12-05 05:22:39
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 FilePathDialog(); projectDialog.setVisible(true); projectDialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.out.println("Window closing"); try { doWork(); } catch (Throwable t) { t.printStackTrace(); } } public void windowClosed(WindowEvent e) { System.out.println("Window closed"); try { doWork(); } catch (Throwable t) { t.printStackTrace(); } } }); doWork never gets called when the JDialog window

Can I make ProgressMonitor dialog modal?

人盡茶涼 提交于 2019-12-05 02:13:11
is there a way to make the dialog from ProgressMonitor modal? EDIT: The ProgressMonitor class in JAVA API will bring a dialog which is on the top but not Modal. User still has access to the background GUI. I am looking for a Modal dialog to show the progress and also allow user to stop the task in the middle. As discussed in How to Use Progress Monitors , a number of factors should be considered when Deciding Whether to Use a Progress Bar or a Progress Monitor . As an implementation detail, ProgressMonitor is modeless because "the Solaris implementation doesn't support Dialog.setModal yet." As

JDialog: How to disable the ESC key of my Modal dialog?

半腔热情 提交于 2019-12-04 16:06:52
So there's a frame (main app). From here, I open a Modal JDialog and start a background thread working whilst displaying progress (log entries) in a table. This process is critical and should not be stoppable/hideable/closeable, thus why the dialog's close button is de-activated until everything's finished. However, the user can at any time tap the ESC key and my onCanceled() is called, thus calling this.dispose(). EDIT: I inherited this project and oversaw how deep the rabbit hole of inheritance went, thus overseeing handling of ESC already, followed by e.consume() which is why my solutions

Stop newly created dialog from taking focus

走远了吗. 提交于 2019-12-04 12:00:34
I'm trying to have Java Swing dialog be created but I don't want to have the dialog to take focus away from whatever is currently focused. So for example, if you're editing a word doc and a different application creates a dialog, you should see the dialog but the word doc should remain in focus so that you can keep editing. I've tested the following code on Mac OSX and on Ubuntu 12.04. On Mac, the code creates dialogs that do not take the focus like I want. On Ubuntu, the dialogs take the focus, and I can't type while they are being created. I really hope this isn't operating system specific.