-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from creme332/animation
add translation and rotation animations
- Loading branch information
Showing
8 changed files
with
175 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/github/creme332/utils/RequestFocusListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.github.creme332.utils; | ||
|
||
import java.awt.Component; | ||
import java.awt.Window; | ||
import java.awt.event.HierarchyEvent; | ||
import java.awt.event.HierarchyListener; | ||
import java.awt.event.WindowAdapter; | ||
import java.awt.event.WindowEvent; | ||
|
||
import javax.swing.SwingUtilities; | ||
|
||
/** | ||
* Focuses a component in a JOptionPane. By default, it is not possible to | ||
* request focus to a component inside a JOptionPane. | ||
* Reference: | ||
* https://bugs.openjdk.org/browse/JDK-5018574?focusedId=12217314&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-12217314 | ||
* | ||
*/ | ||
public class RequestFocusListener implements HierarchyListener { | ||
|
||
@Override | ||
public void hierarchyChanged(HierarchyEvent e) { | ||
final Component c = e.getComponent(); | ||
if (c.isShowing() && (e.getChangeFlags() & | ||
HierarchyEvent.SHOWING_CHANGED) != 0) { | ||
Window toplevel = SwingUtilities.getWindowAncestor(c); | ||
toplevel.addWindowFocusListener(new WindowAdapter() { | ||
@Override | ||
public void windowGainedFocus(WindowEvent e) { | ||
c.requestFocus(); | ||
} | ||
}); | ||
|
||
} | ||
} | ||
} |