Index: trunk/src/scriptbuilder/gui/ScriptBuilderFrame.java
===================================================================
--- trunk/src/scriptbuilder/gui/ScriptBuilderFrame.java	(revision 163)
+++ trunk/src/scriptbuilder/gui/ScriptBuilderFrame.java	(revision 177)
@@ -32,4 +32,5 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import javax.swing.DefaultComboBoxModel;
 import javax.swing.DefaultListModel;
 import javax.swing.JFileChooser;
@@ -79,5 +80,18 @@
      */
     private int oldIncidentIndex;
-
+    /**
+     * incident color
+     */
+    private Color selectedColor;
+     /**
+     * Strings to show in the incident color combo box
+     */
+    private final String[] colorModel = {"BLUE", "RED", "CYAN", "GREEN", 
+        "ORANGE", "MAGENTA", "YELLOW", "BLACK"};
+    /** 
+     * Allowed color choices. These colors must match the items in the combobox.
+     */
+    private final Color[] colorChoices = {Color.BLUE, Color.RED, Color.CYAN, 
+        Color.GREEN, Color.ORANGE, Color.MAGENTA, Color.YELLOW, Color.BLACK};
     /**
      * Get the script currently in use.
@@ -407,5 +421,4 @@
         labelIncidentStart = new javax.swing.JLabel();
         addIncidentStart = new javax.swing.JSpinner();
-        btnChooseColor = new javax.swing.JButton();
         incidentColorField = new javax.swing.JTextField();
         txtIncidentLength = new javax.swing.JLabel();
@@ -414,4 +427,5 @@
         jLabel2 = new javax.swing.JLabel();
         addIncidentType = new javax.swing.JTextField();
+        colorComboBox = new javax.swing.JComboBox<>();
         addNoiseFrame = new javax.swing.JFrame();
         labelRadioChatter = new javax.swing.JLabel();
@@ -681,11 +695,4 @@
         addIncidentStart.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
 
-        btnChooseColor.setText("Choose...");
-        btnChooseColor.addActionListener(new java.awt.event.ActionListener() {
-            public void actionPerformed(java.awt.event.ActionEvent evt) {
-                btnChooseColorActionPerformed(evt);
-            }
-        });
-
         incidentColorField.setEditable(false);
         incidentColorField.setBackground(new java.awt.Color(0, 0, 0));
@@ -704,4 +711,11 @@
 
         jLabel2.setText("Incident Type:");
+
+        colorComboBox.setModel(new DefaultComboBoxModel(colorModel));
+        colorComboBox.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                colorSelectedHandler(evt);
+            }
+        });
 
         javax.swing.GroupLayout incidentFrameLayout = new javax.swing.GroupLayout(incidentFrame.getContentPane());
@@ -722,8 +736,8 @@
                             .addComponent(addIncidentName, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
                             .addComponent(addIncidentNumber, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
-                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, incidentFrameLayout.createSequentialGroup()
-                                .addComponent(incidentColorField, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)
+                            .addGroup(incidentFrameLayout.createSequentialGroup()
+                                .addComponent(incidentColorField, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                                .addComponent(btnChooseColor, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))))
+                                .addComponent(colorComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                     .addGroup(incidentFrameLayout.createSequentialGroup()
                         .addComponent(incidentCancelButton)
@@ -768,6 +782,6 @@
                 .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(labelIncidentColor)
-                    .addComponent(btnChooseColor)
-                    .addComponent(incidentColorField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+                    .addComponent(incidentColorField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                    .addComponent(colorComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
@@ -781,5 +795,5 @@
                 .addComponent(labelIncidentDescription)
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(incidentPropertiesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)
+                .addComponent(incidentPropertiesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE)
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addGroup(incidentFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
@@ -1334,10 +1348,10 @@
 
         scriptBuilderMenuBar.addAncestorListener(new javax.swing.event.AncestorListener() {
-            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
-            }
             public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
                 scriptBuilderMenuBarAncestorAdded(evt);
             }
             public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
+            }
+            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
             }
         });
@@ -1798,10 +1812,7 @@
         addIncidentStart.setValue(0);
         txtIncidentLength.setText("0");
-        incidentColorField.setBackground(Color.BLACK);
-        String colStr = "" + Integer.toHexString(Color.BLACK.getRed())
-                + Integer.toHexString(Color.BLACK.getGreen())
-                + Integer.toHexString(Color.BLACK.getBlue());
-        incidentColorField.setText(colStr);
-        selectedColor = Color.BLACK;
+        selectedColor = colorChoices[0];
+        incidentColorField.setBackground(colorChoices[0]);
+        colorComboBox.setSelectedIndex(0);
         addIncidentDescription.setText("");
         addIncidentLocation.setText("");
@@ -1948,8 +1959,5 @@
         //addIncidentLength.setValue(i.length / 60);
         incidentColorField.setBackground(i.color);
-        String colStr = "" + Integer.toHexString(i.color.getRed())
-                + Integer.toHexString(i.color.getGreen())
-                + Integer.toHexString(i.color.getBlue());
-        incidentColorField.setText(colStr);
+        colorComboBox.setSelectedIndex(lookupColor(i.color));
         selectedColor = i.color;
         addIncidentDescription.setText(i.description);
@@ -2204,38 +2212,5 @@
         }
     }//GEN-LAST:event_zoomOutIconMouseClicked
-    private Color selectedColor = Color.BLACK;
-
-    private void btnChooseColorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChooseColorActionPerformed
-        //For whatever reason, this causes the incident properties frame to be hidden
-        //this needs to be changed to edit only a certain number of colors, perhaps only the colors that are specified by java.awt.Color 
-        
-        Color newColor = incidentColorChooser.showDialog(this, "Incident Color", incidentColorField.getBackground());
-//        Color newColor = Color.BLUE;
-//        JColorChooser chooser = (new JColorChooser(incidentColorField.getBackground()));
-//        AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
-//        for(AbstractColorChooserPanel panel:panels)
-//        {
-//            System.out.println(panel.getDisplayName());
-//        }
-//        chooser.setPreviewPanel(new JPanel());
-//               JColorChooser.createDialog(
-//                   this.getParent(), 
-//                   "Choose an Incident Color", 
-//                   true, 
-//                   chooser,null,null  
-//                ).setVisible(true);
-        if (newColor != null)
-        {
-            //If the user selected a color, apply it to the properties frame
-            selectedColor = newColor;
-            incidentColorField.setBackground(newColor);
-            String colStr = "" + Integer.toHexString(newColor.getRed())
-                    + Integer.toHexString(newColor.getGreen())
-                    + Integer.toHexString(newColor.getBlue());
-            incidentColorField.setText(colStr);
-        }
-        //Return focus to the properties frame
-        incidentFrame.setVisible(true);
-    }//GEN-LAST:event_btnChooseColorActionPerformed
+
 
     /* Help > About simply displays the current SVN revision number so
@@ -2411,4 +2386,5 @@
             //addIncidentLength.setValue(i.length / 60);
             incidentColorField.setBackground(i.color);
+            colorComboBox.setSelectedIndex(lookupColor(i.color));
             selectedColor = i.color;
             addIncidentDescription.setText(i.description);
@@ -2461,4 +2437,26 @@
 //        script.loadUnitsFromFile(f);
     }//GEN-LAST:event_scriptBuilderMenuBarAncestorAdded
+/** Handle a user selection in the incident color combo box.
+ * @author jdalbey
+ */
+    private void colorSelectedHandler(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorSelectedHandler
+        // Save the chosen color
+        int index = colorComboBox.getSelectedIndex();
+        selectedColor = colorChoices[index];
+        incidentColorField.setBackground(selectedColor);
+    }//GEN-LAST:event_colorSelectedHandler
+    /** Given a color, find its index in the color Choices.
+     * @param color a java color 
+     * @pre color exists in color choices
+     */
+    private int lookupColor(Color color)
+    {
+        int idx = 0;
+        while(idx < colorChoices.length && colorChoices[idx] != color)
+        { 
+            idx++;
+        }
+        return idx;
+    }
 
     /**
@@ -2542,9 +2540,9 @@
     private javax.swing.JButton btnAddTime;
     private javax.swing.JButton btnCancelNoise;
-    private javax.swing.JButton btnChooseColor;
     private javax.swing.JButton btnGenerateNoise;
     private javax.swing.JMenuItem cadEvent;
     private javax.swing.JFrame cadEventFrame;
     private javax.swing.JButton cancelButton;
+    private javax.swing.JComboBox<String> colorComboBox;
     private javax.swing.JMenuItem deleteEventList;
     private javax.swing.JMenuItem deleteIncident;
