/*
* VirtualNewsReaderApp.java
*/
/**
* @author kpham
*/
package virtualnewsreader;
import java.awt.Toolkit;
import java.util.EventObject;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
import javax.swing.*;
import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.watermark.SubstanceWoodWatermark;
import chrriis.common.UIUtils;
import chrriis.dj.nativeswing.swtimpl.NativeInterface;
import java.awt.Component;
/**
* The main class of the application.
*/
public class VirtualNewsReaderApp extends SingleFrameApplication {
/**
* At startup create and show the main frame of the application.
*/
VirtualNewsReaderView MainView;
@Override
protected void startup() {
addExitListener(new ExitListener() {
public boolean canExit(EventObject e) {
boolean bOkToExit = false;
Component source = (Component) e.getSource();
bOkToExit = JOptionPane.showConfirmDialog(source,
"Do you really want to exit?") ==
JOptionPane.YES_OPTION;
return bOkToExit;
}
public void willExit(EventObject event) {
}
});
MainView = new VirtualNewsReaderView(this);
show( MainView);
}
@Override
protected void ready() {
super.ready();
//Application is Ready
//Lets Start out with the browser Tab
((VirtualNewsReaderView) getMainView()).NewBrowser();
}
@Override
public VirtualNewsReaderView getMainView() {
return MainView;
}
@Override
public void exit(EventObject arg0) {
super.exit(arg0);
}
@Override
protected void shutdown() {
super.shutdown();
//close the model when exit.
((VirtualNewsReaderView) getMainView()).getModel().close();
}
/**
* This method is to initialize the specified window by injecting resources.
* Windows shown in our application come fully initialized from the GUI
* builder, so this additional configuration is not needed.
*/
@Override
protected void configureWindow(java.awt.Window root) {
}
/**
* A convenient static getter for the application instance.
* @return the instance of VirtualNewsReaderApp
*/
public static VirtualNewsReaderApp getApplication() {
return Application.getInstance(VirtualNewsReaderApp.class);
}
/**
* Main method launching the application.
*/
public static void main(String[] args) throws UnsupportedLookAndFeelException{
NativeInterface.open();
SubstanceLookAndFeel.setCurrentWatermark(new SubstanceWoodWatermark());
Toolkit.getDefaultToolkit().getSystemEventQueue().push( new PopupEventQueue() );
launch(VirtualNewsReaderApp.class, args);
}
}