Havia testado este código antes, e funcionava normalmente, depois que atualizei o SDK, porque não estava dando para desenvolver aplicativos, ele não aceitou as importações. Alguém sabe o porque?
Erro em Anexo:
Opens the artifact search dialog to search for ‘javax.swing’ to add
to your target
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
public class Atividade_01 {
public static void main(String[] args) {
String entrada1 = null;
while (entrada1 == null || entrada1.equals("")) {
entrada1 = JOptionPane.showInputDialog(null, "Digite um Número", "Fatorial", JOptionPane.PLAIN_MESSAGE);
if (entrada1 == null || entrada1.equals("")) {
JOptionPane.showMessageDialog(null, "Você não respondeu a pergunta.");
}
}
int j = Integer.parseInt(entrada1);
int resposta = JOptionPane.showConfirmDialog(null, "Quer ver qual a resposta?");
if (resposta == JOptionPane.YES_OPTION) {
JLabel mensagem = new JLabel(String.format("%d! = %d", j, fatorial(j)));
mensagem.setFont(new Font("Arial", Font.BOLD, 20));
JOptionPane.showMessageDialog(null,"A resposta é...");
JOptionPane.showMessageDialog(null,mensagem);
} else {
JOptionPane.showMessageDialog(null, "Que falta de interesse!!!");
}
}
public static int fatorial(int n) {
if (n <= 1)
return 1;
int r = fatorial(n - 1) * n;
return r;
}
}