|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Junior Member
Iscritto dal: Aug 2006
Messaggi: 3
|
Come fermare un programma in java?
Ciao a tutti e buon proseguimento d'estate,
sto facendo un programma in java e ho un assoluto bisogno di far fermare il programma che sto costruendo finchè non si verifica una condizione. In pratica sto facendo un pò di grafica e voglio che il mio programma fermi l'esecuzione finchè non è premuto un bottone nel pannello... spero di essermi spiegato bene, per favore aiutatemi è urgente, GRAZIE |
![]() |
![]() |
![]() |
#2 |
Member
Iscritto dal: Sep 2005
Città: Barcelona
Messaggi: 200
|
potresti gestire la cosa tramite thread... e tenerlo bloccato finche appunto finchè nn arriva l'evento.
__________________
Code without tests is broken by design. |
![]() |
![]() |
![]() |
#3 |
Senior Member
Iscritto dal: May 2005
Città: Roma
Messaggi: 7938
|
oppure metti una azione nel pulsante, ovvero quando premi fai esci
![]() in codice Codice:
pulsanteCheFaAzione.addActionerListener(new Action Listener(){ public void actionPerformed(actionEvent e){ System.exit(-1); } } );
__________________
My gaming placement Ultima modifica di franksisca : 10-08-2006 alle 16:17. Motivo: mi ero dimenticato un ; |
![]() |
![]() |
![]() |
#4 |
Junior Member
Iscritto dal: Aug 2006
Messaggi: 3
|
Ma cosa comporta la chiamata System.exit quando all'interno gli passo -1 o zero?
|
![]() |
![]() |
![]() |
#5 | |
Senior Member
Iscritto dal: May 2005
Città: Roma
Messaggi: 7938
|
Quote:
![]()
__________________
My gaming placement |
|
![]() |
![]() |
![]() |
#6 |
Senior Member
Iscritto dal: May 2005
Città: Roma
Messaggi: 7938
|
dalle api di java
Codice:
exit public void exit(int status) Terminates the currently running Java virtual machine by initiating its shutdown sequence. This method never returns normally. The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination. The virtual machine's shutdown sequence consists of two phases. In the first phase all registered shutdown hooks, if any, are started in some unspecified order and allowed to run concurrently until they finish. In the second phase all uninvoked finalizers are run if finalization-on-exit has been enabled. Once this is done the virtual machine halts. If this method is invoked after the virtual machine has begun its shutdown sequence then if shutdown hooks are being run this method will block indefinitely. If shutdown hooks have already been run and on-exit finalization has been enabled then this method halts the virtual machine with the given status code if the status is nonzero; otherwise, it blocks indefinitely. The System.exit method is the conventional and convenient means of invoking this method. Parameters: status - Termination status. By convention, a nonzero status code indicates abnormal termination. Throws: SecurityException - If a security manager is present and its checkExit method does not permit exiting with the specified status See Also: SecurityException, SecurityManager.checkExit(int), addShutdownHook(java.lang.Thread), removeShutdownHook(java.lang.Thread), runFinalizersOnExit(boolean), halt(int) ![]()
__________________
My gaming placement |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 14:53.