Galera, sou novo to no primeiro ano ainda da faculdade e to na linguagem java, criei um programa até que legal só que agora preciso muito jogar ele em uma Interface Grafica, eu consigo coisas basicas mas nunca da em nada, por favor dao um helps ae?
Meu código é esse ae.
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;
import javax.swing.JOptionPane;
import javax.swing.Icon;
import javax.swing.ImageIcon;
public class Exemplo2 {
public static void main(String[] args) throws IOException {
ArrayList agenda = new ArrayList();
Scanner ler = new Scanner(System.in);
int opcao;
importar(agenda);
do {
String ret = JOptionPane.showInputDialog (
"\n\n Menu PokeAgenda \n"+
"[ 1 ] Incluir Pokemon\n"+
"[ 2 ] Excluir Pokemon\n"+
"[ 3 ] Listar todos Pokemons\n"+
"[ 4 ] Pesquisar Pokemons\n"+
"[ 0 ] Encerrar a PokeAgenda\n"+
"\nO que deseja mestre Pokemon: ");
opcao = Integer.parseInt(ret);
switch (opcao) {
case 1: incluir(agenda); break;
case 2: excluir(agenda); break;
case 3: listar(agenda); break;
case 4: pesquisar(agenda);
}
} while (opcao != 0);
exportar(agenda);
}
public static void importar(ArrayList agenda) {
try {
FileReader arq = new FileReader(“agenda.txt”);
BufferedReader lerArq = new BufferedReader(arq);
String linha = lerArq.readLine(); // lê a primeira linha
// a variável “linha” recebe o valor “null” quando o processo
// de repetição atingir o final do arquivo texto
while (linha != null) {
agenda.add(linha);
linha = lerArq.readLine(); // lê da segunda até a última linha
}
arq.close();
} catch (IOException e) {
System.err.printf(“Erro na abertura do arquivo: %s.”,
e.getMessage());
}
}
public static void exportar(ArrayList agenda)
throws IOException {
FileWriter arq = new FileWriter(“agenda.txt”);
PrintWriter gravarArq = new PrintWriter(arq);
int i, n = agenda.size();
for (i=0; i<n; i++) {
gravarArq.printf("%s%n", agenda.get(i));
}
gravarArq.close();
}
public static void incluir(ArrayList agenda) {
Scanner ler = new Scanner(System.in);
String nome, descricao;
JOptionPane.showInputDialog("\nQual sera o nome do seu Pokemon:\n");
JOptionPane.showInputDialog("\nDescreva seu Pokemon:\n");
// grava os dados no final da "lista"
agenda.add(nome + ";" + descricao);
}
public static void excluir(ArrayList agenda) {
Scanner ler = new Scanner(System.in);
int i;
listar(agenda);
JOptionPane.showInputDialog("\nQual numero do Pokemon que deseja excluir?\n");
i = ler.nextInt();
try {
agenda.remove(i);
} catch (IndexOutOfBoundsException e) {
// exceção lançada para indicar que um índice (i)
// está fora do intervalo válido (de 0 até agenda.size()-1)
System.out.printf("\nErro: posição inválida (%s).\n\n",
e.getMessage());
}
}
public static void listar(ArrayList agenda) {
JOptionPane.showInputDialog("\nListadando a PokeAgenda:\n");
int i, n = agenda.size();
for (i=0; i<n; i++) {
System.out.printf(“Posição %d- %s\n\n”, i, agenda.get(i));
}
System.out.printf("---------------------------------------");
}
public static void pesquisar(ArrayList agenda) {
Scanner ler = new Scanner(System.in);
String s;
JOptionPane.showInputDialog("\nInforme o nome Pokemon:\n");
s = ler.nextLine();
int i, n = agenda.size();
s = s.toUpperCase();
String dados[];
for (i=0; i<n; i++) {
// informando "joão", por exemplo, na entrada serão mostrados
// todos os contatos que possuem "joão" no nome
if (agenda.get(i).toUpperCase().indexOf(s) != -1) {
dados = agenda.get(i).split(";");
JOptionPane.showInputDialog("\nNome....: %s", dados[0]);
JOptionPane.showInputDialog("\nDescricao: %s\n", dados[1]);
}
}
}
}