jdialog

Show JDialog on Windows taskbar

孤街浪徒 提交于 2019-11-28 08:56:00
I'm trying to display a JDialog in Windows. How do I show a JDialog (like JFrame ) on my Windows taskbar? A dialog itself cannot have a task bar entry, but you can construct a frame that does not have any visible effect and use it as a parent for the dialog. Then it will look like the dialog has a task bar entry. The following code shows you how to do it: class MyDialog extends JDialog { private static final List<Image> ICONS = Arrays.asList( new ImageIcon("icon_16.png").getImage(), new ImageIcon("icon_32.png").getImage(), new ImageIcon("icon_64.png").getImage()); MyDialog() { super(new

How to add components to JDialog

安稳与你 提交于 2019-11-28 08:25:31
问题 d1=new JDialog(); d1.setSize(200, 100); t1=new JTextField(); t1.setBounds(10,10,40,20); d1.add(t1); I want to add components in JDialog such as TextField, Button... 回答1: 1) first create a Jpanel JPanel pan=new JPanel(); pan.setLayout(new FlowLayout()); 2) add the components to that JPanel pan.add(new JLabel("label")); pan.add(new JButton("button")); 3) create JDialog JDialog jd=new JDialog(); 4) add the JPanel to JDialog jd.add(pan); 回答2: You have to make sure you use no layout manager. d1

To Add Minimize /Maximize button to JDialog orJPanel

只谈情不闲聊 提交于 2019-11-28 08:07:30
问题 Is it possible to add maximize/minimize button to the JDialog? if not then can we add these buttons to JPanel? I have a JPanel and inside that panel there is a JDialog.I want to add a minimize/maximize button such that when that button is clicked JDialog and the components under JDialog get adjusted according to the JPanel. like when i click maximize then jpanel should get enlarged and components inside that panel(JDialog) also get enlarged and vice versa for minimize button. The solution I

How can I return a value from a JDialog box to the parent JFrame?

烈酒焚心 提交于 2019-11-28 03:55:29
I have created a modal JDialog box with a custom drawing on it and a JButton. When I click the JButton, the JDialog box should close and a value should be returned. I have created a function in the parent JFrame called setModalPiece, which receives a value and sets it to a local JFrame variable. The problem is that this function is not visible from the JDialog box (even though the JDialog box has a reference to the parent JFrame). Two questions: 1) Is there a better way to return a value from a JDialog box to its parent JFrame? 2) Why can't the reference to the JFrame passed to the JDialog be

How to really close a JDialog with Java code?

南笙酒味 提交于 2019-11-28 00:24:29
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.csupdate); } private static final Logger log = Logger.getLogger(CsUpdateCtrl.class.getName()); public

How do I remove the maximize and minimize buttons from a JFrame?

女生的网名这么多〃 提交于 2019-11-27 22:05:54
I need to remove the maximize and minimize buttons from a JFrame . Please suggest how to do this. import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class Dlg extends JDialog { public Dlg(JFrame frame, String str) { super(frame, str); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); } public static void main(String[] args) { try { Dlg frame = new Dlg(new JFrame(), "No min max buttons"); JPanel panel =

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

大城市里の小女人 提交于 2019-11-27 18:33:00
问题 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. 回答1: Just add a custom JPanel as a message to JOptionPane.showOptionDialog() : String[] options = {"OK"}; JPanel panel = new JPanel(); JLabel lbl = new JLabel(

JDialog setVisible(false) vs dispose()

僤鯓⒐⒋嵵緔 提交于 2019-11-27 14:19:40
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 instances and use setVisible() or should I make a new Dialog every time and dispose() them on closing. I

Java Dialog - Find out if OK is clicked?

↘锁芯ラ 提交于 2019-11-27 09:19:53
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 = new JTextField(20); GUI gui = new GUI(); Client client = new Client(); JOptionPane optionPane; public

How to wait for a JFrame to close before continuing?

亡梦爱人 提交于 2019-11-27 07:54:09
问题 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