com.github.rickyclarkson.swingflow.Windows Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swingflow Show documentation
Show all versions of swingflow Show documentation
A library to display and control workflows in Swing
package com.github.rickyclarkson.swingflow;
import fj.data.Option;
import javax.swing.JWindow;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Windows {
public static Option findAncestor(Component component, Class ancestorClass) {
while (component != null) {
if (ancestorClass.isInstance(component))
return Option.some(ancestorClass.cast(component));
component = component.getParent();
}
return Option.none();
}
public static ActionListener close(final JWindow window) {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
window.setVisible(false);
}
};
}
}