All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tutorial.support.JTutorialFrame Maven / Gradle / Ivy

The newest version!
package tutorial.support;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JFrame;

import bibliothek.gui.DockController;
import bibliothek.gui.DockFrontend;

public class JTutorialFrame extends JFrame{
	private List runOnClose = new ArrayList();
	
	public JTutorialFrame( Class clazz ){
		setBounds( 40, 40, 800, 600 );
		
		Tutorial tutorial = (Tutorial)clazz.getAnnotation( Tutorial.class );
		setTitle( tutorial == null ? clazz.getSimpleName() : tutorial.title() );
		setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE );
		addWindowListener( new WindowAdapter(){
			public void windowClosing( WindowEvent e ){
				dispose();
				for( Runnable onClose : runOnClose ){
					onClose.run();
				}
			}
		});
	}
	
	public void runOnClose( Runnable run ){
		runOnClose.add( run );
	}
	
	public void destroyOnClose( final DockController controller ){
		runOnClose( new Runnable(){
			public void run(){
				controller.kill();
			}
		});
	}
	
	public void destroyOnClose( final DockFrontend frontend ){
		runOnClose( new Runnable(){
			public void run(){
				frontend.kill();	
			}
		});
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy