JavaBeat

  • Home
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Privacy

Window System in NetBeans Platform 6.9

September 17, 2009 by Krishna Srinivasan Leave a Comment

Automatic window lifecycle management

  • Buy NetBeans Books from Java Books Store

A further major advantage of the NetBeans Window System is that it provides
a WindowManager that controls the lifecycle of all the windows defined in the
application. The WindowManager notifies all TopComponents about state changes
using callback methods, listed as follows:

 

 

 

 

Let’s illustrate this lifecycle via an example that logs all the callback methods to the
output window of NetBeans IDE, which is your development environment on top of
the NetBeans Platform 6.9.

  1. Create a new NetBeans Platform 6.9 application and name it
    WindowSystemExamples.
  2. Add a new module named LifeCycle, with Code Name Base
    com.netbeansrcp.lifecycle.
  3. Add a TopComponent, with Class Name Prefix prefix LifeCycleDemo,
    making sure to indicate that it should be automatically opened in the editor
    area at application startup.
  4. Override the lifecycle methods as follows:

	public void componentOpened() {
		super.componentOpened();
		System.out.println("componentOpened()");
	}
	protected void componentShowing() {
		super.componentShowing();
		System.out.println("componentShowing()");
	}
	protected void componentActivated() {
		super.componentActivated();
		System.out.println("componentActivated()");
	}
	@Override
	protected void componentDeactivated() {
		super.componentDeactivated();
		System.out.println("componentDeactivated()");
	}
	@Override
	protected void componentHidden() {
		super.componentHidden();
		System.out.println("componentHidden()");
	}
	@Override
	public void componentClosed() {
		super.componentClosed();
		System.out.println("componentClosed()");
	}

Start the new application. The TopComponent LifeCyleDemoTopComponent is
automatically opened at startup. Select the TopComponent and inspect the output
in the NetBeans IDE Output Window. You should see the following:


	componentOpened()
	componentShowing()
	componentActivated()

The TopComponent has passed the first half of its lifecycle and is now activated.

Close the LifeCyleDemoTopComponent and inspect the output again, to understand
the second half of the TopComponent lifecycle. You should see the following output:


	componentHidden()
	componentDeactivated()
	componentClosed()

You have learned that the TopComponent’s lifecycle is automatically controlled
by the NetBeans Platform 6.9. Between the start and the end of the TopComponent’s
lifecycle are six different states, all managed by the NetBeans Platform 6.9, and with
notifications sent via callbacks.

NetBeans Articles

  • Create EJB 3.0 project in NetBeans 6.1
  • JPA in NetBeans 6.1 by SriHari
  • NetBeans Articles
  • NetBeans Links
  • Buy NetBeans Books from Java Books Store
Pages: 1 2 3 4

Filed Under: NetBeans Tagged With: Window

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Follow Us

  • Facebook
  • Pinterest

As a participant in the Amazon Services LLC Associates Program, this site may earn from qualifying purchases. We may also earn commissions on purchases from other retail websites.

JavaBeat

FEATURED TUTORIALS

Answered: Using Java to Convert Int to String

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Copyright © by JavaBeat · All rights reserved