!7

static JComponent form;
static SS data;

p-noconsole {
  load("data");
  
  final JTextField tfSender = jtextfield(completeGMailAddress(gmailDefaultUser()));
  final JTextField tfTo = jtextfield("billg@microsoft.com");
  final JTextField tfSubject = jtextfield("Hello");
  final JTextArea tfText = jwrappedtextarea(trim([[
Hello Bill.

-Sent from my JavaX computer]]));

  form = setFormData(data, showFormTitled2("GMail Send Form",
    "From:", tfSender,
    "To:", tfTo,
    "Subject:", tfSubject,
    "Text:", tfText,
    "", jbutton("Send mail!", r-thread-messagebox {
      infoBox("Sending...");
      quickGMail(getTextTrim(tfSender), getTextTrim(tfTo),
        getTextTrim(tfSubject), getText(tfText));
      infoBox("Sent!");
    })));
    
  addFontChangersToTitleMenu(form, r innerCleanUpAndReRunMain);
}

svoid cleanMeUp {
  if (form != null) setAndSave(data := autoGetDataFromForm(form));
}