// draw all the shapes on the list public void paint(Graphics g) { super.paint(g); // is no super.paint(), then lines stay on screen for (int i = 0; i < allTheShapesCount; i++) { allTheShapes[i].drawMe(g); } }
public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; g2d.draw( new Ellipse2D.Double( centerx - (centery - 500), centery - (centery - 500), 2 * (centery - 500), 2 * (centery - 500))); try { g2d.draw( new Ellipse2D.Double( player.x - player.size / 2, player.y - player.size / 2, player.size, player.size)); } catch (NullPointerException e) { } k = 1; while (k <= ballCount) { g2d.draw( new Ellipse2D.Double( ball[k].x - ball[k].size / 2, ball[k].y - ball[k].size / 2, ball[k].size, ball[k].size)); k++; } }
public void paint(Graphics g) { super.paint(g); g.setFont(fotn); Random generator1 = new Random(); height = bird.getBirdy(); g.drawImage(Backgroundtop, 0, 0, 450, 644, null); g.drawImage(Bird, 100, height, 40, 30, null); if (firstrun == true) { // intiate threads pipethread[currentthreads].start(); birdthread.start(); firstrun = false; } for (int index = 0; index <= currentthreads; index++) { g.drawImage(Pipes, pipeob[index].getpipex(), pipeob[index].getpipey(), null); } g.drawImage(Backgroundbottom, 0, 644, 450, 156, null); g.setColor(Color.black); if (pipeob[currentthreads].getpipex() <= 550) { currentthreads++; pipethread[currentthreads].start(); score++; } g.drawString("Score: " + score + "", 50, 50); for (int index = 0; index < currentthreads; index++) { if (((height < pipeob[index].getpipey() + 730) || (height > pipeob[index].getpipey() + 870)) && ((pipeob[index].getpipex() < 100) && (pipeob[index].getpipex() + 72 > 100)) || ((height < pipeob[index].getpipey() + 730) || (height > pipeob[index].getpipey() + 870)) && ((pipeob[index].getpipex() < 140) && (pipeob[index].getpipex() + 72 > 140)) || ((height + 30 < pipeob[index].getpipey() + 730) || (height + 30 > pipeob[index].getpipey() + 870)) && ((pipeob[index].getpipex() < 100) && (pipeob[index].getpipex() + 72 > 100)) || ((height + 30 < pipeob[index].getpipey() + 730) || (height + 30 > pipeob[index].getpipey() + 870)) && ((pipeob[index].getpipex() < 140) && (pipeob[index].getpipex() + 72 > 140)) || ((height + 30 >= 644))) { g.drawImage(gameover, 125, 200, null); JOptionPane.showMessageDialog( null, "You Dead. \n you scored " + score, "Oh no!", JOptionPane.INFORMATION_MESSAGE); } } for (int counter = 0; counter <= 50000000; counter++) { counter++; counter--; } do { repaint(); } while (replay = true); }
public void paint(Graphics g) { super.paint(g); if (screen.equalsIgnoreCase("title")) { MyPanel.score = 0; hs = new Highscore(); c.removeAll(); c.add(ts); panel = null; ts.revalidate(); } else if (screen.equalsIgnoreCase("instructions")) { c.removeAll(); c.add(instructions); instructions.revalidate(); } else if (screen.equalsIgnoreCase("mode")) { c.removeAll(); c.add(mode); mode.revalidate(); } else if (screen.equalsIgnoreCase("difficulty")) { c.removeAll(); c.add(dif); dif.revalidate(); } else if (screen.equalsIgnoreCase("highscore")) { if (hs.returnCount() == 0) { c.removeAll(); c.add(hs); c.validate(); } } else if (screen.equalsIgnoreCase("gameover")) { if (!once) { c.removeAll(); c.add(gg); once = true; c.validate(); } } else { if (once) { c.removeAll(); panel = new MyPanel(THA.WIDTH, THA.HEIGHT, ai, diff); c.setLayout(new BorderLayout()); c.add(panel.returnNs(), BorderLayout.WEST); c.add(panel, BorderLayout.CENTER); c.add(btns, BorderLayout.SOUTH); c.add(panel.returnAmmo(), BorderLayout.EAST); c.validate(); once = false; } } repaint(); }
/** * ************************************************************************* CONCRETE Class::paint * Purpose: The paint() method is an overridden method inherited from JFrame that draws the * indicator on the screen. This method must be overridden so that various JRE services can update * the display. If you do not override paint, the indicator will not be consistiently drawn to the * screen and may have various graphics disappear at run time. This method is invoked indirectly * by the repaint() method. * * <p>Arguments: Graphics g this is the indicator's graphic instance. * * <p>Returns: none * * <p>Exceptions: none ************************************************************************** */ public void paint(Graphics g) { super.paint(g); FontMetrics fm = g.getFontMetrics(); int xLabelPosition = (int) (Height * 0.5) - (int) (fm.stringWidth(MessageLabel) * 0.5); int yLabelPosition = (int) (Height * 0.90); g.setColor(IluminationColor); g.fillRoundRect( (int) (Height * 0.15), (int) (Height * 0.35), (int) (Height * 0.70), (int) (Height * 0.40), (int) (Height * 0.20), (int) (Height * 0.20)); g.setColor(TextColor); g.drawString(MessageLabel, xLabelPosition, yLabelPosition); } // paint
public void paint(Graphics g) { super.paint(g); if (lastX > firstX && lastY > firstY && dragStatus) { int weightRec = (lastX > firstX) ? (lastX - firstX) : (firstX - lastX); int heightRec = (lastY > firstY) ? (lastY - firstY) : (firstY - lastY); g.drawRect(firstX, firstY, weightRec, heightRec); Color dragColor = new Color(255, 255, 255, 70); Color finishColor = new Color(0, 0, 0, 0); if (isPress) g.setColor(dragColor); else g.setColor(finishColor); g.fillRect(firstX, firstY, weightRec, heightRec); System.out.println("Draw Rec at X:" + firstX + ", Y:" + firstY); } }
public void paint(Graphics g) { super.paint(g); }