[sword-svn] r95 - in trunk: .settings app/src/org/crosswire/common/swing app/src/org/crosswire/flashcards app/src/org/crosswire/modedit

Apache apache at www.crosswire.org
Sat Dec 2 15:43:51 MST 2006


Author: 
Date: 2006-12-02 15:43:50 -0700 (Sat, 02 Dec 2006)
New Revision: 95

Added:
   trunk/.settings/org.eclipse.jdt.ui.prefs
Modified:
   trunk/app/src/org/crosswire/common/swing/RowTable.java
   trunk/app/src/org/crosswire/common/swing/SortRenderer.java
   trunk/app/src/org/crosswire/flashcards/Debug.java
   trunk/app/src/org/crosswire/flashcards/EditPane.java
   trunk/app/src/org/crosswire/flashcards/Editor.java
   trunk/app/src/org/crosswire/flashcards/EditorFrame.java
   trunk/app/src/org/crosswire/flashcards/EditorFrame_AboutBox.java
   trunk/app/src/org/crosswire/flashcards/FlashCard.java
   trunk/app/src/org/crosswire/flashcards/FlashCardColumns.java
   trunk/app/src/org/crosswire/flashcards/FlashCardEditor.java
   trunk/app/src/org/crosswire/flashcards/FlashCardPane.java
   trunk/app/src/org/crosswire/flashcards/FlashCardRep.java
   trunk/app/src/org/crosswire/flashcards/Lesson.java
   trunk/app/src/org/crosswire/flashcards/LessonManager.java
   trunk/app/src/org/crosswire/flashcards/LessonPane.java
   trunk/app/src/org/crosswire/flashcards/LessonSet.java
   trunk/app/src/org/crosswire/flashcards/LessonSetPane.java
   trunk/app/src/org/crosswire/flashcards/MainFrame.java
   trunk/app/src/org/crosswire/flashcards/MainFrame_AboutBox.java
   trunk/app/src/org/crosswire/flashcards/MainMenu.java
   trunk/app/src/org/crosswire/flashcards/OpenFile.java
   trunk/app/src/org/crosswire/flashcards/Quiz.java
   trunk/app/src/org/crosswire/flashcards/QuizPane.java
   trunk/app/src/org/crosswire/flashcards/SetupPane.java
   trunk/app/src/org/crosswire/modedit/CGreekIM.java
   trunk/app/src/org/crosswire/modedit/GreekKeymanIM.java
   trunk/app/src/org/crosswire/modedit/HebrewDurusauIM.java
   trunk/app/src/org/crosswire/modedit/UniTextEdit.java
Log:
clean up of warnings from checkstyle, findbugs and pmd

Added: trunk/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- trunk/.settings/org.eclipse.jdt.ui.prefs	                        (rev 0)
+++ trunk/.settings/org.eclipse.jdt.ui.prefs	2006-12-02 22:43:50 UTC (rev 95)
@@ -0,0 +1,5 @@
+#Sun Nov 26 07:18:49 EST 2006
+eclipse.preferences.version=1
+org.eclipse.jdt.ui.exception.name=e
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.overrideannotation=true

