/** * Here's the problem the FOR loop prints the String Array Contents on top of one another * so made a WHILE loop (to me, a newb, this seemms the thing to do?) to space out the Array Eleements for each increment... * *However, when ALT+TABBING (switch to another window) after VIEWING the running app, the CONTENTS of the String Array *as printed to the screen disappear??? It will just say " A char:" but the " 1 2 3 4 5 " disappears? * *This does NOT occur with the FOR loop.. * *VERY Confused */ package aiycaptcha_plain; import java.awt.Container; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import javax.swing.JFrame; public class Understand_Disappear extends JFrame{ private String randStr = "A \"char\":"; private String[] str5 = {"1", "2","3","4","5"}; private int i = 0; private int initialPos = 215; public Understand_Disappear() { super ("It goes away bwaaaaa"); getContentPane().setBackground( Color.gray ); } public void paint( Graphics g ) { drawText( g ); } public void drawText( Graphics g ) { super.paint( g ); Graphics2D graphics2D = ( Graphics2D ) g ; graphics2D.setFont(new Font("Goudy Handtooled BT", Font.PLAIN, 44)); graphics2D.setPaint(Color.orange); // graphics2D.drawString("Java 2D", 25, 115); graphics2D.drawString(randStr, 25, 115); /** for (int i = 0; i < str5.length; i++) { int initialPos = 200; initialPos += 50; graphics2D.drawString(str5[i], initialPos, 115); } */ while (i < str5.length) { graphics2D.drawString(str5[i], initialPos, 115); i++; initialPos += 30; } } public static void main(String[] args) { Understand_Disappear uS = new Understand_Disappear(); uS.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); uS.setSize(590,150); uS.setVisible( true ); } }