コード例 #1
0
ファイル: ArgumentManager.java プロジェクト: tomrink/mcidasv
  /**
   * Get the {@link JComponent} that displays the given message.
   *
   * @param msg Message to display.
   * @param breakLines Whether or not {@literal "long"} lines should be broken up.
   * @return {@code JComponent} that displays {@code msg}.
   */
  private static JComponent getMessageComponent(String msg, boolean breakLines) {
    if (msg.startsWith("<html>")) {
      Component[] comps = GuiUtils.getHtmlComponent(msg, null, 500, 400);
      return (JScrollPane) comps[1];
    }

    int msgLength = msg.length();
    if (msgLength < 50) {
      return new JLabel(msg);
    }

    StringBuilder sb = new StringBuilder(msgLength * 2);
    if (breakLines) {
      for (String line : StringUtil.split(msg, "\n")) {
        line = StringUtil.breakText(line, "\n", 50);
        sb.append(line).append('\n');
      }
    } else {
      sb.append(msg).append('\n');
    }

    JTextArea textArea = new JTextArea(sb.toString());
    textArea.setFont(textArea.getFont().deriveFont(Font.BOLD));
    textArea.setBackground(new JPanel().getBackground());
    textArea.setEditable(false);
    JScrollPane textSp = GuiUtils.makeScrollPane(textArea, 400, 200);
    textSp.setPreferredSize(new Dimension(400, 200));
    return textSp;
  }
コード例 #2
0
ファイル: StormTrackChart.java プロジェクト: ethanrd/IDV
 /**
  * _more_
  *
  * @param comp _more_
  * @param width _more_
  * @param height _more_
  * @return _more_
  */
 JScrollPane makeScroller(JComponent comp, int width, int height) {
   JScrollPane scroller = GuiUtils.makeScrollPane(comp, width, height);
   scroller.setBorder(BorderFactory.createLoweredBevelBorder());
   scroller.setPreferredSize(new Dimension(width, height));
   scroller.setMinimumSize(new Dimension(width, height));
   return scroller;
 }
コード例 #3
0
  /** Export a list of user selected projections */
  public void doExport() {
    List projections = getProjections();

    Vector<String> projectionNames = new Vector<>(projections.size());
    for (int i = 0; i < projections.size(); i++) {
      ProjectionImpl projection = (ProjectionImpl) projections.get(i);
      projectionNames.add(projection.getName());
    }

    JList<String> jlist = new JList<>(projectionNames);
    JPanel contents =
        GuiUtils.topCenter(
            GuiUtils.cLabel("Please select the projections you want to export"),
            GuiUtils.makeScrollPane(jlist, 200, 400));

    if (!GuiUtils.showOkCancelDialog(null, "Export Projections", contents, null)) {
      return;
    }

    int[] indices = jlist.getSelectedIndices();
    if ((indices == null) || (indices.length == 0)) {
      return;
    }
    List<ProjectionImpl> selected = new ArrayList<>(indices.length);
    for (int i = 0; i < indices.length; i++) {
      selected.add((ProjectionImpl) projections.get(indices[i]));
    }
    String xml = (new XmlEncoder()).toXml(selected);
    String filename = FileManager.getWriteFile(FileManager.FILTER_XML, FileManager.SUFFIX_XML);
    if (filename == null) {
      return;
    }
    try {
      IOUtil.writeFile(filename, xml);
    } catch (Exception exc) {
      LogUtil.logException("Writing projection file: " + filename, exc);
    }
  }