Modified: trunk/app/src/org/crosswire/common/swing/RowTable.java
===================================================================
--- trunk/app/src/org/crosswire/common/swing/RowTable.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/common/swing/RowTable.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -142,7 +142,7 @@
         if (first != -1)
         {
             final Rectangle bounds = getRowBounds(aTable, first, last);
-            if (isVerticallyVisible(aTable, bounds) == false)
+            if (!isVerticallyVisible(aTable, bounds))
             {
                 // Is SwingUtilities.invokeLater needed ???
                 aTable.scrollRectToVisible(bounds);
@@ -276,8 +276,7 @@
         final JTableHeader th = getTableHeader();
         final TableCellRenderer renderer = th.getDefaultRenderer();
         Component comp = renderer.getTableCellRendererComponent(this, ONE_STANDARD_CHARACTER, false, false, 0, 0);
-        final int height = comp.getPreferredSize().height;
-        return height;
+        return comp.getPreferredSize().height;
     }
 
     /**

Modified: trunk/app/src/org/crosswire/common/swing/SortRenderer.java
===================================================================
--- trunk/app/src/org/crosswire/common/swing/SortRenderer.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/common/swing/SortRenderer.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -37,81 +37,81 @@
  */
 public class SortRenderer extends DefaultTableCellRenderer {
 
-	/**
+    /**
      * Serialization ID
      */
     private static final long serialVersionUID = 7280299308536170406L;
     /**
-	 * Field pressedColumn
-	 */
-	private TableColumn pressedColumn;
-	/**
-	 * Field model
-	 */
-	private RowTableModel model;
+     * Field pressedColumn
+     */
+    private TableColumn pressedColumn;
+    /**
+     * Field model
+     */
+    private RowTableModel model;
 
-	/**
-	 * Constructor for SortRenderer
-	 * @param stm SegmentTableModel
-	 */
-	public SortRenderer(RowTableModel stm) {
-		model = stm;
-		pressedColumn = null;
-		setHorizontalAlignment(SwingConstants.CENTER);
-	}
+    /**
+     * Constructor for SortRenderer
+     * @param stm SegmentTableModel
+     */
+    public SortRenderer(RowTableModel stm) {
+        model = stm;
+        pressedColumn = null;
+        setHorizontalAlignment(SwingConstants.CENTER);
+    }
 
-	/**
-	 * Method getTableCellRendererComponent
-	 * @param table JTable
-	 * @param value Object
-	 * @param isSelected boolean
-	 * @param hasFocus boolean
-	 * @param row int
-	 * @param column int
-	 * @return Component
-	 */
-	public Component getTableCellRendererComponent(
-		JTable table,
-		Object value,
-		boolean isSelected,
-		boolean hasFocus,
-		int row,
-		int column) {
-		if (table != null) {
-			setToolTipText(model.getHeaderToolTip(column));
-			final JTableHeader header = table.getTableHeader();
-			final TableColumn tableColumn = table.getColumnModel().getColumn(column);
-			if (header != null) {
-				setForeground(header.getForeground());
-				setBackground(header.getBackground());
-				final Font headerFont = header.getFont();
-				if (tableColumn == pressedColumn) {
-					setFont(headerFont.deriveFont(Font.ITALIC));
-				} else {
-					setFont(headerFont);
-				}
-			}
-		}
+    /**
+     * Method getTableCellRendererComponent
+     * @param table JTable
+     * @param value Object
+     * @param isSelected boolean
+     * @param hasFocus boolean
+     * @param row int
+     * @param column int
+     * @return Component
+     */
+    public Component getTableCellRendererComponent(
+        JTable table,
+        Object value,
+        boolean isSelected,
+        boolean hasFocus,
+        int row,
+        int column) {
+        if (table != null) {
+            setToolTipText(model.getHeaderToolTip(column));
+            final JTableHeader header = table.getTableHeader();
+            final TableColumn tableColumn = table.getColumnModel().getColumn(column);
+            if (header != null) {
+                setForeground(header.getForeground());
+                setBackground(header.getBackground());
+                final Font headerFont = header.getFont();
+                if (tableColumn == pressedColumn) {
+                    setFont(headerFont.deriveFont(Font.ITALIC));
+                } else {
+                    setFont(headerFont);
+                }
+            }
+        }
 
-		setText((value == null) ? "" : value.toString()); //$NON-NLS-1$
-		setBorder(UIManager.getBorder("TableHeader.cellBorder")); //$NON-NLS-1$
-		return this;
-	}
+        setText((value == null) ? "" : value.toString()); //$NON-NLS-1$
+        setBorder(UIManager.getBorder("TableHeader.cellBorder")); //$NON-NLS-1$
+        return this;
+    }
 
-	/**
-	 * Method getPressedColumn
-	 * @return the table column
-	 */
-	public TableColumn getPressedColumn() {
-		return pressedColumn;
-	}
+    /**
+     * Method getPressedColumn
+     * @return the table column
+     */
+    public TableColumn getPressedColumn() {
+        return pressedColumn;
+    }
 
-	/**
-	 * Method setPressedColumn
-	 * @param tc the table column
-	 */
-	public void setPressedColumn(TableColumn tc) {
-		pressedColumn = tc;
-	}
+    /**
+     * Method setPressedColumn
+     * @param tc the table column
+     */
+    public void setPressedColumn(TableColumn tc) {
+        pressedColumn = tc;
+    }
 
 }
\ No newline at end of file

Modified: trunk/app/src/org/crosswire/flashcards/Debug.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/Debug.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/Debug.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -45,6 +45,9 @@
     private static boolean error = true;
     private static PrintStream printStream = System.err;
 
+    // Singleton class
+    private Debug() {}
+
     //
     // Methods
     //
@@ -92,7 +95,7 @@
     // ---------------
     static void trace( String identity, String message ) {
 
-        if( null != printStream && false != trace && false != enabled ) {
+        if( null != printStream && trace && enabled ) {
 
             Debug.printStream.print( " TRACE : " + identity + " : " +
                                      Thread.currentThread( ) + "\n" + message );
@@ -104,7 +107,7 @@
     // ---------------
     static void inform( String identity, String message ) {
 
-        if( null != printStream && false != inform && false != enabled ) {
+        if( null != printStream && inform && enabled ) {
 
             Debug.printStream.print( "INFORM : " + identity + " : " +
                                      Thread.currentThread( ) + "\n" + message );
@@ -116,7 +119,7 @@
     // ---------------
     static void warn( String identity, String message ) {
 
-        if( null != printStream && false != warn && false != enabled ) {
+        if( null != printStream && warn && enabled ) {
 
             Debug.printStream.print( "  WARN : " + identity + " : " +
                                      Thread.currentThread( ) + "\n" + message );
@@ -128,7 +131,7 @@
     // ---------------
     static void error( String identity, String message ) {
 
-        if( null != printStream && false != error ) {
+        if( null != printStream && error ) {
 
             Debug.printStream.print( " ERROR : " + identity + " : " +
                                      Thread.currentThread( ) + "\n" + message );

Modified: trunk/app/src/org/crosswire/flashcards/EditPane.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/EditPane.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/EditPane.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -51,17 +51,10 @@
     //Construct the frame
     public EditPane()
     {
-        try
-        {
-            jbInit();
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
+        jbInit();
     }
 
-    private void jbInit() throws Exception
+    private void jbInit()
     {
         setLayout(new BorderLayout());
         setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
@@ -69,7 +62,7 @@
 
         final LessonSetPane lessonSetPanel = new LessonSetPane(true);
         final LessonPane lessonPanel = new LessonPane(true);
-        final FlashCardPane flashCardPanel = new FlashCardPane(true);
+        final FlashCardPane flashCardPanel = new FlashCardPane();
         final FlashCardEditor flashCardEditor = new FlashCardEditor();
         final JButton saveButton = new JButton("Save");
 

Modified: trunk/app/src/org/crosswire/flashcards/Editor.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/Editor.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/Editor.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -45,15 +45,21 @@
     //
 
     // ---------------
-    public Editor(LessonManager lessonManager, boolean standAlone ) {
+    public Editor(boolean standAlone) {
 
-        EditorFrame frame = new EditorFrame( standAlone );
+        EditorFrame frame = new EditorFrame(standAlone);
 
         //Validate frames that have preset sizes
         //Pack frames that have useful preferred size info, e.g. from their layout
 
-        if( packFrame ) { frame.pack( ); }
-        else { frame.validate( ); }
+        if (packFrame)
+        {
+            frame.pack();
+        }
+        else
+        {
+            frame.validate( );
+        }
 
         //Center the window
 
@@ -83,30 +89,26 @@
 
         // Parse the command line arguments
 
-        for( int index = 0; arguments.length > index; ++ index ) {
-
-            if( ( arguments [ index ] ).equals( "-debug" ) ) {
-
+        for (int index = 0; arguments.length > index; ++index)
+        {
+            if (arguments[index].equals("-debug"))
+            {
                 Debug.setEnabled( true );
-
             }
-
         }
 
         // Set the "Look And Feel"
-
-        try {
-
+        try 
+        {
             UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName( ) );
-
-        } catch( Exception exception ) {
-
-            exception.printStackTrace( );
-
         }
+        catch (Exception exception)
+        {
+            exception.printStackTrace(System.err);
+        }
 
-        new Editor(LessonManager.instance(), true );
-
+        LessonManager.instance();
+        new Editor(true);
     }
 
 }

Modified: trunk/app/src/org/crosswire/flashcards/EditorFrame.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/EditorFrame.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/EditorFrame.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -33,6 +33,7 @@
 import java.awt.AWTEvent;
 import java.awt.BorderLayout;
 import java.awt.ComponentOrientation;
+import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.FlowLayout;
 import java.awt.GridLayout;
@@ -41,11 +42,13 @@
 import java.awt.event.WindowEvent;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Properties;
-import java.util.Vector;
 
 import javax.swing.ImageIcon;
 import javax.swing.JButton;
@@ -70,7 +73,7 @@
     //
     String cwdPath = "./";
 
-    JPanel contentPane;
+    Container contentPane;
     JToolBar jToolBar = new JToolBar();
     JButton jButton1 = new JButton();
     JButton jButton2 = new JButton();
@@ -102,7 +105,7 @@
     JTextField answers = new JTextField();
     JPanel jPanel7 = new JPanel();
     BorderLayout borderLayout6 = new BorderLayout();
-    Vector words = new Vector();
+    List words = new ArrayList();
     UniTextEdit wordText = new UniTextEdit();
     private boolean standAlone;
 
@@ -130,21 +133,15 @@
         this.standAlone = standAlone;
         enableEvents( AWTEvent.WINDOW_EVENT_MASK );
 
-        try { jbInit( ); }
-        catch( Exception exception ) {
-
-            Debug.error( this.toString( ), exception.getMessage( ) );
-
-        }
-
+        jbInit( );
     }
 
     //Component initialization
-    private void jbInit() throws Exception  {
+    private void jbInit() {
         image1 = new ImageIcon(EditorFrame.class.getResource("openFile.png"));
         image2 = new ImageIcon(EditorFrame.class.getResource("closeFile.png"));
         image3 = new ImageIcon(EditorFrame.class.getResource("saveDoc.png"));
-        contentPane = (JPanel) this.getContentPane();
+        contentPane = this.getContentPane();
         contentPane.setLayout(borderLayout1);
         this.setSize(new Dimension(512, 300));
         this.setTitle("Editor");
@@ -254,7 +251,7 @@
         lesson.setProperty("fileName", "NewLesson.flash");
         lesson.setProperty("lessonTitle", "New Lesson");
         lesson.setProperty("wordCount", "0");
-        words = new Vector();
+        words = new ArrayList();
         words.add(new WordEntry(" "));
         showLesson();
     }
@@ -266,23 +263,30 @@
 
         lesson = new Properties( );
 
+        InputStream inStream = null;
         try {
+            inStream = new FileInputStream(lessonFileName);
+            lesson.load(inStream);
 
-            lesson.load( new FileInputStream( lessonFileName ) );
-
-        } catch( Exception e ) {
-
-            e.printStackTrace( );
-
+        } catch(IOException e) {
+            Debug.error(this.getClass().getName(), e.getMessage());
+        } finally {
+            if (inStream != null) {
+                try {
+                    inStream.close();
+                } catch (IOException e) {
+                    Debug.error(this.getClass().getName(), e.getMessage());
+                }
+            }
         }
 
-        words = new Vector( );
-        int wordCount = Integer.parseInt( lesson.getProperty( "wordCount" ) );
+        words = new ArrayList( );
+        int wordCount = Integer.parseInt(lesson.getProperty("wordCount"));
 
-        for( int i = 0; i < wordCount; ++ i ) {
+        for(int i = 0; i < wordCount; ++i) {
 
-            words.add( new WordEntry( lesson.getProperty( "word" + Integer.toString( i ) ),
-                                      lesson.getProperty( "answers" + Integer.toString( i ) ) ) );
+            words.add( new WordEntry(lesson.getProperty("word" + Integer.toString(i)),
+                                     lesson.getProperty("answers" + Integer.toString(i))));
 
         }
 
@@ -292,6 +296,7 @@
 
 
     private void saveLesson() {
+        OutputStream outStream = null;
         try {
             lesson.setProperty("wordCount", Integer.toString(words.size()));
             for (int i = 0; i < words.size(); i++) {
@@ -299,9 +304,19 @@
                 lesson.setProperty("word"+Integer.toString(i), we.word);
                 lesson.setProperty("answers"+Integer.toString(i), we.answers);
             }
-            lesson.store(new FileOutputStream(cwdPath + "/" + lesson.getProperty("fileName")),
-                         "Flash Lesson");
-        } catch (IOException ex) { ex.printStackTrace(); }
+            outStream = new FileOutputStream(cwdPath + "/" + lesson.getProperty("fileName"));
+            lesson.store(outStream, "Flash Lesson");
+        } catch (IOException ex) {
+            Debug.error(this.getClass().getName(), ex.getMessage());
+        } finally {
+            if (outStream != null) {
+                try {
+                    outStream.close();
+                } catch (IOException e) {
+                    Debug.error(this.getClass().getName(), e.getMessage());
+                }
+            }
+        }
     }
 
     ////////////////////////////
@@ -309,7 +324,7 @@
 
         setTitle( "FlashCards Editor (c) CrossWire Bible Society http://crosswire.org - " +
                   lesson.getProperty( "fileName" ) );
-        wordList.setListData( words );
+        wordList.setListData( words.toArray() );
         wordList.setSelectedIndex( 0 );
         wordList.addListSelectionListener( new EditorFrame_wordList_listSelectionAdapter( this ) );
         String fName = lesson.getProperty( "fileName" );
@@ -327,9 +342,7 @@
                 wordText.loadFont( new FileInputStream( fontPath.getText( ) ) );
 
             } catch( Exception exception ) {
-
-                exception.printStackTrace( );
-
+                Debug.error(this.getClass().getName(), exception.getMessage());
             }
 
         }
@@ -375,21 +388,14 @@
 
     void jButton1_actionPerformed(ActionEvent e) {
         JFileChooser dialog = new JFileChooser();
-        dialog.setFileFilter(new FileFilter() {
-                public boolean accept(File f) {
-                    if (f.isDirectory()) return true;
-                    else if (f.getName().endsWith(".flash")) return true;
-                    return false;
-                }
-                public String getDescription() { return "Flash Card Lessons"; }
-            });
+        dialog.setFileFilter(new FlashFileFilter());
         dialog.setCurrentDirectory(new File(cwdPath));
         if (dialog.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
             try {
                 loadLesson(dialog.getSelectedFile().getCanonicalPath());
                 cwdPath = dialog.getCurrentDirectory().getCanonicalPath();
             } catch( IOException ioe ) {
-                ioe.printStackTrace( );
+                Debug.error(this.getClass().getName(), ioe.getMessage());
             }
         }
     }
@@ -400,29 +406,34 @@
 
     void jButton6_actionPerformed(ActionEvent e) {
         JFileChooser dialog = new JFileChooser();
-        dialog.setFileFilter(new FileFilter() {
-                public boolean accept(File f) {
-                    if (f.isDirectory()) return true;
-                    else if (f.getName().endsWith(".ttf")) return true;
-                    return false;
-                }
-                public String getDescription() { return "TrueType Font"; }
-            });
+        dialog.setFileFilter(new TTFFileFilter());
         dialog.setCurrentDirectory(new File("./"));
         if (dialog.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
             lesson.setProperty("font", dialog.getSelectedFile().getName());
             fontPath.setText(lesson.getProperty("font"));
+            InputStream inStream = null;
             try {
-                wordText.loadFont(new FileInputStream(fontPath.getText()));
+                inStream = new FileInputStream(fontPath.getText());
+                wordText.loadFont(inStream);
             }
-            catch (FileNotFoundException ex) { ex.printStackTrace(); }
+            catch (Exception ex) {
+                Debug.error(this.getClass().getName(), ex.getMessage());
+            } finally {
+                if (inStream != null) {
+                    try {
+                        inStream.close();
+                    } catch (IOException e1) {
+                        Debug.error(this.getClass().getName(), e1.getMessage());
+                    }
+                }
+            }
         }
 
     }
 
     void addButton_actionPerformed(ActionEvent e) {
         words.add(new WordEntry(" "));
-        wordList.setListData(words);
+        wordList.setListData(words.toArray());
         wordList.setSelectedIndex(words.size()-1);
         wordText.requestFocus();
         wordText.setText("");
@@ -430,7 +441,7 @@
 
     void updateWordList() {
         int currentWord = wordList.getSelectedIndex();
-        wordList.setListData(words);
+        wordList.setListData(words.toArray());
         wordList.setSelectedIndex(currentWord);
 
     }
@@ -494,6 +505,19 @@
             updateWordList();
         }
     }
+    static class FlashFileFilter extends FileFilter {
+        public boolean accept(File f) {
+            return f.isDirectory() || f.getName().endsWith(".flash");
+        }
+        public String getDescription() { return "Flash Card Lessons"; }
+    }
+
+    static class TTFFileFilter extends FileFilter {
+        public boolean accept(File f) {
+            return f.isDirectory() || f.getName().endsWith(".ttf");
+        }
+        public String getDescription() { return "TrueType Font"; }
+    }
 }
 
 class EditorFrame_jButton1_actionAdapter implements java.awt.event.ActionListener {

Modified: trunk/app/src/org/crosswire/flashcards/EditorFrame_AboutBox.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/EditorFrame_AboutBox.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/EditorFrame_AboutBox.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -71,15 +71,10 @@
   public EditorFrame_AboutBox(Frame parent) {
     super(parent);
     enableEvents(AWTEvent.WINDOW_EVENT_MASK);
-    try {
-      jbInit();
-    }
-    catch(Exception e) {
-      e.printStackTrace();
-    }
+    jbInit();
   }
   //Component initialization
-  private void jbInit() throws Exception  {
+  private void jbInit()  {
     image1 = new ImageIcon(EditorFrame.class.getResource("about.png"));
     imageLabel.setIcon(image1);
     this.setTitle("About");

Modified: trunk/app/src/org/crosswire/flashcards/FlashCard.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/FlashCard.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/FlashCard.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -20,7 +20,9 @@
  */
 package org.crosswire.flashcards;
 
+import java.io.Serializable;
 
+
 /**
  * A FlashCard has a front and a back. The front has the test
  * and the back has the answer.
@@ -28,7 +30,7 @@
  * @author Troy A. Griffitts [scribe at crosswire dot org]
  * @author DM Smith [ dmsmith555 at yahoo dot com]
  */
-public class FlashCard implements Cloneable, Comparable
+public class FlashCard implements Cloneable, Comparable, Serializable
 {
     /**
      * Create a partial FlashCard.
@@ -152,9 +154,13 @@
     public boolean equals(Object obj)
     {
         if (obj == this)
+        {
             return true;
+        }
         if (!(obj instanceof FlashCard))
+        {
             return false;
+        }
         FlashCard otherCard = (FlashCard) obj;
         return copy.equals(otherCard.copy);
     }
@@ -186,4 +192,9 @@
 
     private FlashCardRep original;
     private FlashCardRep copy;
+
+    /**
+     * Serialization ID
+     */
+    private static final long serialVersionUID = -4429061155097506281L;
 }

Modified: trunk/app/src/org/crosswire/flashcards/FlashCardColumns.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/FlashCardColumns.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/FlashCardColumns.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -101,7 +101,7 @@
      */
     public String[] getHeaders()
     {
-        return FlashCardColumns.HEADERS;
+        return (String[]) FlashCardColumns.HEADERS.clone();
     }
 
     /* (non-Javadoc)
@@ -109,7 +109,7 @@
      */
     public String[] getHeaderToolTips()
     {
-        return FlashCardColumns.HEADER_TOOLTIPS;
+        return (String[]) FlashCardColumns.HEADER_TOOLTIPS.clone();
     }
 
     /* (non-Javadoc)
@@ -117,7 +117,7 @@
      */
     public int[] getCharacterWidths()
     {
-        return FlashCardColumns.CHARACTER_WIDTHS;
+        return (int[]) FlashCardColumns.CHARACTER_WIDTHS.clone();
     }
 
     /* (non-Javadoc)
@@ -125,7 +125,7 @@
      */
     public boolean[] getFixedWidths()
     {
-        return FlashCardColumns.FIXED_WIDTHS;
+        return (boolean[]) FlashCardColumns.FIXED_WIDTHS.clone();
     }
 
     /* (non-Javadoc)
@@ -133,7 +133,7 @@
      */
     public Class[] getClasses()
     {
-        return FlashCardColumns.CLASSES;
+        return (Class[]) FlashCardColumns.CLASSES.clone();
     }
 
     /* (non-Javadoc)
@@ -141,7 +141,7 @@
      */
     public int[] getSortKeys()
     {
-        return FlashCardColumns.SORT_KEYS;
+        return (int[]) FlashCardColumns.SORT_KEYS.clone();
     }
 
      /* (non-Javadoc)

Modified: trunk/app/src/org/crosswire/flashcards/FlashCardEditor.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/FlashCardEditor.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/FlashCardEditor.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -20,6 +20,11 @@
  */
 package org.crosswire.flashcards;
 
+import java.awt.BorderLayout;
+import java.awt.ComponentOrientation;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 
@@ -28,10 +33,8 @@
 import javax.swing.JDialog;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
-import javax.swing.event.EventListenerList;
 
 import org.crosswire.modedit.UniTextEdit;
-import java.awt.*;
 
 /**
  * Editor for lessons used by Quiz (part of FlashCards).
@@ -68,19 +71,11 @@
     // ---------------
     public FlashCardEditor()
     {
-        try
-        {
-            jbInit();
-        }
-        catch (Exception exception)
-        {
-            exception.printStackTrace();
-            Debug.error(this.toString(), exception.getMessage());
-        }
+        jbInit();
     }
 
     //Component initialization
-    private void jbInit() throws Exception
+    private void jbInit()
     {
         setLayout(gridBagLayout1);
         setBorder(BorderFactory.createEtchedBorder());

Modified: trunk/app/src/org/crosswire/flashcards/FlashCardPane.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/FlashCardPane.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/FlashCardPane.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -27,7 +27,6 @@
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.ListSelectionModel;
-import javax.swing.event.EventListenerList;
 import javax.swing.event.ListSelectionListener;
 
 import org.crosswire.common.swing.RowTable;
@@ -47,35 +46,13 @@
     private RowTable wordList = new RowTable(new ArrayList(), new FlashCardColumns());
     private Lesson lesson;
 
-    /**
-     * The listeners for handling ViewEvent Listeners
-     */
-    private EventListenerList listenerList = new EventListenerList();
-
-
     public FlashCardPane()
     {
-        this(false);
+        jbInit();
     }
 
-    /**
-     * @param b
-     */
-    public FlashCardPane(boolean allowsEdits)
-    {
-        try
-        {
-            jbInit();
-        }
-        catch (Exception exception)
-        {
-            exception.printStackTrace();
-            Debug.error(this.toString(), exception.getMessage());
-        }
-    }
-
     //Component initialization
-    private void jbInit() throws Exception
+    private void jbInit()
     {
         wordList.setShowGrid(false);
         setLayout(new BorderLayout());
@@ -210,14 +187,14 @@
     public void fireLessonChanged(LessonChangeEvent e)
     {
         // Guaranteed to return a non-null array
-        Object[] listeners = listenerList.getListenerList();
+        Object[] list = listenerList.getListenerList();
         // Process the listeners last to first, notifying
         // those that are interested in this event
-        for (int i = listeners.length - 2; i >= 0; i -= 2)
+        for (int i = list.length - 2; i >= 0; i -= 2)
         {
-            if (listeners[i] == LessonChangeEventListener.class)
+            if (list[i] == LessonChangeEventListener.class)
             {
-                ((LessonChangeEventListener) listeners[i + 1]).lessonChanged(e);
+                ((LessonChangeEventListener) list[i + 1]).lessonChanged(e);
             }
         }
     }

Modified: trunk/app/src/org/crosswire/flashcards/FlashCardRep.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/FlashCardRep.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/FlashCardRep.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -20,6 +20,8 @@
  */
 package org.crosswire.flashcards;
 
+import java.io.Serializable;
+
 /**
  * A FlashCard has a front and a back. The front has the test
  * and the back has the answer.
@@ -27,7 +29,7 @@
  * @author Troy A. Griffitts [scribe at crosswire dot org]
  * @author DM Smith [ dmsmith555 at yahoo dot com]
  */
-public class FlashCardRep implements Cloneable, Comparable
+public class FlashCardRep implements Cloneable, Comparable, Serializable
 {
     /**
      * Create a partial FlashCard.
@@ -121,9 +123,13 @@
     public boolean equals(Object obj)
     {
         if (obj == this)
+        {
             return true;
+        }
         if (!(obj instanceof FlashCardRep))
+        {
             return false;
+        }
         FlashCardRep otherCard = (FlashCardRep) obj;
         return front.equals(otherCard.front)
         	&& back.equals(otherCard.back);
@@ -163,4 +169,9 @@
 
     private String front;
     private String back;
+
+    /**
+     * Serialization ID
+     */
+    private static final long serialVersionUID = 3503218506665464549L;
 }

Modified: trunk/app/src/org/crosswire/flashcards/Lesson.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/Lesson.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/Lesson.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -24,13 +24,15 @@
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.net.JarURLConnection;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.Iterator;
 import java.util.Properties;
 import java.util.Set;
 import java.util.TreeSet;
-import java.net.URLConnection;
-import java.net.JarURLConnection;
 
 
 /**
@@ -40,10 +42,9 @@
  * @author Troy A. Griffitts [scribe at crosswire dot org]
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public class Lesson
-          implements Comparable {
+public class Lesson implements Comparable, Serializable {
 
-     /**
+    /**
       * The <code>filename</code> gives the relative location of the lesson.
       * Typically this is something like lesson/setname/lessonname.flash.
       */
@@ -65,7 +66,13 @@
      private Set flashCards = new TreeSet();
 
      private boolean modified = false;
+
      /**
+      * Serialization ID
+      */
+     private static final long serialVersionUID = -4031174832238749375L;
+
+     /**
       * Construct a new, empty lesson.
       */
      public Lesson() {
@@ -112,7 +119,7 @@
                }
                modified = false;
           }
-          catch (Exception e1) {
+          catch (IOException e1) {
                /* ignore it */
           }
      }
@@ -123,6 +130,7 @@
       */
      public void store() {
           Properties lesson = new Properties();
+          OutputStream outStream = null;
           try {
                lesson.setProperty("lessonTitle", description);
                Iterator iter = flashCards.iterator();
@@ -150,11 +158,23 @@
                if (!dir.isDirectory()) {
                     dir.mkdirs();
                }
-               lesson.store(new FileOutputStream(file), "Flash Lesson");
+               outStream = new FileOutputStream(file);
+               lesson.store(outStream, "Flash Lesson");
                modified = false;
           }
           catch (IOException ex) {
-               ex.printStackTrace();
+              Debug.error(this.getClass().getName(), ex.getMessage());
+          } finally {
+              if (outStream != null) {
+                  try
+                  {
+                      outStream.close();
+                  }
+                  catch (IOException e)
+                  {
+                      Debug.error(this.getClass().getName(), e.getMessage());
+                  }
+              }
           }
      }
 

Modified: trunk/app/src/org/crosswire/flashcards/LessonManager.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/LessonManager.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/LessonManager.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -21,12 +21,14 @@
 
 import java.io.File;
 import java.io.FilenameFilter;
+import java.io.IOException;
 import java.net.JarURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.Iterator;
+import java.util.Locale;
 import java.util.Set;
 import java.util.TreeSet;
 import java.util.jar.JarEntry;
@@ -58,20 +60,10 @@
 
 
      private LessonManager() {
-          try {
-               homeProjectPath = System.getProperty("user.home") + File.separator + DIR_PROJECT;
-               homeLessonDir = new File(homeProjectPath + File.separator + LESSON_ROOT);
-          }
-          catch (Exception e1) {
-               e1.printStackTrace();
-          }
-          load();
-          try {
-               jbInit();
-          }
-          catch (Exception ex) {
-               ex.printStackTrace();
-          }
+         homeProjectPath = System.getProperty("user.home") + File.separator + DIR_PROJECT;
+         homeLessonDir = new File(homeProjectPath + File.separator + LESSON_ROOT);
+         load();
+         jbInit();
      }
 
 
@@ -115,9 +107,9 @@
 
           // find the directory containing this
           // search all jars in that directory for lesson sets
-          String thisName = this.getClass().getName();
+          String thisName = LessonManager.class.getName();
           String thisRes = "/" + thisName.replace('.', '/') + ".class";
-          URL thisURL = this.getClass().getResource(thisRes);
+          URL thisURL = LessonManager.class.getResource(thisRes);
           if (thisURL == null) {
               return;
           }
@@ -135,7 +127,7 @@
 
           // see if there are any lessons on our path
           // dig into the jar for lessonSets
-          URL lessonsURL = this.getClass().getResource('/' + LESSON_ROOT);
+          URL lessonsURL = LessonManager.class.getResource('/' + LESSON_ROOT);
           if (lessonsURL == null) {
               return;
           }
@@ -160,26 +152,19 @@
 
                     loadJarLessonSets(new File(new java.net.URI(uri)));
                }
-               catch (Exception e) { e.printStackTrace(); }
+               catch (Exception e) { 
+                   Debug.error(this.getClass().getName(), e.getMessage());
+               }
           }
-
-
-
-
      }
 
-
      /**
       * Load lesson sets from the jar file
       */
      private void loadLessonSetsFromJarDir(String path) {
           File lessonDir = new File(path);
           if (lessonDir.isDirectory()) {
-               File[] files = lessonDir.listFiles(new FilenameFilter() {
-                    public boolean accept(File dir, String name) {
-                         return name.toUpperCase().endsWith(".JAR");
-                    }
-               });
+               File[] files = lessonDir.listFiles(new JarFileFilter());
                if (files != null) {
                     for (int i = 0; i < files.length; i++) {
                          loadJarLessonSets(files[i]);
@@ -213,8 +198,8 @@
                     }
                }
           }
-          catch (Exception e2) {
-               e2.printStackTrace();
+          catch (IOException e2) {
+              Debug.error(this.getClass().getName(), e2.getMessage());
           }
      }
 
@@ -236,7 +221,7 @@
                     }
                }
           }
-          catch (Exception e) {
+          catch (IOException e) {
                // that's fine.  We just failed to load local files.
           }
      }
@@ -281,6 +266,12 @@
      }
 
 
-     private void jbInit() throws Exception {
+     private void jbInit() {
      }
+
+     static class JarFileFilter implements FilenameFilter {
+         public boolean accept(File dir, String name) {
+              return name.toUpperCase(Locale.ENGLISH).endsWith(".JAR");
+         }
+    }
 }

Modified: trunk/app/src/org/crosswire/flashcards/LessonPane.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/LessonPane.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/LessonPane.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -24,6 +24,7 @@
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 import javax.swing.BorderFactory;
 import javax.swing.DefaultListModel;
@@ -34,7 +35,6 @@
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
-import javax.swing.event.EventListenerList;
 import javax.swing.event.ListSelectionListener;
 
 /**
@@ -54,11 +54,6 @@
     private JMenuItem newItem;
     private boolean editable;
 
-    /**
-     * The listeners for handling ViewEvent Listeners
-     */
-    private EventListenerList listenerList = new EventListenerList();
-
     //Construct the frame
     public LessonPane()
     {
@@ -71,14 +66,7 @@
     public LessonPane(boolean allowEdits)
     {
         editable = allowEdits;
-        try
-        {
-            jbInit();
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
+        jbInit();
     }
 
     public void setSelectionMode(int mode)
@@ -99,7 +87,7 @@
         lessonList.addListSelectionListener(listener);
     }
 
-    private void jbInit() throws Exception
+    private void jbInit()
     {
         setLayout(new BorderLayout());
 
@@ -203,14 +191,14 @@
     public void fireLessonChanged(LessonChangeEvent e)
     {
         // Guaranteed to return a non-null array
-        Object[] listeners = listenerList.getListenerList();
+        Object[] list = listenerList.getListenerList();
         // Process the listeners last to first, notifying
         // those that are interested in this event
-        for (int i = listeners.length - 2; i >= 0; i -= 2)
+        for (int i = list.length - 2; i >= 0; i -= 2)
         {
-            if (listeners[i] == LessonChangeEventListener.class)
+            if (list[i] == LessonChangeEventListener.class)
             {
-                ((LessonChangeEventListener) listeners[i + 1]).lessonChanged(e);
+                ((LessonChangeEventListener) list[i + 1]).lessonChanged(e);
             }
         }
     }
@@ -246,9 +234,13 @@
         /* (non-Javadoc)
          * @see java.util.Iterator#next()
          */
-        public Object next()
+        public Object next() throws NoSuchElementException
         {
-            return model.get(selectedIndexes[currentIndex++]);
+            if (hasNext())
+            {
+                return model.get(selectedIndexes[currentIndex++]);
+            }
+            throw new NoSuchElementException();
         }
 
         private int[] selectedIndexes;

Modified: trunk/app/src/org/crosswire/flashcards/LessonSet.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/LessonSet.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/LessonSet.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -21,6 +21,8 @@
 
 import java.io.File;
 import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.Serializable;
 import java.net.JarURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
@@ -28,6 +30,7 @@
 import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.Iterator;
+import java.util.Locale;
 import java.util.Set;
 import java.util.TreeSet;
 import java.util.jar.JarEntry;
@@ -44,10 +47,9 @@
  * @author Troy A. Griffitts [scribe at crosswire dot org]
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public class LessonSet
-          implements Comparable {
+public class LessonSet implements Comparable, Serializable {
 
-     /**
+    /**
       * The <code>url</code> of the lesson
       */
      private String url = null;
@@ -67,6 +69,11 @@
       */
      private boolean modified;
 
+     /**
+      * Serialization ID
+      */
+     private static final long serialVersionUID = -798022075988174038L;
+
      public LessonSet(String url) {
           this.url = url; // .toLowerCase();
           description = url.substring(url.lastIndexOf('/', url.length() - 2) + 1);
@@ -100,16 +107,14 @@
                connection = lessonsURL.openConnection();
           }
           catch (Exception e1) {
-               e1.printStackTrace();
+              Debug.error(this.getClass().getName(), e1.getMessage());
           }
           if (connection instanceof JarURLConnection) {
                JarURLConnection jarConnection = (JarURLConnection) connection;
                loadJarLessonSet(jarConnection);
           }
-          else {
-              if (lessonsURL != null) {
-                  loadDirectoryLessonSet(new File(lessonsURL.getFile()));
-              }
+          else if (lessonsURL != null) {
+              loadDirectoryLessonSet(new File(lessonsURL.getFile()));
           }
      }
 
@@ -121,7 +126,7 @@
                jarFile = jarConnection.getJarFile();
           }
           catch (Exception e2) {
-               e2.printStackTrace();
+              Debug.error(this.getClass().getName(), e2.getMessage());
           }
           if (jarFile == null) {
                return;
@@ -131,7 +136,7 @@
                JarEntry jarEntry = (JarEntry) entries.nextElement();
                String lessonPath = jarEntry.getName();
                if (lessonPath.startsWith(dirName) && !jarEntry.isDirectory() &&
-                   lessonPath.toUpperCase().endsWith(".FLASH")) {
+                   lessonPath.toUpperCase(Locale.ENGLISH).endsWith(".FLASH")) {
                     lessons.add(new Lesson("jar:" + jarConnection.getJarFileURL() + "!/" + lessonPath));
                }
           }
@@ -145,11 +150,7 @@
       */
      private void loadDirectoryLessonSet(File directory) {
           try {
-               File[] files = directory.listFiles(new FilenameFilter() {
-                    public boolean accept(File dir, String name) {
-                         return name.toUpperCase().endsWith(".FLASH");
-                    }
-               });
+               File[] files = directory.listFiles(new FlashFileFilter());
                if (files == null) {
                     return;
                }
@@ -158,7 +159,7 @@
                     lessons.add(new Lesson(files[i].getCanonicalFile().toURL().toString()));
                }
           }
-          catch (Exception e) {
+          catch (IOException e) {
                // that's fine.  We just failed to load local files.
           }
      }
@@ -292,4 +293,10 @@
           }
           return null;
      }
+
+     static class FlashFileFilter implements FilenameFilter {
+         public boolean accept(File dir, String name) {
+              return name.toUpperCase(Locale.ENGLISH).endsWith(".FLASH");
+         }
+    }
 }

Modified: trunk/app/src/org/crosswire/flashcards/LessonSetPane.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/LessonSetPane.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/LessonSetPane.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -35,7 +35,6 @@
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.ListSelectionModel;
-import javax.swing.event.EventListenerList;
 import javax.swing.event.ListSelectionListener;
 
 
@@ -53,11 +52,6 @@
     private JList lessonSetList = new JList(new DefaultListModel());
     private boolean editable;
 
-    /**
-     * The listeners for handling ViewEvent Listeners
-     */
-    private EventListenerList listenerList = new EventListenerList();
-
     //Construct the frame
     public LessonSetPane()
     {
@@ -70,14 +64,7 @@
     public LessonSetPane(boolean allowEdits)
     {
         editable = allowEdits;
-        try
-        {
-            jbInit();
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
+        jbInit();
     }
 
     /**
@@ -88,7 +75,7 @@
         lessonSetList.addListSelectionListener(listener);
     }
 
-    private void jbInit() throws Exception
+    private void jbInit()
     {
         lessonSetList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
 

Modified: trunk/app/src/org/crosswire/flashcards/MainFrame.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/MainFrame.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/MainFrame.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -22,12 +22,12 @@
 
 import java.awt.AWTEvent;
 import java.awt.BorderLayout;
+import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.event.WindowEvent;
 
 import javax.swing.JFrame;
 import javax.swing.JOptionPane;
-import javax.swing.JPanel;
 import javax.swing.JTabbedPane;
 
 
@@ -58,20 +58,13 @@
         testPane = new QuizPane(setupPane);
         editPane = new EditPane();
         JOptionPane.setRootFrame(this);
-        try
-        {
-            jbInit();
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
+        jbInit();
     }
 
     //Component initialization
-    private void jbInit() throws Exception
+    private void jbInit()
     {
-        JPanel contentPane = (JPanel) this.getContentPane();
+        Container contentPane = this.getContentPane();
         contentPane.setLayout(new BorderLayout());
         this.setSize(new Dimension(600, 480));
         this.setTitle("FlashCards  - (c) 2004 CrossWire Bible Society http://crosswire.org");

Modified: trunk/app/src/org/crosswire/flashcards/MainFrame_AboutBox.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/MainFrame_AboutBox.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/MainFrame_AboutBox.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -67,15 +67,10 @@
   public MainFrame_AboutBox(Frame parent) {
     super(parent);
     enableEvents(AWTEvent.WINDOW_EVENT_MASK);
-    try {
-      jbInit();
-    }
-    catch(Exception e) {
-      e.printStackTrace();
-    }
+    jbInit();
   }
   //Component initialization
-  private void jbInit() throws Exception  {
+  private void jbInit()  {
     image1 = new ImageIcon(MainFrame.class.getResource("about.png"));
     imageLabel.setIcon(image1);
     this.setTitle("About");

Modified: trunk/app/src/org/crosswire/flashcards/MainMenu.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/MainMenu.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/MainMenu.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -166,7 +166,7 @@
     }
 
     // ---------------
-    class ExitAction extends AbstractAction {
+    static class ExitAction extends AbstractAction {
 
         /**
          * Serialization ID
@@ -195,10 +195,10 @@
 
         public void actionPerformed( ActionEvent event ) {
 
-            String aboutString = new String( "FlashCards\n" +
-                                             "A Vocabulary Training Tool by CrossWire\n" +
-                                             "(c) 2004 CrossWire Bible Society\n" +
-                                             "http://crosswire.org" );
+            String aboutString = "FlashCards\n" +
+                                 "A Vocabulary Training Tool by CrossWire\n" +
+                                 "(c) 2004 CrossWire Bible Society\n" +
+                                 "http://crosswire.org";
 
             Debug.trace( this.toString( ), "Beginning\n" );
             JOptionPane.showMessageDialog( frame,

Modified: trunk/app/src/org/crosswire/flashcards/OpenFile.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/OpenFile.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/OpenFile.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -39,19 +39,14 @@
 
   public OpenFile(Frame frame, String title, boolean modal) {
     super(frame, title, modal);
-    try {
-      jbInit();
-      pack();
-    }
-    catch(Exception ex) {
-      ex.printStackTrace();
-    }
+    jbInit();
+    pack();
   }
 
   public OpenFile() {
     this(null, "", false);
   }
-  private void jbInit() throws Exception {
+  private void jbInit() {
     panel1.setLayout(borderLayout1);
     getContentPane().add(panel1);
     panel1.add(jFileChooser1, BorderLayout.CENTER);

Modified: trunk/app/src/org/crosswire/flashcards/Quiz.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/Quiz.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/Quiz.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -99,7 +99,7 @@
 
         } catch(Exception e ) {
 
-            e.printStackTrace();
+            e.printStackTrace(System.err);
 
         }
 

Modified: trunk/app/src/org/crosswire/flashcards/QuizPane.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/QuizPane.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/QuizPane.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -20,24 +20,32 @@
  */
 package org.crosswire.flashcards;
 
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.ComponentOrientation;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.GridLayout;
+import java.awt.Insets;
+import java.awt.SystemColor;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Vector;
 
 import javax.swing.BorderFactory;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
 import javax.swing.JComponent;
 import javax.swing.JLabel;
+import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.SwingConstants;
-import javax.swing.JOptionPane;
-import java.awt.*;
 
 
 /**
@@ -57,8 +65,8 @@
      private static final long serialVersionUID = 8613458092624929167L;
 
      SetupPane setupPane;
-     Vector words = new Vector();
-     Vector notLearned = new Vector();
+     List words = new ArrayList();
+     List notLearned = new ArrayList();
      WordEntry currentWord = null;
      int wrong = 0;
      int totalAsked = 0;
@@ -76,11 +84,15 @@
      BorderLayout statusPanelBorderLayout = new BorderLayout();
      GridBagLayout gridBagLayout1 = new GridBagLayout();
 
-     static class WordEntry {
+     static class WordEntry implements Serializable {
 
-          public String back;
+          protected String back;
           protected FlashCard flashCard;
-          public int attempts;
+          protected int attempts;
+          /**
+           * Serialization ID
+           */
+          private static final long serialVersionUID = -8148656461971656626L;
 
 
           public WordEntry(FlashCard flashCard) {
@@ -113,17 +125,12 @@
      //Construct the frame
      public QuizPane(SetupPane setupPane) {
           this.setupPane = setupPane;
-          try {
-               jbInit();
-          }
-          catch (Exception e) {
-               e.printStackTrace();
-          }
+          jbInit();
      }
 
 
      //Component initialization
-     private void jbInit() throws Exception {
+     private void jbInit() {
           startLessonButton.setText("Start");
           startLessonButton.addActionListener(new QuizPane_startLessonButton_actionAdapter(this));
 
@@ -183,7 +190,7 @@
 
      public void loadTest() {
 //        boolean loadedFont = false;
-          words = new Vector();
+          words = new ArrayList();
           Iterator lessonIter = setupPane.iterator();
           while (lessonIter.hasNext()) {
                Lesson lesson = (Lesson) lessonIter.next();
@@ -242,7 +249,7 @@
 
      void startLessonButton_actionPerformed(ActionEvent e) {
           loadTest();
-          notLearned = (Vector) words.clone();
+          notLearned = (List) ((ArrayList) words).clone();
           totalAsked = 0;
           totalWrong = 0;
           showRandomWord(currentWord);
@@ -272,43 +279,43 @@
                choicesPanel.repaint();
           }
           else {
-               Vector choices = (Vector) words.clone();
-               choices.remove(w);
+              List choices = (List) ((ArrayList) words).clone();
+              choices.remove(w);
 
-               // randomly pick answers
-               boolean flipped = setupPane.isFlipped();
-               List picks = new ArrayList();
-               picks.add(createAnswerEntry(w.getSide(flipped)));
-               int size = words.size();
-               while (picks.size() < Math.min(NUM_ANSWERS, size)) {
-                    int c = (int) (Math.random() * choices.size());
-                    WordEntry wc = (WordEntry) choices.get(c);
-                    String answer = wc.getSide(flipped);
+              // randomly pick answers
+              boolean flipped = setupPane.isFlipped();
+              List picks = new ArrayList();
+              picks.add(createAnswerEntry(w.getSide(flipped)));
+              int size = words.size();
+              while (picks.size() < Math.min(NUM_ANSWERS, size)) {
+                  int c = (int) (Math.random() * choices.size());
+                  WordEntry wc = (WordEntry) choices.get(c);
+                  String answer = wc.getSide(flipped);
 
-                    // some times two different word have the same answer
-                    if (!picks.contains(answer)) {
-                         picks.add(createAnswerEntry(answer));
-                         choices.remove(wc);
-                    }
-               }
-               // Now randomize these answers. To do this we swap the first one
-               // with another.
-               int c = (int) (Math.random() * picks.size());
-               // If we have selected something other than ourselves.
-               if (c > 0) {
-                    picks.add(0, picks.remove(c));
-                    picks.add(c, picks.remove(1));
-               }
-               Iterator iter = picks.iterator();
-               while (iter.hasNext()) {
-                    choicesPanel.add( (Component) iter.next());
-               }
-               wrong = 0;
-               shownAnswer = false;
-               updateStats();
-               choicesPanel.invalidate();
-               choicesPanel.validate();
-               choicesPanel.repaint();
+                  // some times two different word have the same answer
+                  if (!picks.contains(answer)) {
+                      picks.add(createAnswerEntry(answer));
+                      choices.remove(wc);
+                  }
+              }
+              // Now randomize these answers. To do this we swap the first one
+              // with another.
+              int c = (int) (Math.random() * picks.size());
+              // If we have selected something other than ourselves.
+              if (c > 0) {
+                  picks.add(0, picks.remove(c));
+                  picks.add(c, picks.remove(1));
+              }
+              Iterator iter = picks.iterator();
+              while (iter.hasNext()) {
+                  choicesPanel.add( (Component) iter.next());
+              }
+              wrong = 0;
+              shownAnswer = false;
+              updateStats();
+              choicesPanel.invalidate();
+              choicesPanel.validate();
+              choicesPanel.repaint();
           }
      }
 
@@ -370,7 +377,7 @@
      public void showAnswer() {
           for (int i = 0; i < choicesPanel.getComponentCount(); i++) {
                JCheckBox ck = (JCheckBox) choicesPanel.getComponent(i);
-               if (ck.getText() == currentWord.getSide(setupPane.isFlipped())) {
+               if (ck.getText().equals(currentWord.getSide(setupPane.isFlipped()))) {
                     ck.setFont(new Font(ck.getFont().getName(), Font.BOLD | Font.ITALIC, ck.getFont().getSize()));
                     break;
                }
@@ -381,8 +388,8 @@
 
      void showAnswerButton_actionPerformed(ActionEvent e) {
           if (setupPane.isNoMultipleChoice()) {
-               ++totalAsked; String dialogString = new String(currentWord.getSide(!setupPane.isFlipped()) + "\n" +
-                         currentWord.getSide(setupPane.isFlipped()) + "\n" + "Did You Get It Right?\n");
+               ++totalAsked; String dialogString = currentWord.getSide(!setupPane.isFlipped()) + "\n" +
+                         currentWord.getSide(setupPane.isFlipped()) + "\n" + "Did You Get It Right?\n";
                int choice = JOptionPane.showConfirmDialog(this, dialogString, "Result", JOptionPane.YES_NO_OPTION);
                if (JOptionPane.YES_OPTION == choice) {
                     notLearned.remove(currentWord);

Modified: trunk/app/src/org/crosswire/flashcards/SetupPane.java
===================================================================
--- trunk/app/src/org/crosswire/flashcards/SetupPane.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/flashcards/SetupPane.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -44,7 +44,7 @@
     /**
      * Serialization ID
      */
-    private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1904221667403637140L;
     protected LessonPane lessonPanel = new LessonPane();
     private LessonSetPane lessonSetPanel = new LessonSetPane();
     private JCheckBox flipped = new JCheckBox("Flip the Flash Cards");
@@ -53,14 +53,7 @@
     //Construct the frame
     public SetupPane()
     {
-        try
-        {
-            jbInit();
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
+        jbInit();
     }
 
     public boolean isFlipped()
@@ -78,49 +71,17 @@
         return lessonPanel.iterator();
     }
 
-    private void jbInit() throws Exception
+    private void jbInit()
     {
         setLayout(new BorderLayout());
         setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
                         "Select a Lesson Set, then one or more Lessons: "));
 
-        final FlashCardPane flashCardPanel = new FlashCardPane();
+        FlashCardPane flashCardPanel = new FlashCardPane();
 
-        lessonSetPanel.addListSelectionListener(new ListSelectionListener()
-                        {
-            /* (non-Javadoc)
-             * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
-             */
-            public void valueChanged(ListSelectionEvent e)
-            {
-                if (e.getValueIsAdjusting())
-                {
-                    return;
-                }
-                JList list = (JList) e.getSource();
-                lessonPanel.loadLessons((LessonSet) list.getSelectedValue());
-            }
-        });
+        lessonSetPanel.addListSelectionListener(new LessonSetSelectionListener(lessonPanel));
 
-        lessonPanel.addListSelectionListener(new ListSelectionListener()
-                        {
-            /* (non-Javadoc)
-             * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
-             */
-            public void valueChanged(ListSelectionEvent e)
-            {
-                if (e.getValueIsAdjusting())
-                {
-                    return;
-                }
-                JList list = (JList) e.getSource();
-                Object[] selections = list.getSelectedValues();
-                if (selections != null && selections.length == 1)
-                {
-                    flashCardPanel.loadFlashCards((Lesson) selections[0]);
-                }
-            }
-        });
+        lessonPanel.addListSelectionListener(new LessonSelectionListener(flashCardPanel));
 
         JSplitPane horizontalSplitPane = new JSplitPane();
         horizontalSplitPane.setResizeWeight(0.3D);
@@ -144,5 +105,54 @@
         panel.add(noMultipleChoice);
         add(panel, BorderLayout.SOUTH);
     }
+ 
+    static class LessonSetSelectionListener implements ListSelectionListener
+    {
+        private LessonPane lessonPanel;
 
+        public LessonSetSelectionListener(LessonPane lessonPanel)
+        {
+            this.lessonPanel = lessonPanel;
+        }
+
+        /* (non-Javadoc)
+         * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+         */
+        public void valueChanged(ListSelectionEvent e)
+        {
+            if (e.getValueIsAdjusting())
+            {
+                return;
+            }
+            JList list = (JList) e.getSource();
+            lessonPanel.loadLessons((LessonSet) list.getSelectedValue());
+        }
+    }
+
+    static class LessonSelectionListener implements ListSelectionListener
+    {
+        private FlashCardPane flashCardPanel;
+
+        public LessonSelectionListener(FlashCardPane flashCardPanel)
+        {
+            this.flashCardPanel = flashCardPanel;
+        }
+
+        /* (non-Javadoc)
+         * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
+         */
+        public void valueChanged(ListSelectionEvent e)
+        {
+            if (e.getValueIsAdjusting())
+            {
+                return;
+            }
+            JList list = (JList) e.getSource();
+            Object[] selections = list.getSelectedValues();
+            if (selections != null && selections.length == 1)
+            {
+                flashCardPanel.loadFlashCards((Lesson) selections[0]);
+            }
+        }
 }
+}

Modified: trunk/app/src/org/crosswire/modedit/CGreekIM.java
===================================================================
--- trunk/app/src/org/crosswire/modedit/CGreekIM.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/modedit/CGreekIM.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -94,7 +94,7 @@
 
         if( returnValue == null ) {
 
-            returnValue = new String( ) + input;
+            returnValue = "" + input;
 
         }
 

Modified: trunk/app/src/org/crosswire/modedit/GreekKeymanIM.java
===================================================================
--- trunk/app/src/org/crosswire/modedit/GreekKeymanIM.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/modedit/GreekKeymanIM.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -24,7 +24,7 @@
   public String translate(char in) {
     String retVal = (String) charMap.get(new Integer(in));
     if (retVal == null) {
-      retVal = new String() + in;
+      retVal = "" + in;
 
     }
     return retVal;

Modified: trunk/app/src/org/crosswire/modedit/HebrewDurusauIM.java
===================================================================
--- trunk/app/src/org/crosswire/modedit/HebrewDurusauIM.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/modedit/HebrewDurusauIM.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -24,7 +24,7 @@
   public String translate(char in) {
     String retVal = (String) charMap.get(new Integer(in));
     if (retVal == null) {
-      retVal = new String() + in;
+      retVal = "" + in;
 
     }
     return retVal;

Modified: trunk/app/src/org/crosswire/modedit/UniTextEdit.java
===================================================================
--- trunk/app/src/org/crosswire/modedit/UniTextEdit.java	2006-11-26 12:47:47 UTC (rev 94)
+++ trunk/app/src/org/crosswire/modedit/UniTextEdit.java	2006-12-02 22:43:50 UTC (rev 95)
@@ -5,6 +5,7 @@
 import java.awt.ComponentOrientation;
 import java.awt.Dimension;
 import java.awt.Font;
+import java.awt.FontFormatException;
 import java.awt.event.ActionEvent;
 import java.awt.event.ItemEvent;
 import java.awt.event.KeyEvent;
@@ -18,6 +19,7 @@
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.io.StringWriter;
+import java.io.Writer;
 import java.net.URL;
 import java.net.URLConnection;
 
@@ -89,16 +91,11 @@
   /**Construct the frame*/
   public UniTextEdit() {
       enableEvents(AWTEvent.WINDOW_EVENT_MASK);
-      try {
-          jbInit();
-      }
-      catch(Exception e) {
-          e.printStackTrace();
-      }
+      jbInit();
   }
 
 
-  private void jbInit() throws Exception  {
+  private void jbInit() {
     //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
     this.setSize(new Dimension(549, 300));
     fontContentLoader.setLayout(borderLayout5);
@@ -231,7 +228,8 @@
   }
 
 
-  void jTextArea1_keyTyped(KeyEvent e) {
+  void jTextArea1_keyTyped(KeyEvent e)
+  {
       char typedChar = e.getKeyChar();
       String pushChar = null;
       statusBar.setText("");
@@ -239,17 +237,20 @@
       SWInputMethod inputMethod = (SWInputMethod) imComboBox.getSelectedItem();
 
       pushChar = inputMethod.translate(typedChar);
-      if (inputMethod.getState() > 1) {
+      if (inputMethod.getState() > 1)
+      {
           statusBar.setText("Compound '"+typedChar+"'");
           e.consume();
       }
-      else {
-          if (pushChar.length() > 1) {
-              e.consume();
-              jTextArea1.insert(pushChar, jTextArea1.getCaretPosition());
-          }
-          else e.setKeyChar(pushChar.charAt(0));
+      else if (pushChar.length() > 1)
+      {
+          e.consume();
+          jTextArea1.insert(pushChar, jTextArea1.getCaretPosition());
       }
+      else
+      {
+          e.setKeyChar(pushChar.charAt(0));
+      }
   }
 
   public void setFontSize(float size) {
@@ -306,15 +307,33 @@
     StringWriter out = new StringWriter();
     try {
       jTextArea1.write(out);
-    } catch (IOException ex) { ex.printStackTrace(); }
+    } catch (IOException ex) {
+        ex.printStackTrace(System.err);
+    }
     return out.toString();
   }
 
   public void store(File outFile) {
+    Writer writer = null;
     try {
-        jTextArea1.write(new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8"));
+        writer = new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8");
+        jTextArea1.write(writer);
     }
-    catch (Exception e1) { e1.printStackTrace(); }
+    catch (Exception e1) {
+        e1.printStackTrace(System.err);
+    } finally {
+        if (writer != null) {
+            try
+            {
+                writer.close();
+            }
+            catch (IOException e)
+            {
+                e.printStackTrace(System.err);
+            }
+        }
+    }
+    
 
   }
 
@@ -323,30 +342,39 @@
   }
 
   public void load(String url) {
+    InputStream bis = null;
     try {
       statusBar.setText("Loading content...");
       statusBar.paintImmediately(statusBar.getVisibleRect());
       URLConnection connection = new URL(url).openConnection();
-      InputStream is = connection.getInputStream();
       ByteArrayOutputStream bos = new ByteArrayOutputStream();
-      BufferedInputStream bis = new BufferedInputStream(is);
-      String newText = connection.toString();
+      bis = new BufferedInputStream(connection.getInputStream());
 
       int len;
       byte inBuf[] = new byte[8192];
       do {
         len = bis.read(inBuf, 0, 8192);
         if (len != -1)
+        {
           bos.write(inBuf, 0, len);
+        }
       }
       while (len != -1);
-      newText = new String(bos.toByteArray(), "UTF-8");
+      String newText = new String(bos.toByteArray(), "UTF-8");
       jTextArea1.setText(newText);
       statusBar.setText(Integer.toString(newText.length()) +
                         " characters of content loaded.");
     }
-    catch (Exception ex) {
-      ex.printStackTrace();
+    catch (IOException ex) {
+      ex.printStackTrace(System.err);
+    } finally {
+        if (bis != null) {
+            try {
+                bis.close();
+            } catch (IOException e) {
+                e.printStackTrace(System.err);
+            }
+        }
     }
   }
 
@@ -372,33 +400,43 @@
 
 
   public void loadFont(String url) {
+    if (url.length() < 3) {
+        return;
+    }
+
+    InputStream is = null;
     try {
-      if (url.length() < 3)
-        return;
       statusBar.setText("Loading font...");
       statusBar.paintImmediately(statusBar.getVisibleRect());
       URLConnection connection = new URL(url).openConnection();
-      InputStream is = connection.getInputStream();
+      is = connection.getInputStream();
       loadFont(is);
     }
-    catch (Exception ex) {
-      ex.printStackTrace();
+    catch (IOException ex) {
+      ex.printStackTrace(System.err);
     }
+    catch (FontFormatException e) {
+        e.printStackTrace(System.err);
+    } finally {
+        if (is != null) {
+            try {
+                is.close();
+            } catch (IOException e) {
+                e.printStackTrace(System.err);
+            }
+        }
+    }
   }
 
 
-  public void loadFont(InputStream is) {
-    try {
+  public void loadFont(InputStream is) throws FontFormatException, IOException {
         statusBar.setText("Loading font...");
         statusBar.paintImmediately(statusBar.getVisibleRect());
         Font font = Font.createFont(Font.TRUETYPE_FONT, is);
         Font newFont = font.deriveFont((float)18.0);
         fontSizer.setValue(18);
         this.jTextArea1.setFont(newFont);
-        is.close();
         statusBar.setText("New Font Loaded.");
-    }
-    catch (Exception ex) { ex.printStackTrace(); }
   }
 
   public void setText(String text) {




More information about the sword-cvs mailing list