mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 14:37:13 -06:00
@@ -16,9 +16,7 @@
|
|||||||
|
|
||||||
package com.formdev.flatlaf.ui;
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
import javax.swing.DefaultDesktopManager;
|
import javax.swing.*;
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JInternalFrame;
|
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.UIResource;
|
import javax.swing.plaf.UIResource;
|
||||||
import javax.swing.plaf.basic.BasicDesktopPaneUI;
|
import javax.swing.plaf.basic.BasicDesktopPaneUI;
|
||||||
@@ -42,15 +40,25 @@ public class FlatDesktopPaneUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void installDesktopManager() {
|
protected void installDesktopManager() {
|
||||||
desktopManager = desktop.getDesktopManager();
|
// Check current installed desktop manager
|
||||||
if( desktopManager == null ) {
|
// to avoid recursive call with property change event (will fire a stack overflow)
|
||||||
|
// Do not handle install if already installed
|
||||||
|
DesktopManager old = desktop.getDesktopManager();
|
||||||
|
if (old instanceof FlatDesktopManager) return;
|
||||||
|
|
||||||
|
if( old == null ) {
|
||||||
desktopManager = new FlatDesktopManager();
|
desktopManager = new FlatDesktopManager();
|
||||||
desktop.setDesktopManager( desktopManager );
|
|
||||||
|
} else {
|
||||||
|
// create the wrapper version of the desktop manager
|
||||||
|
desktopManager = new FlatWrapperDesktopManager(old);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
desktop.setDesktopManager(desktopManager);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---- class FlatDesktopManager -------------------------------------------
|
//---- class FlatDesktopManager -------------------------------------------
|
||||||
|
|
||||||
private class FlatDesktopManager
|
private class FlatDesktopManager
|
||||||
extends DefaultDesktopManager
|
extends DefaultDesktopManager
|
||||||
implements UIResource
|
implements UIResource
|
||||||
@@ -62,4 +70,94 @@ public class FlatDesktopPaneUI
|
|||||||
((FlatDesktopIconUI)f.getDesktopIcon().getUI()).updateDockIcon();
|
((FlatDesktopIconUI)f.getDesktopIcon().getUI()).updateDockIcon();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---- class for already installed desktop manager to use the flat desktop manager features
|
||||||
|
private class FlatWrapperDesktopManager
|
||||||
|
extends FlatDesktopManager
|
||||||
|
|
||||||
|
{
|
||||||
|
private DesktopManager parent = null;
|
||||||
|
|
||||||
|
private FlatWrapperDesktopManager(DesktopManager parent) {
|
||||||
|
super();
|
||||||
|
this.parent = parent;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openFrame(JInternalFrame f) {
|
||||||
|
parent.openFrame( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closeFrame(JInternalFrame f) {
|
||||||
|
parent.closeFrame( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void maximizeFrame(JInternalFrame f) {
|
||||||
|
parent.maximizeFrame( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void minimizeFrame(JInternalFrame f) {
|
||||||
|
parent.minimizeFrame( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void activateFrame(JInternalFrame f) {
|
||||||
|
parent.activateFrame( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deactivateFrame(JInternalFrame f) {
|
||||||
|
parent.deactivateFrame( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void iconifyFrame( JInternalFrame f ) {
|
||||||
|
super.iconifyFrame( f );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deiconifyFrame( JInternalFrame f ) {
|
||||||
|
super.deiconifyFrame( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beginDraggingFrame(JComponent f) {
|
||||||
|
parent.beginDraggingFrame( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dragFrame(JComponent f, int newX, int newY) {
|
||||||
|
parent.dragFrame( f, newX, newY );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endDraggingFrame(JComponent f) {
|
||||||
|
parent.endDraggingFrame( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beginResizingFrame(JComponent f, int direction) {
|
||||||
|
parent.beginResizingFrame( f, direction );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resizeFrame(JComponent f, int newX, int newY, int newWidth, int newHeight) {
|
||||||
|
parent.resizeFrame( f, newX, newY, newWidth, newHeight );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endResizingFrame(JComponent f) {
|
||||||
|
parent.endResizingFrame( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBoundsForFrame(JComponent f, int newX, int newY, int newWidth, int newHeight) {
|
||||||
|
parent.setBoundsForFrame( f, newX, newY, newWidth, newHeight );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user