br.univali.ps.nucleo.ExcecaoAplicacao: java.lang.NullPointerException: peer
at br.univali.ps.nucleo.TratadorExcecoes.uncaughtException(TratadorExcecoes.java:145)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1057)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1052)
at java.awt.EventDispatchThread.processException(EventDispatchThread.java:227)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:219)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.NullPointerException: peer
at sun.awt.windows.WInputMethod.openCandidateWindow(Native Method)
at sun.awt.windows.WInputMethod.access$400(WInputMethod.java:45)
at sun.awt.windows.WInputMethod$1.run(WInputMethod.java:602)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
... 5 more
Código do Erro:
programa
{
inclua biblioteca Tipos --> c
inclua biblioteca Graficos --> g
inclua biblioteca Texto --> t
inclua biblioteca Matematica --> m
funcao real pow(inteiro base, inteiro expoente) {retorne m.potencia(base*1.0, expoente*1.0)}
funcao inicio()
{
const inteiro quantLinhasMax = 31, distanciaPontos = 20
inteiro quantQuestoes, quantQuestoesLoop, piramide[quantLinhasMax][(quantLinhasMax+1)*2+2]
escreva("Quantidade de questões: ")
leia(quantQuestoes)
quantQuestoesLoop = quantQuestoes+1
enquanto (quantQuestoesLoop < 1 ou quantQuestoesLoop > quantLinhasMax)
{
escreva("\nQuantidade invalida."+
"\nQuantidade de questões: ")
leia(quantQuestoesLoop)
}
inteiro meio = quantQuestoesLoop + 1
piramide[0][meio] = 1
para(inteiro i=0; i<quantQuestoesLoop; i++)
{
para(inteiro j=0; j<i+1; j+=2)
{
se (i==0) {pare}
inteiro pos = (j + i%2)
piramide[i][meio - pos] = piramide[i-1][meio - pos-1] + piramide[i-1][meio - pos+1]
piramide[i][meio + pos] = piramide[i-1][meio - pos-1] + piramide[i-1][meio - pos+1]
}
}
real pontos[quantLinhasMax], maiorPonto=0.0
para (inteiro q=0; q<quantQuestoesLoop; q++)
{
pontos[q] = piramide[quantQuestoes][2+q*2] * pow(4, quantQuestoes - q) /
pow(5, quantQuestoes)
se (maiorPonto < pontos[q]) {maiorPonto = pontos[q]}
}
g.iniciar_modo_grafico(falso)
g.definir_dimensoes_janela(quantQuestoes * distanciaPontos, 150)
g.definir_cor(g.COR_BRANCO)
g.limpar()
g.definir_cor(g.COR_PRETO)
para (inteiro q=0; q<quantQuestoesLoop; q++)
{
//j=2; j < (quantQuestoes+1)*2; j+=2
se(q>0) {g.desenhar_linha((q-1)*distanciaPontos, c.real_para_inteiro(125-(100/maiorPonto)*pontos[q-1]),
q *distanciaPontos, c.real_para_inteiro(125-(100/maiorPonto)*pontos[q ]))}
}
g.renderizar()
/*
* ----------------------------------------------------------------------------------------
* Esse trecho do código desenha o triangulo como texto no terminal, mas não tá 100% pronto
* ----------------------------------------------------------------------------------------
* Apague ou coloque um / na linha de baixo para desativar/ativar essa parte
*
inteiro quantCaracteres = t.numero_caracteres(piramide[(quantQuestoes)][meio + (quantQuestoesLoop)%2]+"")
cadeia texto = ""
para(inteiro i=0; i<quantQuestoesLoop; i++)
{
para(inteiro j=0; j<(quantQuestoesLoop+1)*2; j++)
{
se (piramide[i][j] > 0)
{
cadeia numero = piramide[i][j]+""
// Espaçamento na piramide
se (j < meio) {texto += t.preencher_a_esquerda(' ', quantCaracteres, numero)}
senao se (j > meio) {texto += numero + t.preencher_a_esquerda(' ', quantCaracteres - t.numero_caracteres(numero), "")}
senao {inteiro espacoEsquerda = (quantCaracteres+t.numero_caracteres(numero))/2
texto += t.preencher_a_esquerda(' ', espacoEsquerda, numero) +
t.preencher_a_esquerda(' ', quantCaracteres-espacoEsquerda-t.numero_caracteres(numero)/2, "")}
// Para se não existe mais nada a direita
se (piramide[i][j+2] <= 0) {pare}
}
senao {texto += t.preencher_a_esquerda(' ', quantCaracteres, "")}
}
texto += "\n"
}
escreva(texto)
/*
*/
leia(meio)
}
br.univali.ps.nucleo.ExcecaoAplicacao: java.lang.NullPointerException: peer at br.univali.ps.nucleo.TratadorExcecoes.uncaughtException(TratadorExcecoes.java:145) at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1057) at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1052) at java.awt.EventDispatchThread.processException(EventDispatchThread.java:227) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:219) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) Caused by: java.lang.NullPointerException: peer at sun.awt.windows.WInputMethod.openCandidateWindow(Native Method) at sun.awt.windows.WInputMethod.access$400(WInputMethod.java:45) at sun.awt.windows.WInputMethod$1.run(WInputMethod.java:602) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84) at java.awt.EventQueue$4.run(EventQueue.java:733) at java.awt.EventQueue$4.run(EventQueue.java:731) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) at java.awt.EventQueue.dispatchEvent(EventQueue.java:730) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205) ... 5 more
Código do Erro: programa { inclua biblioteca Tipos --> c inclua biblioteca Graficos --> g inclua biblioteca Texto --> t inclua biblioteca Matematica --> m
}