Exemplo n.º 1
0
  void lookUpTaxonID(String taxonID) {
    URI url;

    try {
      // We should look up the miITIS_TSN status, but since we don't
      // have any options there ...
      url =
          new URI(
              "http://www.itis.gov/servlet/SingleRpt/SingleRpt?search_topic=TSN&search_value="
                  + taxonID);
    } catch (URISyntaxException e) {
      throw new RuntimeException(e);
    }

    try {
      Desktop desktop = Desktop.getDesktop();
      desktop.browse(url);

    } catch (IOException e) {
      MessageBox.messageBox(
          mainFrame,
          "Could not open URL '" + url + "'",
          "The following error occurred while looking up URL '" + url + "': " + e.getMessage(),
          MessageBox.ERROR);
    }
  }
Exemplo n.º 2
0
 private static void getStudentPass(String facultyNumber)
     throws IOException, JAXBException, SAXException, TransformerException,
         ParserConfigurationException {
   if (Pattern.matches("\\d{5,6}", facultyNumber)) {
     InputStream inputStream = new FileInputStream(Constants.CONFIG_FILE_PATH.toString());
     properties.load(inputStream);
     File protocolFile = new File(properties.getProperty("protocol"));
     ReadWriteUtils utils = new ReadWriteUtils(Protocol.class);
     Protocol protocol = (Protocol) utils.readFromXml(protocolFile);
     StudentPass studentPass = protocol.getStudentPass(Integer.parseInt(facultyNumber));
     utils.setType(StudentPass.class);
     File outputFile =
         new File(properties.getProperty("output") + "\\StudentPass" + facultyNumber + ".xml");
     if (outputFile.createNewFile()) System.out.println("File created!");
     utils.writeXml(studentPass, outputFile);
     utils.writeXml(studentPass, System.out);
     System.out.println(
         "Do you want to open the generated XML Document with your default viewing program?");
     if (awaitResponse()) Desktop.getDesktop().open(outputFile);
     System.out.println(
         "Do you want to transform the generated XML Document to html file and open with your default viewing program?");
     if (awaitResponse()) {
       Desktop.getDesktop()
           .open(transformXML(outputFile, new File(Constants.STUDENT_STYLE.toString())));
     }
     inputStream.close();
   } else throw new IllegalArgumentException("Invalid faculty number is entered!");
 }
Exemplo n.º 3
0
  void searchName(String nameToMatch) {
    URI url;

    try {
      // We should look up the miITIS_TSN status, but since we don't
      // have any options there ...
      url = new URI("http", "www.google.com", "/search", "q=" + nameToMatch);
      // I think the URI handles the URL encoding?

    } catch (URISyntaxException e) {
      throw new RuntimeException(e);
    }

    try {
      Desktop desktop = Desktop.getDesktop();
      desktop.browse(url);

    } catch (IOException e) {
      MessageBox.messageBox(
          mainFrame,
          "Could not open URL '" + url + "'",
          "The following error occurred while looking up URL '" + url + "': " + e.getMessage(),
          MessageBox.ERROR);
    }
  }
Exemplo n.º 4
0
  @Override
  public void HUDAreaClicked(HUDArea ha) {
    HUDArea hudArea = null;

    for (int i = 0; i < hudAreas.size(); i++) {
      hudArea = hudAreas.get(i);
      if (hudArea == ha) {
        if (hudArea.getType().equals("single_player")) {
          hudManager.unloadHUD(name);
          hudManager.loadHUD(HUDManager.HUDType.ScreenCharacterSelection);
        } else if (hudArea.getType().equals("multi_player")) {
          if (hudManager.getIsOnline() && Game.VERSION.equals(hudManager.getCurrentVersion())) {
            hudManager.unloadHUD(name);
            hudManager.loadHUD(HUDManager.HUDType.ScreenMultiPlayer);
          } else {
            registry.showMessage(
                "Error",
                "Must be online and have latest version to play.  Try updating and restarting.");
          }
        } else if (hudArea.getType().equals("settings")) {
          hudManager.unloadHUD(name);
          hudManager.loadHUD(HUDManager.HUDType.ScreenSettings);
        } else if (hudArea.getType().equals("exit")) {
          hudManager.gameExit();
        } else if (hudArea.getType().equals("donate")) {
          String url = "http://www.epicinventor.com/donate.html";

          try {
            Desktop.getDesktop().browse(java.net.URI.create(url));
          } catch (Exception e) {
          }
        } else if (hudArea.getType().equals("help")) {
          String url = "http://www.epicinventor.com/help.html";

          try {
            Desktop.getDesktop().browse(java.net.URI.create(url));
          } catch (Exception e) {
          }
        } else if (hudArea.getType().equals("download")) {
          Process p = null;
          try {
            p = Runtime.getRuntime().exec("EpicInventorUpdater");
          } catch (IOException ex) {
          }

          if (p == null) {
            registry.showMessage(
                "Error", "Could not launch auto-updater, run manually from folder");
          } else {
            hudManager.gameExit();
          }
        }
      }
    }
  }
