Interface SwingApplication


public interface SwingApplication
Swingapplication interface to open and control a swing application.
Example:
 componentFactory = new ComponentFactory() {
                public Component createComponent() {
                        return new JLabel("Swing app component");
                }
        };
 config = SwingApplicationConfiguration.CONFIG_GENERATOR.get().
               title("SwingApplication")).
               componentFactory(componentFactory);
 appService = servicesBroker.getService(ApplicationService.class);
 swingApp = appService.openApplication(SwingApplication.TYPE,  config).getApplication().getApplication();
 
Since:
4.2.416
Example:
Example how to create a multi application
import de.espirit.firstspirit.client.gui.applications.*;

import de.espirit.firstspirit.access.ServicesBroker;
import de.espirit.firstspirit.client.gui.applications.SwingApplicationConfiguration.ComponentFactory;

import javax.swing.JLabel;


/**
 * Examples how to use a swing application
 *
 * @since 4.2.416
 */
public class SwingApplicationExample {

	/**
	 * Creates a swing application tab.
	 *
	 * @param title the title used for the application tab
	 * @return the created application
	 * @since 4.2.416
	 */
	public SwingApplication createSwingApplication(final ServicesBroker servicesBroker, final String title) {

		// get the applicationservice from servicesBroker
		final ApplicationService appService = servicesBroker.getService(ApplicationService.class);


		// create a new swing application configuration
		final SwingApplicationConfiguration swingConfig = SwingApplicationConfiguration.GENERATOR.invoke()
				.title(title)
				.componentFactory(new ComponentFactory<MyLabel>() {
					public MyLabel createComponent() {
						return new MyLabel("Swing app component");
					}


					public void dispose(final MyLabel label) {
						label.cleanUp();
					}
				});

		// open an application tab of type multitab
		final ApplicationTab<SwingApplication> swingTab = appService.openApplication(SwingApplication.TYPE, swingConfig);

		return swingTab.getApplication();
	}


	public static class MyLabel extends JLabel {

		public MyLabel(final String label) {
			super(label);
		}


		public void cleanUp() {
			// clean up resources
		}
	}
}