Changeset 182 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/gui/ScriptBuilderFrame.java
- Timestamp:
- 01/11/2020 05:45:23 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scriptbuilder/gui/ScriptBuilderFrame.java
r179 r182 84 84 */ 85 85 private Color selectedColor; 86 /** 87 * Strings to show in the incident color combo box 88 */ 89 private final String[] colorModel = {"BLUE", "RED", "CYAN", "GREEN", 90 "ORANGE", "MAGENTA", "YELLOW", "BLACK"}; 91 /** 92 * Allowed color choices. These colors must match the items in the combobox. 93 */ 94 private final Color[] colorChoices = {Color.BLUE, Color.RED, Color.CYAN, 95 Color.GREEN, Color.ORANGE, Color.MAGENTA, Color.YELLOW, Color.BLACK}; 86 96 87 /** 97 88 * Get the script currently in use. … … 712 703 jLabel2.setText("Incident Type:"); 713 704 714 colorComboBox.setModel(new DefaultComboBoxModel( colorModel));705 colorComboBox.setModel(new DefaultComboBoxModel(SimulationScript.colorNames)); 715 706 colorComboBox.addActionListener(new java.awt.event.ActionListener() { 716 707 public void actionPerformed(java.awt.event.ActionEvent evt) { … … 1348 1339 1349 1340 scriptBuilderMenuBar.addAncestorListener(new javax.swing.event.AncestorListener() { 1341 public void ancestorMoved(javax.swing.event.AncestorEvent evt) { 1342 } 1350 1343 public void ancestorAdded(javax.swing.event.AncestorEvent evt) { 1351 1344 scriptBuilderMenuBarAncestorAdded(evt); 1352 1345 } 1353 1346 public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { 1354 }1355 public void ancestorMoved(javax.swing.event.AncestorEvent evt) {1356 1347 } 1357 1348 }); … … 1631 1622 1632 1623 /** 1633 * Executed when the "OK" button is pressed on the Incident editor. If1624 * Executed when the "OK" button is pressed on the Incident properties window. If 1634 1625 * incident is new, and is valid, adds it to the model and updates. If 1635 1626 * editing existing incident, verifies changes are valid and applies them. … … 1813 1804 addIncidentStart.setValue(0); 1814 1805 txtIncidentLength.setText("0"); 1815 selectedColor = colorChoices[0];1816 incidentColorField.setBackground( colorChoices[0]);1806 selectedColor = SimulationScript.incidentColors[0]; 1807 incidentColorField.setBackground(selectedColor); 1817 1808 colorComboBox.setSelectedIndex(0); 1818 1809 addIncidentDescription.setText(""); … … 1960 1951 //addIncidentLength.setValue(i.length / 60); 1961 1952 incidentColorField.setBackground(i.color); 1962 colorComboBox.setSelectedIndex( lookupColor(i.color));1953 colorComboBox.setSelectedIndex(SimulationScript.lookupColor(i.color)); 1963 1954 selectedColor = i.color; 1964 1955 addIncidentDescription.setText(i.description); … … 2362 2353 2363 2354 private void incidentDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_incidentDetailsActionPerformed 2364 // TODO add your handling code here:2365 2355 Object[] incidentList = script.incidents.toArray(); 2366 2356 ScriptIncident i = (ScriptIncident) JOptionPane.showInputDialog( … … 2387 2377 //addIncidentLength.setValue(i.length / 60); 2388 2378 incidentColorField.setBackground(i.color); 2389 colorComboBox.setSelectedIndex( lookupColor(i.color));2379 colorComboBox.setSelectedIndex(SimulationScript.lookupColor(i.color)); 2390 2380 selectedColor = i.color; 2391 2381 addIncidentDescription.setText(i.description); … … 2444 2434 // Save the chosen color 2445 2435 int index = colorComboBox.getSelectedIndex(); 2446 selectedColor = colorChoices[index];2436 selectedColor = SimulationScript.incidentColors[index]; 2447 2437 incidentColorField.setBackground(selectedColor); 2448 2438 }//GEN-LAST:event_colorSelectedHandler 2449 /** Given a color, find its index in the color Choices. 2450 * @param color a java color 2451 * @pre color exists in color choices 2452 */ 2453 private int lookupColor(Color color) 2454 { 2455 int idx = 0; 2456 while(idx < colorChoices.length && colorChoices[idx] != color) 2457 { 2458 idx++; 2459 } 2460 return idx; 2461 } 2439 2462 2440 2463 2441 /** … … 2505 2483 { 2506 2484 UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); 2485 //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 2486 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); 2507 2487 } 2508 2488 catch (Exception ex)
Note: See TracChangeset
for help on using the changeset viewer.
