Q:

How can I stop my text array from flashing and switching in Java?

I am having a problem with my text array, the text keeps switching constantly. This is the code that I have so far for it:  
private void drawSplash(Graphics2D g) {
  if (displayed == false) {
     Random r = new Random();
     String list;
     String items[] = { "Buggy!", "New Game!", "Roll up, roll up!",
           "Made from Scratch" };
     int amount;
     amount = (int) (Math.random() * 25 + 1);
     list = items[r.nextInt(3 + 1)];
     System.out.println(list);
     g.setFont(font2);
     g.setColor(Color.BLACK);
     g.drawString(list, 320, 240);
     displayed = true;
  }
}

I want to make it so that whenever the program is restarted, the string change.
Can anyone help me with this please? It's really bugging me.

A:

Problem is that you want to keep state between program startups, otherwise you will get repeats. So what you want to do is:
During startup: if no property file with a shuffled list exists, create a shuffled list, set index to 1
Then:

during startup: retrieve shuffled list and index from property file
put the item with the given index in a static field
increase the index and store the property file again
display the item during paint

I'll leave it up to you what you do when you run out of items.

For a quick fix that simply displays a random item each time the class is used:
private static String ITEMS[] = { "Buggy!", "New Game!",
        "Roll up, roll up!", "Made from Scratch" };

private String itemDisplayed = chooseItem();

private String chooseItem() {
    Random r = new SecureRandom();
    int i = r.nextInt(ITEMS.length);
    return ITEMS[i];
}

private void drawSplash(Graphics2D g) {
    g.setColor(Color.BLACK);
    g.setFont(font2);
    g.drawString(itemDisplayed, 320, 240);
    displayed = true;
}

