1

Is there a method in Java to make a string appear in GUI while blinking? I am writing a program and I need the string below to display while blinking. Thanks.

        g.setColor(Color.RED);
        g.setFont(new Font("Serif", Font.BOLD, 30));
        g.drawString("Game Over!!! Score: " + score, 190, 300);
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
RonnyStack
  • 31
  • 4
  • 2
    You can use the code from https://stackoverflow.com/questions/17524080/enable-blinking-of-jlabel-3-times-and-then-remain-invisible-disappear – takendarkk Jun 25 '18 at 19:08
  • Also check out [this question](https://stackoverflow.com/questions/43084698/flashing-label-in-javafx-gui) which is very similar – Winston Yang Jun 25 '18 at 19:09
  • @csmckelvey *"You can use the code from.."* Indeed! In this case, change the actions from updating the label, to calling `repaint()`. I'd suggest after incrementing a counter, change the `Color` of a variable referenced in the paint method. – Andrew Thompson Jun 26 '18 at 00:39

0 Answers0