Esempio n. 1
0
 /**
  * Tries to insert words into the text area. Displays a dialog if the attempt fails.
  *
  * @param words the words to insert
  */
 public void insertWords(String words) {
   try {
     textArea.append(words + "\n");
   } catch (SecurityException ex) {
     JOptionPane.showMessageDialog(this, "I am sorry, but I cannot do that.");
     ex.printStackTrace();
   }
 }
Esempio n. 2
0
 public boolean saveMidiFile(File file) {
   try {
     int[] fileTypes = MidiSystem.getMidiFileTypes(sequence);
     if (fileTypes.length == 0) {
       System.out.println("Can't save sequence");
       return false;
     } else {
       if (MidiSystem.write(sequence, fileTypes[0], file) == -1) {
         throw new IOException("Problems writing to file");
       }
       return true;
     }
   } catch (SecurityException ex) {
     ex.printStackTrace();
     return false;
   } catch (Exception ex) {
     ex.printStackTrace();
     return false;
   }
 }