UI: fixed windows layer problems when old window overlapped new window (see #4318, #4320 and other)

This commit is contained in:
Oleg Agafonov 2018-01-01 18:00:42 +04:00
parent 89f8b1420e
commit 78d036b6bb
9 changed files with 74 additions and 20 deletions

View file

@ -45,8 +45,8 @@ import java.awt.event.MouseEvent;
import java.beans.PropertyVetoException;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.*;
import mage.client.MageFrame;
import org.apache.log4j.Logger;
@ -74,11 +74,34 @@ public class MageDialog extends javax.swing.JInternalFrame {
@Override
public void show() {
super.show();
this.toFront();
// frames desktop ordering
// more info https://docs.oracle.com/javase/7/docs/api/javax/swing/JLayeredPane.html
// WARNING, use
// - JLayeredPane.DEFAULT_LAYER: tables and games (tabs)
// - JLayeredPane.PALETTE_LAYER: toolbars and info windows like cards list, not modal dialogs (not required user actions)
// - JLayeredPane.MODAL_LAYER: all modal dialogs (user required actions - select cards in game, new game window, error windows)
// - JLayeredPane.POPUP_LAYER: hints and other top level graphics
// - JLayeredPane.DRAG_LAYER: top most layer for critical actions and user controls
/*
JInternalFrame[] frames = MageFrame.getDesktop().getAllFrames();
System.out.println("---");
for(JInternalFrame frame: frames){
int zorder = -1;
if (frame.getParent() != null){
frame.getParent().getComponentZOrder(frame);
}
System.out.println(frame.getClass() + " (" + frame.getTitle() + ") : layer = " + frame.getLayer() + ", zorder = " + zorder);
}
*/
if (modal) {
this.setClosable(false);
}
if (this.modal) {
this.toFront();
if (modal){
startModal();
}
}
@ -108,7 +131,6 @@ public class MageDialog extends javax.swing.JInternalFrame {
}
private synchronized void startModal() {
try {
if (SwingUtilities.isEventDispatchThread()) {
EventQueue theQueue = getToolkit().getSystemEventQueue();