Exemplo n.º 5
0
 // deschide fereastra editorului pentru fisierul openPhilePath
 public void edit(String entry) throws PhileNotOpenException {
   try {
     String targetPath = currentPath + "\\" + entry;
     File file = new File(targetPath);
     if (!file.exists()) {
       System.out.println("Fisierul nu exista");
       return;
     }
     Desktop dk = Desktop.getDesktop();
     // Open a file
     dk.edit(file);
   } catch (Exception e) {
   } finally {
     takePath();
   }
 }
Exemplo n.º 6
0
 private static void getProtocol()
     throws IOException, JAXBException, SAXException, ParserConfigurationException,
         TransformerException {
   InputStream inputStream = new FileInputStream(Constants.CONFIG_FILE_PATH.toString());
   properties.load(inputStream);
   File protocolFile = new File(properties.getProperty("protocol"));
   ReadWriteUtils utils = new ReadWriteUtils(Protocol.class);
   utils.writeXml(utils.readFromXml(protocolFile), System.out);
   System.out.println("Do you want to open protocol with your default viewing program?");
   if (awaitResponse()) Desktop.getDesktop().open(protocolFile);
   System.out.println(
       "Do you want to transform and open the protocol file with your default viewing program?");
   if (awaitResponse())
     Desktop.getDesktop()
         .open(transformXML(protocolFile, new File(Constants.PROTOCOL_STYLE.toString())));
 }
