private void clearDeleteRecord() { if (deleteList != null) { java.util.List list = deleteList.getSelection(); if (list.size() > 0) { try { java.util.List dbIDs = new ArrayList(list.size()); for (Iterator it = list.iterator(); it.hasNext(); ) { GKInstance instance = (GKInstance) it.next(); dbIDs.add(instance.getDBID()); } fileAdaptor.clearDeleteRecord(dbIDs); } catch (IOException e) { System.err.println("SynchronizationDialog.clearDeleteRecord(): " + e); e.printStackTrace(); } deleteList.deleteInstances(list); // Check if deleteList needs to be removed if (deleteList.getDisplayedInstances().size() == 0) { centerPane.remove(deleteList); centerPane.validate(); centerPane.repaint(); } } } }
private void updateEditorView() { editorPane.setText(""); numParameters = 0; try { java.util.List elements = editableTemplate.getPrintfElements(); for (Iterator it = elements.iterator(); it.hasNext(); ) { PrintfUtil.PrintfElement el = (PrintfUtil.PrintfElement) it.next(); if (el.getFormat().equals(PrintfUtil.PrintfElement.FORMAT_NONE)) { appendText(el.getElement(), PLAIN_ATTR); } else { insertParameter( (ConfigParamDescr) paramKeys.get(el.getElement()), el.getFormat(), editorPane.getDocument().getLength()); } } } catch (Exception ex) { JOptionPane.showMessageDialog( this, "Invalid Format: " + ex.getMessage(), "Invalid Printf Format", JOptionPane.ERROR_MESSAGE); selectedPane = 1; printfTabPane.setSelectedIndex(selectedPane); updatePane(selectedPane); } }
public boolean importData(JComponent comp, Transferable t) { // Make sure we have the right starting points if (!(comp instanceof JTable)) { return false; } if (!t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { return false; } try { java.util.List data = (java.util.List) t.getTransferData(DataFlavor.javaFileListFlavor); Iterator i = data.iterator(); while (i.hasNext()) { File f = (File) i.next(); frame.importDataFile(f); } return true; } catch (UnsupportedFlavorException ufe) { System.err.println("Ack! we should not be here.\nBad Flavor."); } catch (IOException ioe) { System.out.println("Something failed during import:\n" + ioe); } catch (ImportException e) { e .printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } return false; }
public List<Pair<String, TextWithImports>> getExpressions() { final ArrayList<Pair<String, TextWithImports>> pairs = new ArrayList<Pair<String, TextWithImports>>(myData.size()); for (Iterator<Row> it = myData.iterator(); it.hasNext(); ) { final Row row = it.next(); pairs.add(new Pair<String, TextWithImports>(row.name, row.value)); } return pairs; }
public void tabRemoveHighlight(int tabIndex) { Iterator<Integer> highlightedIter = highlightedTabs.iterator(); while (highlightedIter.hasNext()) { if (highlightedIter.next().intValue() == tabIndex) { highlightedIter.remove(); break; } } }
/** * Fire a property change event to each listener. * * @param bean Bean being edited. * @param propName Name of the property. * @param oldValue Old value. * @param newValue New value. */ protected void firePropertyChange( Object bean, String propName, Object oldValue, Object newValue) { PropertyChangeEvent e = new PropertyChangeEvent(bean, propName, oldValue, newValue); Iterator it = _changeListeners.iterator(); while (it.hasNext()) { PropertyChangeListener l = (PropertyChangeListener) it.next(); l.propertyChange(e); } }
/** * Sets the accelerator sequence * * @param accSeq The new accelSeq value */ public void setAccelSeq(AcceleratorSeq accSeq) { java.util.List<AcceleratorNode> accNodes = accSeq.getNodesOfType(Electromagnet.s_strType); java.util.Iterator<AcceleratorNode> itr = accNodes.iterator(); while (itr.hasNext()) { Electromagnet emg = (Electromagnet) itr.next(); if (emg.getStatus()) { emg.setUseFieldReadback(false); } } ringFoilPosCorr.setAccelSeq(accSeq); }
public void paintComponent(Graphics g) { super.paintComponent(g); height = this.getHeight(); width = this.getWidth(); drawPlayers(g); g.setColor(Color.WHITE); g.drawString("Score", width - 60, 25); g.drawString(String.valueOf(score), width - 60, 40); if (countdownF) { g.drawString(String.valueOf(counterN), width / 2 - 10, height / 2); } else { if ((spawnCircleB) && (spawnIncrease)) { spawnCircles(); } if (spawnMonsterB) { spawnMonsters(); } if (spawnRandomersB) { spawnRandomers(); } if (spawnRainB) { spawnRain(); } if (spawnBombB()) { spawnBomb(); } try { Iterator i = enemies.iterator(); while (i.hasNext()) { Enemy e = (Enemy) i.next(); Iterator j = players.iterator(); while (j.hasNext()) { Player p = (Player) j.next(); e.move(players, programSpeedAdjust /*/players.size()*/); if ((e.collidesWith(p.getX(), p.getY())) && (!p.getImmunity())) { p.decLives(p.getX(), p.getY()); p.setImmunity(true); } } e.paint(g); } } catch (Exception e) { } } drawLayout(g); }
private void movePlayers() { onePlayerAlive = false; Iterator i = players.iterator(); while (i.hasNext()) { Player p = (Player) i.next(); if (p.getLives() == 0) { p.setActive(false); } if (p.isActive()) { onePlayerAlive = true; p.move(); } } }
private void lookupViewComboAction(ActionEvent e) { ObjEntityView fieldLookupView = objEntityViewField.getLookup().getLookupObjEntityView(); ObjEntityView selectedLookupView = (ObjEntityView) lookupViewCombo.getSelectedItem(); if (selectedLookupView != fieldLookupView) { objEntityViewField.getLookup().setLookupObjEntityView(selectedLookupView); dataViewTreeModel.fieldChanged(objEntityViewField); dataMapTreeModel.fieldChanged(objEntityViewField); fieldsTableModel.fireTableCellUpdated( objEntityViewField.getObjEntityView().getIndexOfObjEntityViewField(objEntityViewField), 4); } if (selectedLookupView != null) { ObjEntityViewField nullField = null; java.util.List lookupFields = new ArrayList(); lookupFields.add(nullField); lookupFields.addAll(selectedLookupView.getObjEntityViewFields()); DefaultComboBoxModel lookupFieldsDefaultModel = new DefaultComboBoxModel(lookupFields.toArray()); lookupFieldCombo.setModel(lookupFieldsDefaultModel); ObjEntityViewField fieldLookupField = objEntityViewField.getLookup().getLookupField(); if (fieldLookupField != null) { boolean flagSetSelectedItem = false; for (Iterator itr = lookupFields.iterator(); itr.hasNext(); ) { ObjEntityViewField field = (ObjEntityViewField) itr.next(); if ((field != null) && (fieldLookupField.getName().equals(field.getName()))) { lookupFieldCombo.setSelectedItem(fieldLookupField); flagSetSelectedItem = true; break; } } if (!flagSetSelectedItem) { lookupFieldCombo.setSelectedIndex(0); } } else { lookupFieldCombo.setSelectedIndex(0); } } else { ObjEntityViewField nullField = null; ObjEntityViewField[] fields = new ObjEntityViewField[] {nullField}; DefaultComboBoxModel fieldsModel = new DefaultComboBoxModel(fields); lookupFieldCombo.setModel(fieldsModel); lookupFieldCombo.setSelectedIndex(0); } }
/** * Returns the set of pages contained in this wizard. * * @param registration the registration object * @return Iterator */ public Iterator<WizardPage> getPages(JabberAccountRegistration registration) { java.util.List<WizardPage> pages = new ArrayList<WizardPage>(); // create new registration, our container needs the pages // this means this is a new wizard and we must reset all data // it will be invoked and when the wizard cleans and unregister // our pages, but this fix don't hurt in this situation. this.registration = registration; if (firstWizardPage == null) firstWizardPage = new FirstWizardPage(this); pages.add(firstWizardPage); return pages.iterator(); }
private void setup() { playerSetup(); deathLocation = new int[4]; Arrays.fill(deathLocation, -1); menu.setVisible(false); this.revalidate(); audioSetup(); Iterator i = players.iterator(); Player p; while (i.hasNext()) { p = (Player) i.next(); p.resetLives(3); p.setActive(true); } BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); Cursor blank = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "BLANK"); this.setCursor(blank); reset(); ballN = 1; level = 1; timeLast = 0; score = 0; counterN = 10; timeCircle = 0; timeCircleSwitch = 0; programLoopCounter = 1; programSpeedAdjust = 1; onePlayerAlive = true; countdownF = true; circular = true; spawnIncrease = true; spawnCircleB = false; spawnMonsterB = false; spawnRandomersB = false; levelSetup(); countdown(); animate(); }
public static Collection searchByAttribute( GeopistaLayer geopistaLayer, int attributeNumber, String value) { Collection finalFeatures = new ArrayList(); if (geopistaLayer == null) return finalFeatures; java.util.List allFeaturesList = geopistaLayer.getFeatureCollectionWrapper().getFeatures(); Iterator allFeaturesListIter = allFeaturesList.iterator(); while (allFeaturesListIter.hasNext()) { Feature localFeature = (Feature) allFeaturesListIter.next(); String nombreAtributo = localFeature.getString(attributeNumber).trim(); if (nombreAtributo.equals(value)) { finalFeatures.add(localFeature); } } return finalFeatures; }
private void drawPlayers(Graphics g) { Iterator i = players.iterator(); Player p; while (i.hasNext()) { p = (Player) i.next(); if (p.isActive()) { if (p.getImmunity()) { g.setColor(Color.red.brighter()); g.drawOval(p.getX() - 30, p.getY() - 30, 60, 60); } g.setColor(Color.WHITE); g.fillOval(p.getX() - 5, p.getY() - 5, 10, 10); } p.paint(g); } }
private void objRelationshipComboAction(ActionEvent e) { ObjRelationship selectedObjRelationship = (ObjRelationship) objRelationshipCombo.getSelectedItem(); ObjRelationship fieldObjRelationship = objEntityViewField.getObjRelationship(); if (selectedObjRelationship != fieldObjRelationship) { objEntityViewField.setObjRelationship(selectedObjRelationship); } if (selectedObjRelationship != null) { ObjEntity targetObjEntity = selectedObjRelationship.getTargetObjEntity(); ObjEntityView nullView = null; java.util.List lookupViews = new ArrayList(); lookupViews.add(nullView); lookupViews.addAll(targetObjEntity.getObjEntityViews()); DefaultComboBoxModel lookupViewModel = new DefaultComboBoxModel(lookupViews.toArray()); lookupViewCombo.setModel(lookupViewModel); ObjEntityView fieldLookupView = objEntityViewField.getLookup().getLookupObjEntityView(); if (fieldLookupView != null) { boolean flagSetSelectedItem = false; for (Iterator itr = lookupViews.iterator(); itr.hasNext(); ) { ObjEntityView view = (ObjEntityView) itr.next(); if (fieldLookupView == view) { lookupViewCombo.setSelectedItem(fieldLookupView); flagSetSelectedItem = true; break; } } if (!flagSetSelectedItem) { lookupViewCombo.setSelectedIndex(0); } } else { lookupViewCombo.setSelectedIndex(0); } } else { ObjEntityView nullView = null; ObjEntityView[] views = new ObjEntityView[] {nullView}; DefaultComboBoxModel viewsModel = new DefaultComboBoxModel(views); lookupViewCombo.setModel(viewsModel); lookupViewCombo.setSelectedIndex(0); } }
public EditorPaneHTMLHelp(String htmlFile) { if (GlobalValues.useSystemBrowserForHelp) { Desktop d = GlobalValues.desktop; try { // create a temp file GlobalValues.forHTMLHelptempFile = new File("tempHTMLHelpSynthetic.html"); FileWriter fw = new FileWriter(GlobalValues.forHTMLHelptempFile); java.util.List<String> list = readTextFromJar(htmlFile); Iterator<String> it = list.iterator(); while (it.hasNext()) { fw.write(it.next() + "\n"); } String canonicalPathOfFile = GlobalValues.forHTMLHelptempFile.getCanonicalPath(); URL urlFile = new URL("file://" + canonicalPathOfFile); URI uriOfFile = urlFile.toURI(); fw.close(); d.browse(uriOfFile); } catch (Exception e) { e.printStackTrace(); } } else { URL initialURL = getClass().getResource(htmlFile); font = GlobalValues.htmlfont; String title = "HTML Help"; setTitle(title); final Stack<String> urlStack = new Stack<String>(); final JEditorPane editorPane; editorPane = new JEditorPane(new HTMLEditorKit().getContentType(), " "); editorPane.setOpaque(false); editorPane.setBorder(null); editorPane.setEditable(false); JPanel magPanel = new JPanel(); magnificationFactor = GlobalValues.helpMagnificationFactor; magFactor = new JTextField(Double.toString(magnificationFactor)); JButton magButton = new JButton("Set Magnification: "); magButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { magnificationFactor = Double.parseDouble(magFactor.getText()); GlobalValues.helpMagnificationFactor = magnificationFactor; } }); magPanel.setLayout(new GridLayout(1, 2)); magPanel.add(magButton); magPanel.add(magFactor); final JTextField url = new JTextField(initialURL.toString()); // set up hyperlink listener editorPane.setEditable(false); try { // remember URL for back button urlStack.push(initialURL.toString()); // show URL in text field url.setText(initialURL.toString()); // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() * GlobalValues.helpMagnificationFactor + "pt; }"; ((HTMLDocument) editorPane.getDocument()).getStyleSheet().addRule(bodyRule); editorPane.setPage(initialURL); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } editorPane.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() * GlobalValues.helpMagnificationFactor + "pt; }"; ((HTMLDocument) editorPane.getDocument()).getStyleSheet().addRule(bodyRule); } }); editorPane.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { // remember URL for back button urlStack.push(event.getURL().toString()); // show URL in text field url.setText(event.getURL().toString()); editorPane.setPage(event.getURL()); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } } } }); // set up checkbox for toggling edit mode final JCheckBox editable = new JCheckBox(); editable.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { editorPane.setEditable(editable.isSelected()); } }); // set up load button for loading URL ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { try { // remember URL for back button urlStack.push(url.getText()); editorPane.setPage(url.getText()); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }; JButton loadButton = new JButton("Load/Magnify"); loadButton.addActionListener(listener); url.addActionListener(listener); // set up back button and button action JButton backButton = new JButton("Back"); backButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if (urlStack.size() <= 1) return; try { // get URL from back button urlStack.pop(); // show URL in text field String urlString = urlStack.peek(); url.setText(urlString); editorPane.setPage(urlString); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }); JPanel allPanel = new JPanel(new BorderLayout()); // put all control components in a panel JPanel ctrlPanel = new JPanel(new BorderLayout()); JPanel urlPanel = new JPanel(); urlPanel.add(new JLabel("URL")); urlPanel.add(url); JPanel buttonPanel = new JPanel(); buttonPanel.add(loadButton); buttonPanel.add(backButton); buttonPanel.add(new JLabel("Editable")); buttonPanel.add(magPanel); buttonPanel.add(editable); ctrlPanel.add(buttonPanel, BorderLayout.NORTH); ctrlPanel.add(urlPanel, BorderLayout.CENTER); allPanel.add(ctrlPanel, BorderLayout.NORTH); allPanel.add(new JScrollPane(editorPane), BorderLayout.CENTER); add(allPanel); } }
private void updateFromDB() { InstanceListPane touchedList = null; // Find out which instances have been selected in all relevant lists // Update the attribute values for changed list. try { if (changedList != null) { java.util.List list = new ArrayList(changedList.getSelection()); // To support it.remove() // Use a new ArrayList. if (list != null && list.size() > 0) { for (Iterator it = list.iterator(); it.hasNext(); ) { GKInstance instance = (GKInstance) it.next(); // Fetch GKInstance based on its DB_ID since SchemaClass might be changed. GKInstance localCopy = fileAdaptor.fetchInstance(instance.getDBID()); dbAdaptor.setUseCache(false); GKInstance dbCopy = dbAdaptor.fetchInstance(instance.getDBID()); dbAdaptor.setUseCache(true); if (SynchronizationManager.getManager().updateFromDB(localCopy, dbCopy, this)) { AttributeEditManager.getManager().attributeEdit(localCopy); fileAdaptor.removeDirtyFlag(localCopy); } else it.remove(); // Remove from the list } // Remove all selected instances changedList.deleteInstances(list); touchedList = changedList; } } if (localHasMoreIEList != null && localHasMoreIEList.getSelection().size() > 0) { List list = new ArrayList(localHasMoreIEList.getSelection()); for (Iterator it = list.iterator(); it.hasNext(); ) { GKInstance localCopy = (GKInstance) it.next(); dbAdaptor.setUseCache(false); GKInstance dbCopy = dbAdaptor.fetchInstance(localCopy.getDBID()); dbAdaptor.setUseCache(true); if (SynchronizationManager.getManager().updateFromDB(localCopy, dbCopy, this)) { AttributeEditManager.getManager().attributeEdit(localCopy); fileAdaptor.removeDirtyFlag(localCopy); } else it.remove(); // Remove from the list, if it it cancelled by the user. } localHasMoreIEList.deleteInstances(list); touchedList = localHasMoreIEList; } // Delete the local copy for deleteInDBList. if (deleteInDBList != null) { java.util.List list = deleteInDBList.getSelection(); if (list != null && list.size() > 0) { for (Iterator it = list.iterator(); it.hasNext(); ) { GKInstance instance = (GKInstance) it.next(); fileAdaptor.deleteInstance(instance); } } deleteInDBList.deleteInstances(list); touchedList = deleteInDBList; } // Get another copy for the local repository if (deleteList != null) { java.util.List<?> list = deleteList.getSelection(); if (list != null && list.size() > 0) { Map<SchemaClass, Set<GKInstance>> checkOutMap = new HashMap<SchemaClass, Set<GKInstance>>(); // All checked out Instances for (Iterator<?> it = list.iterator(); it.hasNext(); ) { GKInstance instance = (GKInstance) it.next(); Map<SchemaClass, List<GKInstance>> schemaMap = InstanceUtilities.listDownloadableInstances(instance); // Have to merge schemaMap to checkOutMap for (SchemaClass key : schemaMap.keySet()) { List<GKInstance> list1 = schemaMap.get(key); if (list1 != null && list1.size() > 0) { Set<GKInstance> list2 = checkOutMap.get(key); if (list2 == null) { list2 = new HashSet<GKInstance>(); checkOutMap.put(key, list2); } // Remove first to avoid any duplication list2.addAll(list1); } } } fileAdaptor.store(checkOutMap); InstanceUtilities.clearShellFlags(checkOutMap); // There are maybe more than selected instances after checking out List<GKInstance> checkedOut = new ArrayList<GKInstance>(); for (Set<GKInstance> set : checkOutMap.values()) { checkedOut.addAll(set); } deleteList.deleteInstances(checkedOut); // deleteList.deleteInstances(list); // Need to clear out these deletion records List<Long> dbIds = new ArrayList<Long>(); for (GKInstance inst : checkedOut) dbIds.add(inst.getDBID()); fileAdaptor.clearDeleteRecord(dbIds); touchedList = deleteList; } } } catch (Exception e) { System.err.println("SynchronizationDialog.updateFromDB(): " + e); e.printStackTrace(); } updateInstanceList(touchedList); }
private void calcTypeComboAction(ActionEvent e) { String comboCalcType = (String) calcTypeCombo.getSelectedItem(); ObjEntity objEntity = objEntityViewField.getObjEntityView().getObjEntity(); if (comboCalcType.equals("No Calculation")) { objEntityViewField.setCalcType("nocalc"); objRelationshipCombo.setEnabled(false); lookupViewCombo.setEnabled(false); lookupFieldCombo.setEnabled(false); ObjAttribute nullAttribute = null; java.util.List attributes = new ArrayList(); attributes.add(nullAttribute); if (objEntity != null) { attributes.addAll(objEntity.getObjAttributes()); } DefaultComboBoxModel attributesDefaultModel = new DefaultComboBoxModel(attributes.toArray()); objAttributeCombo.setModel(attributesDefaultModel); objAttributeCombo.setEnabled(true); if (objEntity != null) { if (objEntityViewField.getObjAttribute() != null) { objAttributeCombo.setSelectedItem(objEntityViewField.getObjAttribute()); } else { objAttributeCombo.setSelectedIndex(0); } } else { objAttributeCombo.setSelectedIndex(0); } } if (comboCalcType.equals("Lookup")) { objEntityViewField.setCalcType("lookup"); objAttributeCombo.setEnabled(false); objRelationshipCombo.setEnabled(true); lookupViewCombo.setEnabled(true); lookupFieldCombo.setEnabled(true); ObjRelationship nullRelationship = null; java.util.List relationships = new ArrayList(); relationships.add(nullRelationship); if (objEntity != null) { relationships.addAll(objEntity.getDataMap().getObjRelationshipsBySourceToOne(objEntity)); } DefaultComboBoxModel relationshipsDefaultModel = new DefaultComboBoxModel(relationships.toArray()); objRelationshipCombo.setModel(relationshipsDefaultModel); ObjRelationship fieldRelationship = objEntityViewField.getObjRelationship(); if (fieldRelationship != null) { boolean flagSetSelectedItem = false; for (Iterator itr = relationships.iterator(); itr.hasNext(); ) { ObjRelationship relationship = (ObjRelationship) itr.next(); if ((relationship != null) && (fieldRelationship.getName().equals(relationship.getName()))) { objRelationshipCombo.setSelectedItem(fieldRelationship); flagSetSelectedItem = true; break; } } if (!flagSetSelectedItem) { objRelationshipCombo.setSelectedIndex(0); } } else { objRelationshipCombo.setSelectedIndex(0); } } }
void setFields(java.util.List fields) { fieldChooser.setCollection(fields.iterator()); }
private void drawLayout(Graphics g) { g.setColor(Color.blue); g.drawRect(10, 10, width - 20, height - 20); g.setColor(Color.red.brighter()); Iterator f = players.iterator(); int lifeDisplayPosition = 0; while (f.hasNext()) { Player h = (Player) f.next(); if (h.isActive()) { lifeDisplayPosition++; String lifeInformation = "Player " + lifeDisplayPosition + ": "; for (int i = 0; i < h.getLives(); i++) { lifeInformation += "\u2606"; } g.drawString(lifeInformation, 20, lifeDisplayPosition * 40); } } borders[2] = width - 20; borders[3] = height - 20; Iterator i = players.iterator(); Player p; while (i.hasNext()) { p = (Player) i.next(); if (p.isActive() && !countdownF && (p.getX() < borders[0] || p.getY() < borders[1] || p.getX() > borders[2] || p.getY() > borders[3]) && (!p.getImmunity())) { p.decLives(width / 2, height / 2); p.setImmunity(true); } if (p.getLives() <= 0) { if (p instanceof MouseControlledPlayer) { MouseControlledPlayer m = (MouseControlledPlayer) p; removeMouseListener(m); removeMouseMotionListener(m); } else if (p instanceof KeyboardControlledPlayer) { KeyboardFocusManager.getCurrentKeyboardFocusManager() .removeKeyEventDispatcher((KeyboardControlledPlayer) p); } i.remove(); for (int h = 0; h < 4; h++) { if (deathLocation[h] == -1) { deathLocation[h] = p.getX(); deathLocation[h + 1] = p.getY(); break; } } } } if ((deathLocation[0] != -1) && (deathLocation[1] != -1)) { g.drawLine( deathLocation[0] - 15, deathLocation[1] - 15, deathLocation[0] + 15, deathLocation[1] + 15); g.drawLine( deathLocation[0] + 15, deathLocation[1] - 15, deathLocation[0] - 15, deathLocation[1] + 15); } if ((deathLocation[2] != -1) && (deathLocation[3] != -1)) { g.drawLine( deathLocation[2] - 15, deathLocation[3] - 15, deathLocation[2] + 15, deathLocation[3] + 15); g.drawLine( deathLocation[2] + 15, deathLocation[3] - 15, deathLocation[2] - 15, deathLocation[3] + 15); } if (!onePlayerAlive) { Font old = g.getFont(); g.setFont(new Font("monospaced", Font.BOLD, 20)); g.setColor(Color.red.darker()); g.drawString("GAME OVER", width / 2 - 40, height / 2); g.setFont(old); g.setColor(Color.WHITE); g.drawString("Score", width - 60, 25); g.drawString(String.valueOf(score), width - 60, 40); } }