mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 06:50:56 +03:00
InternalFrame: double-click on icon in internal frame title bar now closes the internal frame (issue #374)
This commit is contained in:
@@ -1,13 +1,20 @@
|
|||||||
FlatLaf Change Log
|
FlatLaf Change Log
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
## 1.6-SNAPSHOT
|
||||||
|
|
||||||
|
#### New features and improvements
|
||||||
|
|
||||||
|
- InternalFrame: Double-click on icon in internal frame title bar now closes the
|
||||||
|
internal frame. (issue #374)
|
||||||
|
|
||||||
|
|
||||||
## 1.5
|
## 1.5
|
||||||
|
|
||||||
#### New features and improvements
|
#### New features and improvements
|
||||||
|
|
||||||
- SwingX: Added search and clear icons to `JXSearchField`. (issue #359)
|
- SwingX: Added search and clear icons to `JXSearchField`. (issue #359)
|
||||||
|
|
||||||
|
|
||||||
#### Fixed bugs
|
#### Fixed bugs
|
||||||
|
|
||||||
- Button and TextComponent: Do not apply minimum width/height if margins are
|
- Button and TextComponent: Do not apply minimum width/height if margins are
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import java.awt.Color;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.LayoutManager;
|
import java.awt.LayoutManager;
|
||||||
|
import java.awt.Rectangle;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
@@ -146,6 +147,19 @@ public class FlatInternalFrameTitlePane
|
|||||||
closeButton.setVisible( frame.isClosable() );
|
closeButton.setVisible( frame.isClosable() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle getFrameIconBounds() {
|
||||||
|
Icon icon = titleLabel.getIcon();
|
||||||
|
if( icon == null )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
int iconWidth = icon.getIconWidth();
|
||||||
|
int iconHeight = icon.getIconHeight();
|
||||||
|
boolean leftToRight = titleLabel.getComponentOrientation().isLeftToRight();
|
||||||
|
int x = titleLabel.getX() + (leftToRight ? 0 : (titleLabel.getWidth() - iconWidth));
|
||||||
|
int y = titleLabel.getY() + ((titleLabel.getHeight() - iconHeight) / 2);
|
||||||
|
return new Rectangle( x, y, iconWidth, iconHeight );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does nothing because FlatLaf internal frames do not have system menus.
|
* Does nothing because FlatLaf internal frames do not have system menus.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -22,10 +22,13 @@ import java.awt.Component;
|
|||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JInternalFrame;
|
import javax.swing.JInternalFrame;
|
||||||
import javax.swing.LookAndFeel;
|
import javax.swing.LookAndFeel;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.event.MouseInputAdapter;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicInternalFrameUI;
|
import javax.swing.plaf.basic.BasicInternalFrameUI;
|
||||||
|
|
||||||
@@ -122,6 +125,11 @@ public class FlatInternalFrameUI
|
|||||||
return new FlatWindowResizer.InternalFrameResizer( frame, this::getDesktopManager );
|
return new FlatWindowResizer.InternalFrameResizer( frame, this::getDesktopManager );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected MouseInputAdapter createBorderListener( JInternalFrame w ) {
|
||||||
|
return new FlatBorderListener();
|
||||||
|
}
|
||||||
|
|
||||||
//---- class FlatInternalFrameBorder --------------------------------------
|
//---- class FlatInternalFrameBorder --------------------------------------
|
||||||
|
|
||||||
public static class FlatInternalFrameBorder
|
public static class FlatInternalFrameBorder
|
||||||
@@ -195,4 +203,26 @@ public class FlatInternalFrameUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---- class FlatBorderListener -------------------------------------------
|
||||||
|
|
||||||
|
protected class FlatBorderListener
|
||||||
|
extends BorderListener
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void mouseClicked( MouseEvent e ) {
|
||||||
|
if( e.getClickCount() == 2 && !frame.isIcon() &&
|
||||||
|
e.getSource() instanceof FlatInternalFrameTitlePane )
|
||||||
|
{
|
||||||
|
Rectangle iconBounds = ((FlatInternalFrameTitlePane)e.getSource()).getFrameIconBounds();
|
||||||
|
if( iconBounds != null && iconBounds.contains( e.getX(), e.getY() ) ) {
|
||||||
|
if( frame.isClosable() )
|
||||||
|
frame.doDefaultCloseAction();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.mouseClicked( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user