Exemplo n.º 7
0
 public void secureUse(File fi) {
   // System.out.println("Using " + fi.getAbsolutePath());
   try {
     Desktop.getDesktop().open(fi);
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 8
0
  public void openLink(String link) {
    if (WWUtil.isEmpty(link)) return;

    try {
      try {
        // See if the link is a URL, and invoke the browser if it is
        URL url = new URL(link.replace(" ", "%20"));
        Desktop.getDesktop().browse(url.toURI());
        return;
      } catch (MalformedURLException ignored) { // just means that the link is not a URL
      }

      // It's not a URL, so see if it's a file and invoke the desktop to open it if it is.
      File file = new File(link);
      if (file.exists()) {
        Desktop.getDesktop().open(new File(link));
        return;
      }

      String message = "Cannot open resource. It's not a valid file or URL.";
      Util.getLogger().log(Level.SEVERE, message);
      this.showErrorDialog(null, "No Reconocido V\u00ednculo", message);
    } catch (UnsupportedOperationException e) {
      String message =
          "Unable to open resource.\n"
              + link
              + (e.getMessage() != null ? "\n" + e.getMessage() : "");
      Util.getLogger().log(Level.SEVERE, message, e);
      this.showErrorDialog(e, "Error Opening Resource", message);
    } catch (IOException e) {
      String message =
          "I/O error while opening resource.\n"
              + link
              + (e.getMessage() != null ? ".\n" + e.getMessage() : "");
      Util.getLogger().log(Level.SEVERE, message, e);
      this.showErrorDialog(e, "I/O Error", message);
    } catch (Exception e) {
      String message =
          "Error attempting to open resource.\n"
              + link
              + (e.getMessage() != null ? "\n" + e.getMessage() : "");
      Util.getLogger().log(Level.SEVERE, message);
      this.showMessageDialog(message, "Error Opening Resource", JOptionPane.ERROR_MESSAGE);
    }
  }
Exemplo n.º 9
0
  /**
   * 访问服务器环境
   *
   * @param names 参数名字
   * @param values 参数值
   */
  public static void visitEnvServerByParameters(String[] names, String[] values) {
    int len = Math.min(ArrayUtils.getLength(names), ArrayUtils.getLength(values));
    String[] segs = new String[len];
    for (int i = 0; i < len; i++) {
      try {
        // 设计器里面据说为了改什么界面统一, 把分隔符统一用File.separator, 意味着在windows里面报表路径变成了\
        // 以前的超链, 以及预览url什么的都是/, 产品组的意思就是用到的地方替换下, 真恶心.
        String value = values[i].replaceAll("\\\\", "/");
        segs[i] =
            URLEncoder.encode(CodeUtils.cjkEncode(names[i]), EncodeConstants.ENCODING_UTF_8)
                + "="
                + URLEncoder.encode(CodeUtils.cjkEncode(value), "UTF-8");
      } catch (UnsupportedEncodingException e) {
        FRContext.getLogger().error(e.getMessage(), e);
      }
    }
    String postfixOfUri = (segs.length > 0 ? "?" + StableUtils.join(segs, "&") : StringUtils.EMPTY);

    if (FRContext.getCurrentEnv() instanceof RemoteEnv) {
      try {
        if (Utils.isEmbeddedParameter(postfixOfUri)) {
          String time = Calendar.getInstance().getTime().toString().replaceAll(" ", "");
          boolean isUserPrivilege =
              ((RemoteEnv) FRContext.getCurrentEnv()).writePrivilegeMap(time, postfixOfUri);
          postfixOfUri =
              isUserPrivilege
                  ? postfixOfUri
                      + "&fr_check_url="
                      + time
                      + "&id="
                      + FRContext.getCurrentEnv().getUserID()
                  : postfixOfUri;
        }

        String urlPath = getWebBrowserPath();
        Desktop.getDesktop().browse(new URI(urlPath + postfixOfUri));
      } catch (Exception e) {
        FRContext.getLogger().error("cannot open the url Successful", e);
      }
    } else {
      try {
        String web = GeneralContext.getCurrentAppNameOfEnv();
        String url =
            "http://localhost:"
                + DesignerEnvManager.getEnvManager().getJettyServerPort()
                + "/"
                + web
                + "/"
                + ConfigManager.getProviderInstance().getServletMapping()
                + postfixOfUri;
        StartServer.browerURLWithLocalEnv(url);
      } catch (Throwable e) {
        //
      }
    }
  }
Exemplo n.º 10
0
 // open default mail client (use the mailto: protocol as the URI), eg.:
 // mailto:[email protected]?SUBJECT=Love me tender&BODY=love me sweet
 public static void mail(URI document) throws IOException {
   if (Desktop.isDesktopSupported()) Desktop.getDesktop().mail(document);
 }
Exemplo n.º 11
0
 // print a file
 public static void print(File document) throws IOException {
   if (Desktop.isDesktopSupported()) Desktop.getDesktop().print(document);
 }
Exemplo n.º 12
0
  /**
   * Try to determine whether this application is running under Windows or some other platform by
   * examining the "os.name" property.
   */
  static {
    String os = System.getProperty("os.name");
    // String version = System.getProperty("os.version"); // for Win7, reports "6.0" on JDK7, should
    // be "6.1"; for Win8, reports "6.2" as of JDK7u17

    if (SystemUtils.startsWithIgnoreCase(os, "windows 7"))
      isWin7 = true; // reports "Windows Vista" on JDK7
    else if (SystemUtils.startsWithIgnoreCase(os, "windows 8"))
      isWin7 = true; // reports "Windows 8" as of JDK7u17
    else if (SystemUtils.startsWithIgnoreCase(os, "windows vista")) isVista = true;
    else if (SystemUtils.startsWithIgnoreCase(os, "windows xp")) isWinXP = true;
    else if (SystemUtils.startsWithIgnoreCase(os, "windows 2000")) isWin2k = true;
    else if (SystemUtils.startsWithIgnoreCase(os, "windows nt")) isWinNT = true;
    else if (SystemUtils.startsWithIgnoreCase(os, "windows"))
      isWin9X = true; // win95 or win98 (what about WinME?)
    else if (SystemUtils.startsWithIgnoreCase(os, "mac")) isMac = true;
    else if (SystemUtils.startsWithIgnoreCase(os, "so")) isSolaris = true; // sunos or solaris
    else if (os.equalsIgnoreCase("linux")) isLinux = true;
    else isUnix = true; // assume UNIX, e.g. AIX, HP-UX, IRIX

    String osarch = System.getProperty("os.arch");
    String arch = (osarch != null && osarch.contains("64")) ? "_x64" /* eg. 'amd64' */ : "_x32";
    String syslib = SYSLIB + arch;

    try { // loading a native lib in a static initializer ensures that it is available before any
          // method in this class is called:
      System.loadLibrary(syslib);
      System.out.println(
          "Done loading '" + System.mapLibraryName(syslib) + "', PID=" + getProcessID());
    } catch (Error e) {
      System.err.println(
          "Native library '"
              + System.mapLibraryName(syslib)
              + "' not found in 'java.library.path': "
              + System.getProperty("java.library.path"));
      throw e; // re-throw
    }

    if (isWinPlatform()) {
      System.setProperty(
          "line.separator", "\n"); // so we won't have to mess with DOS line endings ever again
      comSpec =
          getEnv(
              "comSpec"); // use native method here since getEnvironmentVariable() needs to know
                          // comSpec
      comSpec = (comSpec != null) ? comSpec + " /c " : "";

      try (BufferedReader br =
          new BufferedReader(
              new InputStreamReader(
                  RUNTIME.exec(comSpec + "ver").getInputStream()))) { // fix for Win7,8
        for (String line = null; (line = br.readLine()) != null; ) {
          if (isVista && (line.contains("6.1" /*Win7*/) || line.contains("6.2" /*Win8*/))) {
            isVista = false;
            isWin7 = true;
          }
        }
      } catch (IOException e) {
        e.printStackTrace();
      }

      String cygdir = getEnv("cygdir"); // this is set during CygWin install to "?:/cygwin/bin"
      isCygWin = (cygdir != null && !cygdir.equals("%cygdir%"));
      cygstartPath = cygdir + "/cygstart.exe"; // path to CygWin's cygutils' "cygstart" binary

      if (getDebug() && Desktop.isDesktopSupported()) {
        Desktop desktop = Desktop.getDesktop();
        for (Desktop.Action action : Desktop.Action.values())
          System.out.println(
              "Desktop action " + action + " supported?  " + desktop.isSupported(action));
      }
    }
  }
Exemplo n.º 13
0
  public EditorPaneHTMLHelp(String htmlFile) {
    if (GlobalValues.useSystemBrowserForHelp) {
      Desktop d = GlobalValues.desktop;
      try {
        // create a temp file
        GlobalValues.forHTMLHelptempFile = new File("tempHTMLHelpSynthetic.html");
        FileWriter fw = new FileWriter(GlobalValues.forHTMLHelptempFile);

        java.util.List<String> list = readTextFromJar(htmlFile);
        Iterator<String> it = list.iterator();
        while (it.hasNext()) {
          fw.write(it.next() + "\n");
        }

        String canonicalPathOfFile = GlobalValues.forHTMLHelptempFile.getCanonicalPath();
        URL urlFile = new URL("file://" + canonicalPathOfFile);
        URI uriOfFile = urlFile.toURI();

        fw.close();

        d.browse(uriOfFile);

      } catch (Exception e) {
        e.printStackTrace();
      }

    } else {
      URL initialURL = getClass().getResource(htmlFile);

      font = GlobalValues.htmlfont;

      String title = "HTML Help";
      setTitle(title);

      final Stack<String> urlStack = new Stack<String>();
      final JEditorPane editorPane;

      editorPane = new JEditorPane(new HTMLEditorKit().getContentType(), " ");

      editorPane.setOpaque(false);
      editorPane.setBorder(null);
      editorPane.setEditable(false);

      JPanel magPanel = new JPanel();

      magnificationFactor = GlobalValues.helpMagnificationFactor;
      magFactor = new JTextField(Double.toString(magnificationFactor));

      JButton magButton = new JButton("Set Magnification: ");
      magButton.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent e) {
              magnificationFactor = Double.parseDouble(magFactor.getText());
              GlobalValues.helpMagnificationFactor = magnificationFactor;
            }
          });

      magPanel.setLayout(new GridLayout(1, 2));
      magPanel.add(magButton);
      magPanel.add(magFactor);

      final JTextField url = new JTextField(initialURL.toString());

      // set up hyperlink listener
      editorPane.setEditable(false);

      try {
        // remember URL for back button
        urlStack.push(initialURL.toString());
        // show URL in text field
        url.setText(initialURL.toString());

        // add a CSS rule to force body tags to use the default label font
        // instead of the value in javax.swing.text.html.default.csss

        String bodyRule =
            "body { font-family: "
                + font.getFamily()
                + "; "
                + "font-size: "
                + font.getSize() * GlobalValues.helpMagnificationFactor
                + "pt; }";
        ((HTMLDocument) editorPane.getDocument()).getStyleSheet().addRule(bodyRule);

        editorPane.setPage(initialURL);

        editorPane.firePropertyChange("dummyProp", true, false);

      } catch (IOException e) {
        editorPane.setText("Exception: " + e);
      }

      editorPane.addPropertyChangeListener(
          new PropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent evt) {

              String bodyRule =
                  "body { font-family: "
                      + font.getFamily()
                      + "; "
                      + "font-size: "
                      + font.getSize() * GlobalValues.helpMagnificationFactor
                      + "pt; }";
              ((HTMLDocument) editorPane.getDocument()).getStyleSheet().addRule(bodyRule);
            }
          });

      editorPane.addHyperlinkListener(
          new HyperlinkListener() {
            public void hyperlinkUpdate(HyperlinkEvent event) {
              if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                try {
                  // remember URL for back button
                  urlStack.push(event.getURL().toString());
                  // show URL in text field
                  url.setText(event.getURL().toString());
                  editorPane.setPage(event.getURL());

                  editorPane.firePropertyChange("dummyProp", true, false);

                } catch (IOException e) {
                  editorPane.setText("Exception: " + e);
                }
              }
            }
          });

      // set up checkbox for toggling edit mode
      final JCheckBox editable = new JCheckBox();
      editable.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              editorPane.setEditable(editable.isSelected());
            }
          });

      // set up load button for loading URL
      ActionListener listener =
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              try {
                // remember URL for back button
                urlStack.push(url.getText());
                editorPane.setPage(url.getText());

                editorPane.firePropertyChange("dummyProp", true, false);

              } catch (IOException e) {
                editorPane.setText("Exception: " + e);
              }
            }
          };

      JButton loadButton = new JButton("Load/Magnify");
      loadButton.addActionListener(listener);
      url.addActionListener(listener);

      // set up back button and button action

      JButton backButton = new JButton("Back");
      backButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              if (urlStack.size() <= 1) return;
              try {
                // get URL from back button
                urlStack.pop();
                // show URL in text field
                String urlString = urlStack.peek();
                url.setText(urlString);
                editorPane.setPage(urlString);

                editorPane.firePropertyChange("dummyProp", true, false);

              } catch (IOException e) {
                editorPane.setText("Exception: " + e);
              }
            }
          });

      JPanel allPanel = new JPanel(new BorderLayout());

      // put all control components in a panel

      JPanel ctrlPanel = new JPanel(new BorderLayout());
      JPanel urlPanel = new JPanel();
      urlPanel.add(new JLabel("URL"));
      urlPanel.add(url);
      JPanel buttonPanel = new JPanel();
      buttonPanel.add(loadButton);
      buttonPanel.add(backButton);
      buttonPanel.add(new JLabel("Editable"));
      buttonPanel.add(magPanel);
      buttonPanel.add(editable);
      ctrlPanel.add(buttonPanel, BorderLayout.NORTH);
      ctrlPanel.add(urlPanel, BorderLayout.CENTER);

      allPanel.add(ctrlPanel, BorderLayout.NORTH);
      allPanel.add(new JScrollPane(editorPane), BorderLayout.CENTER);

      add(allPanel);
    }
  }
