jdialog

Opening JDialog with SwingWorker?

折月煮酒 提交于 2019-11-27 07:30:44
问题 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

action listener to JDialog for clicked button

人走茶凉 提交于 2019-11-27 06:06:57
问题 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); /

Java - How to create a custom dialog box?

◇◆丶佛笑我妖孽 提交于 2019-11-27 03:53:38
I have a button on a JFrame that when clicked I want a dialog box to popup with multiple text areas for user input. I have been looking all around to try to figure out how to do this but I keep on getting more confused. Can anyone help? If you don't need much in the way of custom behavior, JOptionPane is a good time saver. It takes care of the placement and localization of OK / Cancel options, and is a quick-and-dirty way to show a custom dialog without needing to define your own classes. Most of the time the "message" parameter in JOptionPane is a String, but you can pass in a JComponent or

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

爱⌒轻易说出口 提交于 2019-11-27 02:47:58
问题 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 automatically close the dialog after a delay; without the user having to close the dialog? 回答1: This solution is based on oxbow_lakes', but it uses a javax.swing.Timer, which is intended for this type of thing. It always executes its code on the event dispatch thread. This is important to avoid subtle but nasty bugs import javax.swing.*;

How to really close a JDialog with Java code?

风流意气都作罢 提交于 2019-11-26 21:41:26
问题 I know setVisible(false) , dispose() ,but they can't really close a JDialog. When I have the other thread stop, the thread of the JDialog still runs. And I can't use System.exit(0) ,because the other thread needs run for a while. Following the code, I finally resolve the problem by System.exit(0) at the end of the program. public class CsUpdateCtrl { /** * 升级service */ private CsUpdateService service; private CsUpdateCtrl() { this.service = (CsUpdateService) RmiUtil.getBean(RmiUtil.Service

JDialog setVisible(false) vs dispose()

孤人 提交于 2019-11-26 16:40:24
问题 Does it make sense to use setVisible(false) on a dialog and reuse it later or is safer to call dispose() every time and to make a new JDialog. What about memory leaks with setVisible(false)? EDIT: My Question isn't so much about quitting the application. More about Dialogs that have the main frame as parent and are opened and closed during the application life time. E.g. let's say my applications has about 10 dialogs that display different data every time I open them. Should I reuse the

Java Dialog - Find out if OK is clicked?

笑着哭i 提交于 2019-11-26 14:39:08
问题 I have a dialog for a client-GUI that asks for the IP and Port of the server one wants to connect to. I have everything else, but how would I make it so that when the user clicks "OK" on my dialog box, that it runs something? Here's what I have so far: import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JDialog; import javax.swing.JOptionPane; import javax.swing.JTextField; public class ClientDialog { JTextField ip = new JTextField(20); JTextField port

How do I make my SwingWorker example work properly?

匆匆过客 提交于 2019-11-26 13:46:45
I've made my own SwingWorker example to get familiar with how it works. What I'm wanting to do is the following: When the button is clicked I want a progress bar appear until the task is done I want to simply remove the progress bar and add a string to the dialog. When the button is clicked, the progress bar comes up but never goes away. (never removes the progress bar after 10 seconds and never places the label up) Here is an SSCCE: package swingtesting; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JDialog; import

Java - How to create a custom dialog box?

别等时光非礼了梦想. 提交于 2019-11-26 09:36:10
问题 I have a button on a JFrame that when clicked I want a dialog box to popup with multiple text areas for user input. I have been looking all around to try to figure out how to do this but I keep on getting more confused. Can anyone help? 回答1: If you don't need much in the way of custom behavior, JOptionPane is a good time saver. It takes care of the placement and localization of OK / Cancel options, and is a quick-and-dirty way to show a custom dialog without needing to define your own classes

Setting the maximum size of a JDialog?

。_饼干妹妹 提交于 2019-11-26 01:48:10
问题 The short version: do I need to do something tricky to get JDialog\'s setMaximumSize() to work? The full version: I\'ve got a JDialog (layout manager: BorderLayout) which contains a scroll pane and a JPanel on the bottom with the commit buttons. The scroll pane contains a JPanel which is built dynamically elsewhere in the system. What I want is for the dialog to dynamically size itself around the JPanel up to a certain size, and then start growing scrollbars. This is, more or less, what