Janela + botões [Concluído]

Oi tenho um projeto que gera um sorteio de 0 3000, mas queria colocar ele dentro de uma janela e controla-lo com um botão!!!
Mas como ja disse ainda estou começando e gostaria que alguem me explicasse!!!

class TesteShuffle {
     /**
      */
     public static void main(String[] args) {
         // Embaralhar os valores entre 0 e 3000 - maneira simples
         List valores = new ArrayList();
         for (int i = 0; i < 3000; ++i) {
             valores.add (new Integer(i));
         }
         Collections.shuffle (valores);
         for (int i = 0; i < 3000; ++i);
         System.out.println (valores+"\n");
         // Embaralhar os valores entre 0 e 3000 - como o professor está pensando
         int[] vals = new int[3000];
         for (int i = 0; i < 3000; ++i) {
             vals[i] = i;
         }
         for (int i = 2999; i >= 1; --i) {
             int j; // uma posição entre 0 e (i - 1)
             j = (int) (Math.random() * i);
             // trocar entre si as posições i e j
             int tmp = vals[i];
             vals[i] = vals[j];
             vals[j] = tmp;
         }            
         for (int i = 0; i < 3000; ++i) {
             System.out.print (vals[i] + ", ");
         }
         System.out.println();
         // Embaralhar os valores entre 0 e 3000 - pelo método da força bruta
         int[] numeros = new int[3000];
         numeros[0] = (int) (Math.random() * 3000); // achar o primeiro número
         for (int i = 1; i < 3000; ) {
             int val = (int) (Math.random() * 3000);
             boolean achou = false;
             for (int j = 0; j < i; ++j) {
                 if (numeros[j] == val) {
                     achou = true;
                     break;
                 }
             }
             if (!achou) {
                 numeros[i] = val;
                 ++i;
             }                
         }
         for (int i = 0; i < 3000; ++i) {
             System.out.print (numeros[i] + ", ");
         }
         System.out.println();
     }
 }

Este aí sorteia numeros em serie!!! de 0 a 3000, se alguem souber me explicar!!!

Deixa eu ver se eu entendi …

Vc quer tornar essa sua aplicação … numa aplicação gráfica ?

Se for
Divida sua aplicação em métodos …
Faça uma JFrame … coloca um JButton … e chama os métodos espeficos … e coloca o valor em um JTextField … ou até mesmo em JLabel …

Bem … caso não seja isso … grita ai

Falowww

T+

Haaa … e tem um erro no seu código …

thokk wrote

List valores = new ArrayList();

Acho que seria assim né …

ArrayList valores = new ArrayList();

Certo

T+

Não há erro aqui, ArrayList implementa List.
Até compila…
É o pai de todos reconhecendo um filho.

Com assim dividir, me explique melhor!!! Assim ficarei mais por dentro do que eu quero fazer, os codigos até pesquisei aqui, mas como estes codigos radarem no meu programa???

Bem … seria mais ou menos assim …

Agora vc termina …

[code]import java.awt.;
import java.awt.event.
;
import java.util.ArrayList;
import java.util.Collections;

import javax.swing.*;

class SuffleTest extends JFrame implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;

public SuffleTest() {
	JPanel p = new JPanel();

	simple = new JButton("Suffle Simple");
	p.add(simple);
	simple.addActionListener(this);

	brutal = new JButton("Brutal Force");
	p.add(brutal);
	brutal.addActionListener(this);

	think = new JButton("Teacher think");
	p.add(think);
	think.addActionListener(this);

	getContentPane().add(p, "South");

	textArea = new JTextArea(8, 40);
	scrollPane = new JScrollPane(textArea);
	getContentPane().add(scrollPane, "Center");

	setTitle("Suffle Test GUI");
	setSize(500, 300);
	addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	});
}

public void actionPerformed(ActionEvent evt) {
	Object source = evt.getSource();
	if (source == simple) {
		textArea.append("Suffle Simple \n");
		textArea.append(SuffleSimple().toString());
		textArea.setLineWrap(true);
	}

	else if (source == brutal) {
		//Aqui vc chama o metodo 
	} else if (source == think) {
		//Aqui vc chama o método
	}
}

/*Método que embaralhar os valores 
 * entre 0 e 3000 - maneira simples
 */
public ArrayList SuffleSimple() {
	ArrayList valores = new ArrayList();
	for (int i = 0; i < 3000; ++i) {
		valores.add(new Integer(i));
	}
	Collections.shuffle(valores);
	for (int i = 0; i < 3000; ++i)
		;
	return valores;

}

private JButton simple;

private JButton brutal;

private JButton think;

private JTextArea textArea;

private JScrollPane scrollPane;

}
[/code]

Essa é a classe que contem o método main

[code]public class Teste {

public static void main(String[] args) {
	SuffleTest test = new SuffleTest();
	test.setVisible(true);

}

}[/code]

Bele …

Espero ter sido claro … qualquer coisa grita ae :lol:

Haaa eu troque de List … para ArrayList …

Voce tambem pode inserir janelas de entrada e saída no lugar de System.out.println, é bem fácil e até que fica legal!
Ex:

import javax.swing.*;
public class soma
{
public static void main(String args[] )
{
//entrada
int n = Integer.parseInt(JOptionPane.showInputDialog("Digite um número: "));
int m = Integer.parseInt(JOptionPane.showInputDialog("Digite outro número: "));
//saída
JOptionPane.showMessageDialog(null, "O resultado da soma é: "+ (n+m));
}
}

Obrigado Pessoal!!!

Agradeço a todos vcs!!!

Até mais!!!