Hello Rolf. Thank you for your answer concerning our problem. Well, we see the problem and we also could build a little workaround to fix the problem. When the parent isn't set, the dialog is closed. Otherwise if the parent is set, the dialog shows up as mentioned in our the previous post. Please see the snipped below to reproduce it.
But nevertheless both workarounds aren't satisfying in long time sight - so we will be pleased, if this problem could be fixed in a near future release. Best regards, Daniel MT AG Dipl.-Ing. Daniel Backhausen Balcke-Dürr-Allee 9 D-40882 Ratingen Telefon +49 (0) 21 02 309 61-0 Telefax +49 (0) 21 02 309 61-50 Mobil +49 (0) 173 594 27 95 E-Mail [EMAIL PROTECTED] Internet http://www.mt-ag.com +++ SNIPPED +++ import com.ulcjava.base.application.AbstractApplication; import com.ulcjava.base.application.BorderFactory; import com.ulcjava.base.application.ULCBoxPane; import com.ulcjava.base.application.ULCButton; import com.ulcjava.base.application.ULCDialog; import com.ulcjava.base.application.ULCFrame; import com.ulcjava.base.application.ULCLabel; import com.ulcjava.base.application.ULCScrollPane; import com.ulcjava.base.application.ULCTable; import com.ulcjava.base.application.ULCWindow; import com.ulcjava.base.application.event.ActionEvent; import com.ulcjava.base.application.event.IActionListener; import com.ulcjava.base.application.event.IWindowListener; import com.ulcjava.base.application.event.WindowEvent; import com.ulcjava.base.application.table.AbstractTableModel; import com.ulcjava.base.application.util.BorderedComponentUtilities; import com.ulcjava.base.application.util.Dimension; import com.ulcjava.base.development.DevelopmentRunner; public class TableAlertSnipped extends AbstractApplication { private static final long serialVersionUID = -9164998680046972987L; private final ULCFrame frame = new ULCFrame("TableAlertSnipped"); private final ULCFrame popUpFrame = new ULCFrame("A new Frame"); public void start() { // This is the calling frame frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE); frame.setSize(new Dimension(200, 65)); frame.setLocation(150, 150); frame.setVisible(true); frame.toFront(); ULCBoxPane pane = new ULCBoxPane(); ULCTable table = new ULCTable(new SnippetTableModel()); pane.add(ULCBoxPane.BOX_EXPAND_EXPAND, new ULCScrollPane(table)); popUpFrame.setDefaultCloseOperation(ULCFrame.DO_NOTHING_ON_CLOSE); popUpFrame.setSize(new Dimension(350, 350)); popUpFrame.setLocation(150, 150); popUpFrame.add(BorderedComponentUtilities.createBorderedComponent(pane, ULCBoxPane.BOX_EXPAND_EXPAND, BorderFactory.createEmptyBorder(5, 5, 5, 5))); popUpFrame.addWindowListener(closeAction); ULCButton testBtn = new ULCButton("Click to open a new Frame"); testBtn.addActionListener(new IActionListener() { public void actionPerformed(ActionEvent event) { showPopUp(); } }); frame.add(testBtn); } private IWindowListener closeAction = new IWindowListener() { public void windowClosing(WindowEvent event) { close(); } }; private void close() { //final AlertBox alert = new AlertBox(popUpFrame, "Alert", "Want to save first?"); final AlertBox alert = new AlertBox(null, "Alert", "Want to save first?"); // null => unsetting parent! alert.addWindowListener(new IWindowListener() { public void windowClosing(WindowEvent event) { if (alert.getValue().equals("Ok")) { // e.g. saving data ... hidePopUp(); } // comment dispose for ULC 6.0 alert.dispose(); } }); } private void hidePopUp() { popUpFrame.setVisible(false); } private void showPopUp() { popUpFrame.setVisible(true); popUpFrame.toFront(); } // -- private class SnippetTableModel extends AbstractTableModel { private static final long serialVersionUID = 6715883500867725570L; public Object getValueAt(int row, int column) { return String.valueOf("xxxyyy"); } public int getRowCount() { return 10; } public void setValueAt(Object value, int row, int column) { System.out.println("Setting: " + value.toString()); } public int getColumnCount() { return 5; } public boolean isCellEditable(int i, int j) { return true; } } public static void main(String[] args) { DevelopmentRunner.setApplicationClass(TableAlertSnipped.class); DevelopmentRunner.main(args); } private class AlertBox extends ULCDialog { private static final long serialVersionUID = -8426765893446903437L; private String value; public AlertBox(ULCWindow parent, String title, String message) { super(parent); setTitle(title); setSize(new Dimension(150, 90)); setModal(true); setResizable(false); setDefaultCloseOperation(ULCDialog.DISPOSE_ON_CLOSE); ULCBoxPane pane = new ULCBoxPane(true); pane.setVerticalGap(5); pane.add(ULCBoxPane.BOX_EXPAND_EXPAND, new ULCLabel(message)); ULCBoxPane btnPane = new ULCBoxPane(false); ULCButton btn1 = new ULCButton("Ok"); btn1.addActionListener(a); btnPane.add(btn1); ULCButton btn2 = new ULCButton("Cancel"); btn2.addActionListener(a); btnPane.add(btn2); pane.add(ULCBoxPane.BOX_EXPAND_EXPAND, btnPane); this.add(pane); this.setVisible(true); this.toFront(); } private IActionListener a = new IActionListener() { public void actionPerformed(final ActionEvent event) { // Sets the buttons text as return value of the dialog. setValue(((ULCButton) event.getSource()).getText()); // ULC 6.0 //distributeToListeners(new WindowEvent(this)); // ULC 6.1 fireWindowClosing(new WindowEvent(this)); setVisible(false); } }; public String getValue() { return (value != null) ? value : "windowClosing"; } private void setValue(String value) { this.value = value; } } } -----"Rolf Pfenninger" <[EMAIL PROTECTED]> wrote: ----- To: <[email protected]>, <[EMAIL PROTECTED]> From: "Rolf Pfenninger" <[EMAIL PROTECTED]> Date: 12/20/2006 11:12 cc: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> Subject: RE: [ULC-developer] Problem closing frames from within a modal dialog in version 6.1.1 Hi Daniel ULC Release 6.1.1 aligned the ULCWindow.setVisible() and ULCWindow.dispose() with Swing. So let me first explain this in the Swing world. When calling java.awt.Window.setVisible(false) on a window with child windows/dialogs that are also currently visible, a subsequent java.awt.Window.setVisible(true) will also bring up the child windows again. So, if the child window should not be brought up automatically later, a Swing application should first hide the child window and then the parent window. Basically the same is true for ULC applications. There is one complication to this however. A ULCDialog.setVisible(true) is handled inside a SwingUtilities.invokeLater() on the client side. This is needed because Swing starts a new event loop for modal dialogs on a call to ULCDialog.setVisible(true). This usage of SwingUtilities.invokeLater() potentially switches the order of calls to setVisible() for a frame and a dialog. I added the issue http://www.canoo.com/jira/browse/UBA-7130to our JIRA issue tracking system. So, your code should first close the alert and then the frame: alert.addWindowListener(new IWindowListener() { public void windowClosing(WindowEvent event) { alert.dispose(); if (alert.getValue().equals("Ok")) { // e.g. saving data ... hidePopUp(); } } }); To make sure that the call to setVisible(false) on your frame comes after the corresponding call to setVisible(false) on your alert, you can use the following workaround. This should fix the problem. private void hidePopUp() { ULCPollingTimer pollingTimer = new ULCPollingTimer(0, new IActionListener() { public void actionPerformed(ActionEvent event) { popUpFrame.setVisible(false); } }); pollingTimer.setRepeats(false); pollingTimer.start(); } I hope this helps. Cheers Rolf ************************************** Rolf Pfenninger Canoo Engineering AG Kirschgartenstrasse 7 CH-4051 Basel Tel +41 61 228 9444 Fax +41 61 228 9449 mailto:[EMAIL PROTECTED] http://www.canoo.com ULC - Rich Clients for J2EE http://www.canoo.com/ulc ************************************** > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of > [EMAIL PROTECTED] > Sent: Donnerstag, 14. Dezember 2006 11:49 > To: [email protected] > Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: [ULC-developer] Problem closing frames from within a modal > dialog in version 6.1.1 > > > > > Hello! > > We just discovered a strange behaviour containing modal dialogs called from > an frame which differs between ULC version 6.0.4 and 6.1.1. > > The following describes the starting situation: We have a frame which > listens to window action within a windowlistener. When trying to close the > frame, the listener fires up a dialog which mimics an ULCAlert showing some > confirm message (e.g. "Save changes?"). > After clicking to confirm, the dialog has to close the parent window. If I > am not wrong, normally the dialog will disappear with the parent. Now, when > we fire up the frame again for ULC 6.1.1, without restarting the > application, the dialog is still shown. After confirming it again and > starting the frame for the third time it is finally invisible. In ULC > version 6.0.4 that behaviour doesn´t come up. The dialog will be correctly > closed and doesn´t come up after restarting the frame. > > I have attached a simple snipped. If you run this code as described above > under 6.1.1 and 6.0.4 you will see the difference. > > We will be glad, if you have any hint or idea to solve this problem. > > > Best regards, > Daniel > > > +++ Snipped +++ > > import com.ulcjava.base.application.AbstractApplication; > import com.ulcjava.base.application.BorderFactory; > import com.ulcjava.base.application.ULCBoxPane; > import com.ulcjava.base.application.ULCButton; > import com.ulcjava.base.application.ULCDialog; > import com.ulcjava.base.application.ULCFrame; > import com.ulcjava.base.application.ULCLabel; > import com.ulcjava.base.application.ULCScrollPane; > import com.ulcjava.base.application.ULCTable; > import com.ulcjava.base.application.ULCWindow; > import com.ulcjava.base.application.event.ActionEvent; > import com.ulcjava.base.application.event.IActionListener; > import com.ulcjava.base.application.event.IWindowListener; > import com.ulcjava.base.application.event.WindowEvent; > import com.ulcjava.base.application.table.AbstractTableModel; > import com.ulcjava.base.application.util.BorderedComponentUtilities; > import com.ulcjava.base.application.util.Dimension; > import com.ulcjava.base.development.DevelopmentRunner; > > public class TableAlertSnipped extends AbstractApplication { > private final ULCFrame frame = new ULCFrame("TableAlertSnipped"); > private final ULCFrame popUpFrame = new ULCFrame("A new Frame"); > > public void start() { > // This is the calling frame > frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE); > frame.setSize(new Dimension(200, 65)); > frame.setLocation(150, 150); > frame.setVisible(true); > frame.toFront(); > > ULCBoxPane pane = new ULCBoxPane(); > ULCTable table = new ULCTable(new SnippetTableModel()); > pane.add(ULCBoxPane.BOX_EXPAND_EXPAND, new ULCScrollPane(table)); > > popUpFrame.setDefaultCloseOperation(ULCFrame.DO_NOTHING_ON_CLOSE); > popUpFrame.setSize(new Dimension(350, 350)); > popUpFrame.setLocation(150, 150); > popUpFrame.add(BorderedComponentUtilities.createBorderedComponent(pane, > ULCBoxPane.BOX_EXPAND_EXPAND, > BorderFactory.createEmptyBorder(5, 5, 5, 5))); > > popUpFrame.addWindowListener(closeAction); > > ULCButton testBtn = new ULCButton("Click to open a new Frame"); > testBtn.addActionListener(new IActionListener() { > public void actionPerformed(ActionEvent event) { > showPopUp(); > } > }); > > frame.add(testBtn); > } > > private IWindowListener closeAction = new IWindowListener() { > public void windowClosing(WindowEvent event) { > close(); > } > }; > > private void close() { > final AlertBox alert = new AlertBox(popUpFrame, "Alert", "Want to save > first?"); > alert.addWindowListener(new IWindowListener() { > public void windowClosing(WindowEvent event) { > if (alert.getValue().equals("Ok")) { > // e.g. saving data ... > hidePopUp(); > } > > // comment dispose for ULC 6.0 > alert.dispose(); > } > }); > } > > private void hidePopUp() { > popUpFrame.setVisible(false); > } > > private void showPopUp() { > popUpFrame.setVisible(true); > popUpFrame.toFront(); > } > > // -- > > private class SnippetTableModel extends AbstractTableModel { > public Object getValueAt(int row, int column) { > return String.valueOf("xxxyyy"); > } > > public int getRowCount() { > return 10; > } > > public void setValueAt(Object value, int row, int column) { > System.out.println("Setting: " + value.toString()); > } > > public int getColumnCount() { > return 5; > } > > public boolean isCellEditable(int i, int j) { > return true; > } > } > > public static void main(String[] args) { > DevelopmentRunner.setApplicationClass(TableAlertSnipped.class); > DevelopmentRunner.main(args); > } > > private class AlertBox extends ULCDialog { > private static final long serialVersionUID = -8426765893446903437L; > private String value; > > public AlertBox(ULCWindow parent, String title, String message) { > super(parent); > > setTitle(title); > setSize(new Dimension(150, 90)); > setModal(true); > setResizable(false); > setDefaultCloseOperation(ULCDialog.DISPOSE_ON_CLOSE); > > ULCBoxPane pane = new ULCBoxPane(true); > pane.setVerticalGap(5); > pane.add(ULCBoxPane.BOX_EXPAND_EXPAND, new ULCLabel(message)); > > ULCBoxPane btnPane = new ULCBoxPane(false); > > ULCButton btn1 = new ULCButton("Ok"); > btn1.addActionListener(a); > btnPane.add(btn1); > > ULCButton btn2 = new ULCButton("Cancel"); > btn2.addActionListener(a); > btnPane.add(btn2); > > pane.add(ULCBoxPane.BOX_EXPAND_EXPAND, btnPane); > > this.add(pane); > this.setVisible(true); > this.toFront(); > } > > private IActionListener a = new IActionListener() { > public void actionPerformed(final ActionEvent event) { > // Sets the buttons text as return value of the dialog. > setValue(((ULCButton) event.getSource()).getText()); > > // ULC 6.0 > //distributeToListeners(new WindowEvent(this)); > // ULC 6.1 > fireWindowClosing(new WindowEvent(this)); > setVisible(false); > } > }; > > public String getValue() { > return (value != null) ? value : "windowClosing"; > } > > private void setValue(String value) { > this.value = value; > } > } > } > > > > (See attached file: TableAlertSnipped.java) _______________________________________________ ULC-developer mailing list [email protected] http://lists.canoo.com/mailman/listinfo/ulc-developer
