ciao ragazzi, sono nuovo in java e mi sono imbattuto in un problema piuttosto banale, ovvero che quando clicco su un bottone questo rimane premuto.
riporto il codice, comunque in sintesi il bottone apre un filechooser
codice:private void okButtonActionPerformed(java.awt.event.ActionEvent evt) { // se è selezionato "import a game", apre un file chooser // se il file non esiste viene mostrato un messaggio d'errore e viene // riproposto il file chooser finché non viene inserito un file corretto // o finché non si preme cancel if(singleGameButton.isSelected()){ do{ filefound = false; returnVal = sFileChooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { file = sFileChooser.getSelectedFile(); try{ if(!file.getCanonicalFile().exists()){ JInternalFrame frame = new JInternalFrame() ; JOptionPane.showMessageDialog(frame, "The file \""+(file.getCanonicalFile().toString())+"\" does not exist.", "Error: File not Found", JOptionPane.ERROR_MESSAGE); } else filefound = true; }catch (IOException e) { System.out.println("IOException is "+ e); } } //se l'utente preme cancel esce dal ciclo if(returnVal == JFileChooser.CANCEL_OPTION) filefound = true; }while(filefound == false); } }

Rispondi quotando

