jdialog

How to set the JFrame as a parent to the JDialog

杀马特。学长 韩版系。学妹 提交于 2019-12-01 14:06:00
问题 I am having trouble to set the frame as a owner to the dialog. Normally when I extend JDialog class for creating a dialog then I use super(frame) to specify the owner of the dialog such that both of them are not disjoint when you press alt+tab . But when I create a dialog using new like JDialog dialog = new JDialog() then I am unable to specify the frame as owner to the dialog. Following example demonstrates above two approaches. Top Click button opens a dialog which is without extending

JDialog allow user to only change width of the dialog

时间秒杀一切 提交于 2019-12-01 08:31:34
Does anyone know if it is possible to limit how the user resizes a JDialog? I know i can call the method setResizible(boolean) and that disables or enables the user from resizing the JDialog, but is there a way to restrict the user from changing the height of the window but allowing him to change the width? The dialog I'm creating looks funny if it grows vertically but horizontally growing the component could be a benefit to the user. Thanks in advance. You could add a ComponentListener to the JDialog, and check in componentResized if height changed. This could be implemented by extending the

JDialog Not Displaying When in Fullscreen Mode

十年热恋 提交于 2019-12-01 08:22:37
问题 I have an application that runs in fullscreen mode and has been working fine. Now I need to add a simple, undecorated dialog and I'm running into trouble. If I run the application maximized but not in fullscreen, the dialog displays and functions as expected. When I switch back to fullscreen, the dialog will not display. The dialog extends JDialog and only contains a JSlider and a couple of buttons. It is undecorated and not modal . (I disabled modality for testing purposes -- it was a pain

Optimal location for a modal JDialog to avoid stuck

人走茶凉 提交于 2019-12-01 08:03:17
My Swing application has to show a modal dialog to the user. Sorry for not posting SSCCE. topContainer might be JFrame or JApplet . private class NewGameDialog extends JDialog { public NewGameDialog () { super(SwingUtilities.windowForComponent(topContainer), "NEW GAME", ModalityType.APPLICATION_MODAL); //add components here getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); //TODO: setSize(new Dimension(250, 200)); setLocation(650, 300); } } I start the dialog like this on network event SwingUtilities.invokeLater(new Runnable() { @Override public void run() {

Button for closing a JDialog

倖福魔咒の 提交于 2019-11-30 22:28:41
问题 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 ActionListener of that button. I don't want the button to exit the program, just close the dialog. The JDialog is created by explicitly calling one of JDialog's constructors, not by calling one of the methods from JOptionPane. I was extremely surprised that I was unable to find an answer to this using Google. I expected that a problem that

Java listener on dialog close

霸气de小男生 提交于 2019-11-30 11:07:10
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 closed, so that I can call a refresh method and refresh the list from the database. If AddNewView

Exception : adding a window to a container. How to solve it?

一个人想着一个人 提交于 2019-11-30 09:21:04
问题 I have a JDialog class named Preferences . This class creates a constructor like: class Preferences extends javax.swing.JDialog { Preferences(java.awt.Frame parent,modal) { super(parent,modal); //...... } } In my program I want this preferences dialog to open up as I click a button from a JFrame form. After I registered the action listener on the button, I wrote the code inside as: Frame fr = new Frame(); Preferences p = new Preferences(fr,false); fr.add(p); fr.setVisible(true); When I run

ActionListener on JOptionPane

ε祈祈猫儿з 提交于 2019-11-30 06:01:23
问题 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

Java: How can I bring a JFrame to the front?

假如想象 提交于 2019-11-29 15:27:21
I am currently waiting for a very important announcement and I have created a simple application to check every 30 minutes whether the announcement was made or not When the announcement is made, I want a window to pop up and inform me about it. The window is just a simple JFrame that has some text in it. I have a class called Announcement. Inside this class I define another class for the frame called Form, so I have something like this: class Form{ public Form(){ //create frame and show it JFrame frame = new JFrame("anouncement"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container

Exception : adding a window to a container. How to solve it?

血红的双手。 提交于 2019-11-29 15:20:47
I have a JDialog class named Preferences . This class creates a constructor like: class Preferences extends javax.swing.JDialog { Preferences(java.awt.Frame parent,modal) { super(parent,modal); //...... } } In my program I want this preferences dialog to open up as I click a button from a JFrame form. After I registered the action listener on the button, I wrote the code inside as: Frame fr = new Frame(); Preferences p = new Preferences(fr,false); fr.add(p); fr.setVisible(true); When I run this code I get the following exception (as I click the button): Exception in thread "AWT-EventQueue-0"