Exemplo n.º 14
0
  public DesktopAppFrame() {
    setLayout(new GridBagLayout());
    final JFileChooser chooser = new JFileChooser();
    JButton fileChooserButton = new JButton("...");
    final JTextField fileField = new JTextField(20);
    fileField.setEditable(false);
    JButton openButton = new JButton("Open");
    JButton editButton = new JButton("Edit");
    JButton printButton = new JButton("Print");
    final JTextField browseField = new JTextField();
    JButton browseButton = new JButton("Browse");
    final JTextField toField = new JTextField();
    final JTextField subjectField = new JTextField();
    JButton mailButton = new JButton("Mail");

    openButton.setEnabled(false);
    editButton.setEnabled(false);
    printButton.setEnabled(false);
    browseButton.setEnabled(false);
    mailButton.setEnabled(false);

    if (Desktop.isDesktopSupported()) {
      Desktop desktop = Desktop.getDesktop();
      if (desktop.isSupported(Desktop.Action.OPEN)) openButton.setEnabled(true);
      if (desktop.isSupported(Desktop.Action.EDIT)) editButton.setEnabled(true);
      if (desktop.isSupported(Desktop.Action.PRINT)) printButton.setEnabled(true);
      if (desktop.isSupported(Desktop.Action.BROWSE)) browseButton.setEnabled(true);
      if (desktop.isSupported(Desktop.Action.MAIL)) mailButton.setEnabled(true);
    }

    fileChooserButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (chooser.showOpenDialog(DesktopAppFrame.this) == JFileChooser.APPROVE_OPTION)
              fileField.setText(chooser.getSelectedFile().getAbsolutePath());
          }
        });

    openButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              Desktop.getDesktop().open(chooser.getSelectedFile());
            } catch (IOException ex) {
              ex.printStackTrace();
            }
          }
        });

    editButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              Desktop.getDesktop().edit(chooser.getSelectedFile());
            } catch (IOException ex) {
              ex.printStackTrace();
            }
          }
        });

    printButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              Desktop.getDesktop().print(chooser.getSelectedFile());
            } catch (IOException ex) {
              ex.printStackTrace();
            }
          }
        });

    browseButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              Desktop.getDesktop().browse(new URI(browseField.getText()));
            } catch (URISyntaxException ex) {
              ex.printStackTrace();
            } catch (IOException ex) {
              ex.printStackTrace();
            }
          }
        });

    mailButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              String subject = percentEncode(subjectField.getText());
              URI uri = new URI("mailto:" + toField.getText() + "?subject=" + subject);

              System.out.println(uri);
              Desktop.getDesktop().mail(uri);
            } catch (URISyntaxException ex) {
              ex.printStackTrace();
            } catch (IOException ex) {
              ex.printStackTrace();
            }
          }
        });

    JPanel buttonPanel = new JPanel();
    ((FlowLayout) buttonPanel.getLayout()).setHgap(2);
    buttonPanel.add(openButton);
    buttonPanel.add(editButton);
    buttonPanel.add(printButton);

    add(fileChooserButton, new GBC(0, 0).setAnchor(GBC.EAST).setInsets(2));
    add(fileField, new GBC(1, 0).setFill(GBC.HORIZONTAL));
    add(buttonPanel, new GBC(2, 0).setAnchor(GBC.WEST).setInsets(0));
    add(browseField, new GBC(1, 1).setFill(GBC.HORIZONTAL));
    add(browseButton, new GBC(2, 1).setAnchor(GBC.WEST).setInsets(2));
    add(new JLabel("To:"), new GBC(0, 2).setAnchor(GBC.EAST).setInsets(5, 2, 5, 2));
    add(toField, new GBC(1, 2).setFill(GBC.HORIZONTAL));
    add(mailButton, new GBC(2, 2).setAnchor(GBC.WEST).setInsets(2));
    add(new JLabel("Subject:"), new GBC(0, 3).setAnchor(GBC.EAST).setInsets(5, 2, 5, 2));
    add(subjectField, new GBC(1, 3).setFill(GBC.HORIZONTAL));

    pack();
  }