001/* 002 * Copyright (c) 2004-2012, Willem Cazander 003 * All rights reserved. 004 * 005 * Redistribution and use in source and binary forms, with or without modification, are permitted provided 006 * that the following conditions are met: 007 * 008 * * Redistributions of source code must retain the above copyright notice, this list of conditions and the 009 * following disclaimer. 010 * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 011 * the following disclaimer in the documentation and/or other materials provided with the distribution. 012 * 013 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 014 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 015 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 016 * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 017 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 018 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 019 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 020 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 021 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 022 */ 023 024package org.x4o.xml.test.swixml; 025 026import java.awt.event.ActionEvent; 027 028import javax.swing.AbstractAction; 029import javax.swing.Action; 030import javax.swing.JOptionPane; 031 032import org.x4o.xml.test.swixml.SwiXmlParser.SwiXmlVersion; 033 034/** 035 * Accelerator2 test demo. 036 * 037 * see swixml sample; http://www.swixml.org/samples/src/Accelerator.java 038 * Added exitMethod and render boolean for unit testing. 039 * 040 * @author Willem Cazander 041 * @version 1.0 Aug 15, 2012 042 */ 043public class Accelerator2 { 044 045 protected static final String DESCRIPTOR = "tests/swixml/swixml-accelerator-2.0.xml"; 046 protected SwingEngine swix = new SwingEngine( this ); 047 048 public Accelerator2(boolean render) throws Exception { 049 if (render) { 050 swix.render( Accelerator2.DESCRIPTOR, SwiXmlVersion.VERSION_2 ).setVisible( true ); 051 } 052 } 053 054 @SuppressWarnings("serial") 055 public Action newAction = new AbstractAction() { 056 public void actionPerformed( ActionEvent e ) { 057 JOptionPane.showMessageDialog( swix.getRootComponent(), "Sorry, not implemented yet." ); 058 } 059 }; 060 061 @SuppressWarnings("serial") 062 public Action aboutAction = new AbstractAction() { 063 public void actionPerformed( ActionEvent e ) { 064 JOptionPane.showMessageDialog( swix.getRootComponent(), "This is the Accelerator Example." ); 065 } 066 }; 067 068 @SuppressWarnings("serial") 069 public Action exitAction = new AbstractAction() { 070 public void actionPerformed( ActionEvent e ) { 071 System.exit(0); 072 } 073 }; 074 075 public static void main( String[] args ) { 076 try { 077 new Accelerator2(true); 078 } catch (Exception e) { 079 e.printStackTrace(); 080 } 081 } 082}