Allow setting "close all frames on client close"
This commit is contained in:
parent
9ab769275c
commit
915fba3645
@ -367,6 +367,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
|
||||
if (withGUI ) {
|
||||
m_Frame = new JEFrame(EvAInfo.productName + " workbench");
|
||||
m_Frame.setCloseAllOnClosed(true);
|
||||
m_Frame.setName(this.getClass().getSimpleName()); // the name is set to recognize the client window
|
||||
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
|
@ -18,7 +18,8 @@ import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class JEFrame extends JFrame {
|
||||
|
||||
private boolean closeAllOnClose=false;
|
||||
|
||||
public JEFrame() {
|
||||
super();
|
||||
init();
|
||||
@ -29,6 +30,15 @@ public class JEFrame extends JFrame {
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to true if all registered JEFrames should be closed if this frame is closed.
|
||||
*
|
||||
* @param c
|
||||
*/
|
||||
public void setCloseAllOnClosed(boolean c) {
|
||||
closeAllOnClose=c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWindowListener(WindowListener l) {
|
||||
super.addWindowListener(l);
|
||||
@ -42,6 +52,7 @@ public class JEFrame extends JFrame {
|
||||
public void windowClosed(WindowEvent e) {
|
||||
super.windowClosed(e);
|
||||
JEFrameRegister.unregister((JEFrame) e.getWindow());
|
||||
if (closeAllOnClose) JEFrameRegister.closeAll();
|
||||
// ((JFrame) e.getWindow()).dispose();
|
||||
}
|
||||
@Override
|
||||
|
@ -68,10 +68,24 @@ public class JEFrameRegister {
|
||||
return prefixes.toArray(new String[prefixes.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close (dispose) all frames whose title starts with a given prefix.
|
||||
*
|
||||
* @param prefix
|
||||
*/
|
||||
public static void closeAllByPrefix(String prefix) {
|
||||
for (int i=0; i<JEFrameList.size(); i++) {
|
||||
String title = JEFrameList.get(i).getTitle();
|
||||
if (title.startsWith(prefix)) JEFrameList.get(i).dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close (dispose) all frames registered in this list.
|
||||
*/
|
||||
public static void closeAll() {
|
||||
for (int i=0; i<JEFrameList.size(); i++) {
|
||||
JEFrameList.get(i).dispose();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user