2013/04/17

Java - Capitulo 17: Métodos da classe JApplet - Exemplo JApplet

new Comment();
import javax.swing.*;

public class three extends JApplet {
 public void init() {
  // final int ARRAY_SIZE = 10;
  // int array[] = new int[ARRAY_SIZE];

  int array[] = { 1, 4, 6, 6, 4, 3 };
  String outputList = "Posição\tNumero\tValor\n--------\t--------\t--------\n";
  for (int i = 0; i < array.length; i++) {
   array[i] = (int) (2 + Math.random() * 10);

  }

  for (int i = 0; i < array.length; i++) {
   outputList += "\n" + i + "\t" + array[i] + "\t";
   for (int estrelhas = 0; estrelhas < array[i]; estrelhas++) {
    outputList += "*";
   }
  }

  JTextArea textArea = new JTextArea();
  textArea.setText(outputList);

  JOptionPane.showMessageDialog(null, textArea, "Exemplo JApplet",
    JOptionPane.INFORMATION_MESSAGE);
  System.exit(0);
 }
}
If You Enjoyed This, Take 5 Seconds To Share It

0 comentarios:

Postar um comentário