jdialog

Safely open and close modal JDialog (using SwingWorker)

寵の児 提交于 2019-11-29 14:43:57
I needed a way to get some data from a database and prevent the user from modifying existing data for that moment. I created a SwingWorker to make the db update and a modal JDialog to show user what is going on (with a JProgressBar). The modal dialog has defaultCloseOperation set to DO_NOTHING, so it can only be closed with a proper call - I use setVisible(false) . MySwingWorkerTask myTask = new MySwingWorkerTask(); myTask.execute(); myModalDialog.setVisible(true); The SwingWorker does some stuff within doInBackground() and lastly it calls: myModalDialog.setVisible(false); My only concern and

Java listener on dialog close

女生的网名这么多〃 提交于 2019-11-29 11:12:26
问题 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() { JFrame mainFrame = ADLog2App.getApplication().getMainFrame(); addNewDialog = new AddNewView(mainFrame, true); addNewDialog.setLocationRelativeTo(mainFrame); addNewDialog.addContainerListener(null); ADLog2App.getApplication().show(addNewDialog); } How do you add a listener to the main class to detect when the addNewDialog window

Is there a way to only have the OK button in a JOptionPane showInputDialog (and no CANCEL button)?

一笑奈何 提交于 2019-11-29 04:38:20
I've seen that this is possible in other types of dialog windows such as "showConfirmDialog", where one can specify the amount of buttons and their names; but is this same functionality achievable when using "showInputDialog"? I couldn't seem to find this type of thing in the API. Perhaps I just missed it, but any help is appreciated. Eng.Fouad Just add a custom JPanel as a message to JOptionPane.showOptionDialog() : String[] options = {"OK"}; JPanel panel = new JPanel(); JLabel lbl = new JLabel("Enter Your name: "); JTextField txt = new JTextField(10); panel.add(lbl); panel.add(txt); int

JLayeredPane with a JDialog

南笙酒味 提交于 2019-11-28 14:06:55
问题 I am unable to make any components apear on a JLayeredPane when adding it to a JDialog. I have also been unable to find a web resource that shows this may be done in a reasonably sized block of code. Every sight iv looked at "claims" this can be done, and then shows a disgustingly long solution. What i want is to take a JLayered pane add a Button and place a JLabel with an icon in it onto this pane aswell. In english i want a button with an icon stuck in the front of its text. That is the awt

ActionListener on JOptionPane

自闭症网瘾萝莉.ら 提交于 2019-11-28 13:53:47
I am following the Oracle tutorial on how to create a custom dialog box: http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html I have two buttons: Save Object and Delete Object which when clicked should execute a certain piece of code. Unfortunately I can't seem to add any ActionListener to the JOptionPane buttons so when they're clicked nothing happens. Can anyone help tell me how I can go about doing this? Here is the class I have for the dialog box so far: class InputDialogBox extends JDialog implements ActionListener, PropertyChangeListener { private String typedText = null

How to wait for a JFrame to close before continuing?

佐手、 提交于 2019-11-28 13:42:29
My program consists of 3 main 'sections'. Main function, Login form and App form. The main function should do something like: Open Login form, wait for it to close, then open App form. I can't get the waiting part to work, or rather, I don't know how I would go around doing that. I was told by someone to use a JDialog instead and use setModal(true) , but with that approach the Login form wouldn't appear on the taskbar, which is terrible in my opinion. Another thing I considered was to open the App from inside the Login after it closes, but that feels like bad design since that'd make the Login

Opening JDialog with SwingWorker?

被刻印的时光 ゝ 提交于 2019-11-28 13:13:39
I have a project J2SE that use JPA. In some JDialogs I do returns getResultList() and populate JTable, JComboBox, JList etc. at constructor of class. So when I will create any instance for these dialogs sometimes are slow. I think use SwingWorker and JProgressbar and create a (loading) to open JDialogs is a good solution, but I don't know how to do this. I'm trying this. // JProgressbar progress = new JProgressBar(); //custommer dialog JDialog custommer = new JDialog(); //here slow because I have List<Customer> and others lists custommer.setModal(true); private void openDialogs(JDialog dialog)

Multithreading issues with Swing around dialog create/destroy [duplicate]

邮差的信 提交于 2019-11-28 13:03:24
问题 Possible Duplicate: SwingWorker in Java I have several classes that need to work together but, they're not. For one, I have Main: public class Main { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { //JFrame dummy for JDialog errors modal = new JFrame(); new PrimaryErrorDialog("Title", "Message", e, false); JFrame masterWindow = new JFrame(); masterWindow.setVisible(); } } } } It creates PrimaryErrorDialog class: private

action listener to JDialog for clicked button

纵然是瞬间 提交于 2019-11-28 11:21:22
I have main application where is table with values. Then, I click "Add" button, new CUSTOM (I made it myself) JDialog type popup comes up. There I can input value, make some ticks and click "Confirm". So I need to read that input from dialog, so I can add this value to table in main application. How can I listen when "confirm" button is pressed, so I can read that value after that? addISDialog = new AddISDialog(); addISDialog.setVisible(true); addISDialog.setLocationRelativeTo(null); //somekind of listener... //after "Confirm" button in dialog was pressed, get value value = addISDialog.ISName;

When creating a dialog with jquery, how do I hide the dialog div?

一笑奈何 提交于 2019-11-28 09:09:40
I am creating a dialog like in this page: http://jqueryui.com/demos/dialog/#modal-confirmation (click view source) on the bottom is the div that gets placed in the dialog. The dialog works perfect when called by the javascript but the dialog is apparent at the bottom of the page when it loads. (minus all the styling that gets applied when it is called by the javascript function) How can I hide the div and still allow the dialog to use it? I have tried setting style="visibility:hidden" but that prevents it from being shown when called by the javascript. This may be a stupid question, but