/*
* [Internationaliser.java]
*
* Summary: Mockup of how the Internationaliser might look.
*
* Copyright: (c) 2006-2017 Roedy Green, Canadian Mind Products, http://mindprod.com
*
* Licence: This software may be copied and used freely for any purpose but military.
* http://mindprod.com/contact/nonmil.html
*
* Requires: JDK 1.8+
*
* Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/
*
* Version History:
* 1.1 2006-03-05
*/
package com.mindprod.internationaliser;
import com.mindprod.common18.HybridJ;
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
/**
* Mockup of how the Internationaliser might look.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.1 2006-03-05
* @since 2006
*/
public final class Internationaliser extends JApplet
{
/**
* height of entire Applet
*/
private static final int APPLET_HEIGHT = 280;
/**
* width of entire Applet
*/
private static final int APPLET_WIDTH = 250;
private static final int FIRST_COPYRIGHT_YEAR = 2006;
/**
* undisplayed copyright notice
*/
private static final String EMBEDDED_COPYRIGHT =
"Copyright: (c) 2006-2017 Roedy Green, Canadian Mind Products, http://mindprod.com";
private static final String RELEASE_DATE = "2006-03-06";
/**
* title
*/
private static final String TITLE_STRING = "Internationaliser Demo";
/**
* version
*/
private static final String VERSION_STRING = "1.1";
/**
* This is the default constructor
*/
public Internationaliser()
{
super();
}
/**
* Allow this JApplet to run as as application as well.
*
* @param args command line arguments ignored.
*/
public static void main( String args[] )
{
HybridJ.fireup( new Internationaliser(),
TITLE_STRING + " " + VERSION_STRING,
APPLET_WIDTH,
APPLET_HEIGHT );
}
/**
* Called by the browser or Applet viewer to inform
* this Applet that it has been loaded into the system.
*/
@Override
public void init()
{
/**
* we have a five level hierarchy:
* task
* project
* ResourceBundle
* locale
* translationitemlevel1
* translationitemlevel2
*/
// create the tree of nodes.
DefaultMutableTreeNode root = new DefaultMutableTreeNode( "root" );
DefaultMutableTreeNode task1 =
new DefaultMutableTreeNode( "task: high priority" );
root.add( task1 );
DefaultMutableTreeNode project11 =
new DefaultMutableTreeNode( "project: Great Bear" );
task1.add( project11 );
DefaultMutableTreeNode resource111 =
new DefaultMutableTreeNode( "resource: Wind" );
project11.add( resource111 );
DefaultMutableTreeNode locale1111 =
new DefaultMutableTreeNode( "locale: sr_YU_CYR" );
resource111.add( locale1111 );
DefaultMutableTreeNode majorKey11111 =
new DefaultMutableTreeNode( "translate: buildings" );
locale1111.add( majorKey11111 );
DefaultMutableTreeNode minorKey111111 =
new DefaultMutableTreeNode( "house" );
majorKey11111.add( minorKey111111 );
DefaultMutableTreeNode minorKey111112 =
new DefaultMutableTreeNode( "school" );
majorKey11111.add( minorKey111112 );
DefaultMutableTreeNode minorKey111113 =
new DefaultMutableTreeNode( "shopping centre" );
majorKey11111.add( minorKey111113 );
DefaultMutableTreeNode majorKey11112 =
new DefaultMutableTreeNode( "translate: vehicles" );
locale1111.add( majorKey11112 );
DefaultMutableTreeNode minorKey111121 =
new DefaultMutableTreeNode( "bicycle" );
majorKey11112.add( minorKey111121 );
DefaultMutableTreeNode minorKey111122 =
new DefaultMutableTreeNode( "hydrid car" );
majorKey11112.add( minorKey111122 );
DefaultMutableTreeNode locale1112 =
new DefaultMutableTreeNode( "locale: de_DE" );
resource111.add( locale1112 );
DefaultMutableTreeNode majorKey11121 =
new DefaultMutableTreeNode( "translate: buildings" );
locale1112.add( majorKey11121 );
DefaultMutableTreeNode minorKey111211 =
new DefaultMutableTreeNode( "house" );
majorKey11121.add( minorKey111211 );
DefaultMutableTreeNode minorKey111212 =
new DefaultMutableTreeNode( "school" );
majorKey11121.add( minorKey111212 );
DefaultMutableTreeNode minorKey111213 =
new DefaultMutableTreeNode( "shopping centre" );
majorKey11121.add( minorKey111213 );
DefaultMutableTreeNode task2 =
new DefaultMutableTreeNode( "low priority" );
DefaultMutableTreeNode project21 =
new DefaultMutableTreeNode( "project: Great Bear" );
task2.add( project21 );
DefaultMutableTreeNode resource211 =
new DefaultMutableTreeNode( "resource: Waves" );
project21.add( resource211 );
DefaultMutableTreeNode locale2111 =
new DefaultMutableTreeNode( "locale: en_CA" );
resource211.add( locale2111 );
DefaultMutableTreeNode majorKey21111 =
new DefaultMutableTreeNode( "translate: appliances" );
locale2111.add( majorKey21111 );
DefaultMutableTreeNode minorKey211111 =
new DefaultMutableTreeNode( "toaster" );
majorKey21111.add( minorKey211111 );
DefaultMutableTreeNode minorKey211112 =
new DefaultMutableTreeNode( "kettle" );
majorKey21111.add( minorKey211112 );
root.add( task2 );
// build the JTree itself from the tree structure of DefaultTreeNodes
JTree tree = new JTree( root );
// customise the leaf icon
DefaultTreeCellRenderer customCellRenderer =
new DefaultTreeCellRenderer();
// icon bundled in jar as com.mindprod.internationaliser.translate.png
customCellRenderer.setLeafIcon( new ImageIcon( Internationaliser.class
.getResource( "translateicon.png" ) ) );
tree.setCellRenderer( customCellRenderer );
// hide the root node
tree.setRootVisible( false );
// reveal the handles on the new roots
tree.setShowsRootHandles( true );
// let it scroll
this.add( new JScrollPane( tree ) );
this.validate();
this.setVisible( true );
}
}