private void initialize() {
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    getTeamNameLabel().setAlignmentX(Component.LEFT_ALIGNMENT);
    add(getTeamNameLabel());
    JPanel p = new JPanel();

    p.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setAlignmentX(Component.LEFT_ALIGNMENT);
    getTeamNameField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getTeamNameField().setMaximumSize(getTeamNameField().getPreferredSize());
    // getVersionField().setMaximumSize(getVersionField().getPreferredSize());
    p.setMaximumSize(
        new Dimension(Integer.MAX_VALUE, getTeamNameField().getPreferredSize().height));
    p.add(getTeamPackageLabel());
    p.add(getTeamNameField());
    add(p);

    JLabel label = new JLabel(" ");

    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);
    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    add(getDescriptionLabel());

    JScrollPane scrollPane =
        new JScrollPane(
            getDescriptionArea(),
            ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    scrollPane.setMaximumSize(scrollPane.getPreferredSize());
    scrollPane.setMinimumSize(new Dimension(100, scrollPane.getPreferredSize().height));
    scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(scrollPane);
    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);
    add(getAuthorLabel());
    getAuthorField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getAuthorField().setMaximumSize(getAuthorField().getPreferredSize());
    add(getAuthorField());
    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);
    add(getWebpageLabel());
    getWebpageField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getWebpageField().setMaximumSize(getWebpageField().getPreferredSize());
    add(getWebpageField());
    getWebpageHelpLabel().setAlignmentX(Component.LEFT_ALIGNMENT);
    add(getWebpageHelpLabel());
    JPanel panel = new JPanel();

    panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(panel);
    addComponentListener(eventHandler);
  }
示例#2
0
  public ComboBoxDemo2() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    String[] patternExamples = {
      "dd MMMMM yyyy",
      "dd.MM.yy",
      "MM/dd/yy",
      "yyyy.MM.dd G 'at' hh:mm:ss z",
      "EEE, MMM d, ''yy",
      "h:mm a",
      "H:mm:ss:SSS",
      "K:mm a,z",
      "yyyy.MMMMM.dd GGG hh:mm aaa"
    };

    currentPattern = patternExamples[0];

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setEditable(true);
    patternList.addActionListener(this);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // == LEFT
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything.
    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternPanel.add(patternList);

    JPanel resultPanel = new JPanel(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(patternPanel);
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();
  } // constructor
示例#3
0
  public DateTimeView(DateTime time) {
    super();
    this.time = time;
    Font f = new Font("Monospaced", Font.BOLD, 13);
    Color c = new Color(44, 68, 152);
    month = new JLabel(strMonth(time.getMonthOfYear()));
    month.setFont(f);
    month.setForeground(c);
    year = new JLabel("" + time.getYear());
    year.setFont(f);
    year.setForeground(c);
    day = new JLabel("" + time.getDayOfMonth());
    day.setFont(new Font("Calibri", Font.BOLD, 26));
    day.setForeground(new Color(126, 148, 227));
    t = new JLabel(formatTime(time.getHourOfDay(), time.getMinuteOfHour()));
    t.setFont(f);
    t.setForeground(c);

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new FlowLayout());
    topPanel.add(month);
    topPanel.add(year);

    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    topPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    this.add(topPanel);
    this.add(Box.createVerticalStrut(3));
    day.setAlignmentX(Component.CENTER_ALIGNMENT);
    this.add(day);
    t.setAlignmentX(Component.CENTER_ALIGNMENT);
    this.add(Box.createVerticalStrut(3));
    this.add(t);
    this.setBorder(BorderFactory.createRaisedBevelBorder());
  }
示例#4
0
  public void buildPopulationBox() {
    rebuilding = true;
    populationBox.removeAll();
    peopleList = new ArrayList<Object>();
    famList = new ArrayList<Family>();
    peopleList.addAll(ctxt.individualCensus);
    String plur = (peopleList.size() == 1 ? "" : "s");
    populationBox.setLayout(new BoxLayout(populationBox, BoxLayout.PAGE_AXIS));
    populationBox.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.blue), "Current Population"));
    populationBox.setAlignmentX(0.5f);
    populationBox.add(Box.createRigidArea(new Dimension(8, 0)));
    indivLabel = new JLabel("Contains " + peopleList.size() + " Individual" + plur);
    indivLabel.setAlignmentX(0.5f);
    populationBox.add(indivLabel);
    if (peopleList.size() > 0) {
      JPanel indivBtnBox = new JPanel();
      indivBtnBox.setLayout(new BoxLayout(indivBtnBox, BoxLayout.LINE_AXIS));
      Dimension sizer2 = new Dimension(350, 50);
      String[] indMenu = genIndMenu(peopleList);
      indPick = new JComboBox(indMenu);
      indPick.addActionListener(listener);
      indPick.setActionCommand("view/edit person");
      indPick.setMinimumSize(sizer2);
      indPick.setMaximumSize(sizer2);
      indPick.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createLineBorder(Color.blue), "View/Edit Person"));
      indivBtnBox.add(indPick);
      populationBox.add(indivBtnBox);
    } //  end of if-any-people-exist

    famList.addAll(ctxt.familyCensus); //  end of filtering deleted records
    plur = (famList.size() == 1 ? "y" : "ies");
    famLabel = new JLabel("Contains " + famList.size() + " Famil" + plur);
    famLabel.setAlignmentX(0.5f);
    populationBox.add(Box.createRigidArea(new Dimension(0, 4)));
    populationBox.add(famLabel);
    if (famList.size() > 0) {
      JPanel famBtnBox = new JPanel();
      famBtnBox.setLayout(new BoxLayout(famBtnBox, BoxLayout.LINE_AXIS));
      Dimension sizer2 = new Dimension(350, 50);
      String[] famMenu = genFamMenu(famList);
      famPick = new JComboBox(famMenu);
      famPick.addActionListener(listener);
      famPick.setActionCommand("view/edit family");
      famPick.setMinimumSize(sizer2);
      famPick.setMaximumSize(sizer2);
      famPick.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createLineBorder(Color.blue), "View/Edit Family"));
      famBtnBox.add(famPick);
      populationBox.add(famBtnBox);
    } //  end of if-any-families-exist
    rebuilding = false;
  } //  end of method buildPopulationBox
示例#5
0
  public FindProf() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Search your campus!");
    JLabel patternLabel2 = new JLabel("");

    patternList = new JComboBox<Object>(searchNames);
    patternList.setEditable(true);
    patternList.setMaximumRowCount(5);
    patternList.addActionListener(this);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Building Initials & Room Number:", JLabel.LEADING); // == LEFT
    result = new JLabel(" ");
    result.setHorizontalAlignment(SwingConstants.CENTER);
    result.setForeground(Color.black);
    result.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything.
    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternPanel.add(patternList);

    JPanel resultPanel = new JPanel(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(patternPanel);
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  } // constructor
  @Override
  protected JComponent createCenterPanel() {
    JPanel north = new JPanel();
    north.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, true));

    final JPanel namePanel = createNamePanel();
    namePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    north.add(namePanel);

    createCheckBoxes(north);

    myGetterPanel = createFieldPanel();
    myGetterPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    north.add(myGetterPanel);

    final JPanel root = new JPanel(new BorderLayout());
    mySignaturePanel = createSignaturePanel();
    root.add(mySignaturePanel, BorderLayout.CENTER);
    root.add(north, BorderLayout.NORTH);

    return root;
  }
  /**
   * Constructor.
   *
   * @param tileset A tileset.
   * @param oldPatternId The tile pattern id to change in this tileset.
   */
  public TilePatternIdRefactoringComponent(Tileset tileset, String oldPatternId) {
    super();

    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JPanel patternIdPanel = new JPanel();
    patternIdPanel.setLayout(new BoxLayout(patternIdPanel, BoxLayout.LINE_AXIS));
    patternIdPanel.setAlignmentX(1.0f);
    JLabel patternIdLabel = new JLabel("Tile pattern id:");
    patternIdPanel.add(patternIdLabel);
    patternIdPanel.add(Box.createHorizontalStrut(10));
    patternIdField = new JTextField(oldPatternId, 20);
    patternIdField.selectAll();
    patternIdPanel.add(patternIdField);
    patternIdPanel.setAlignmentX(0.0f);
    add(patternIdPanel);
    add(Box.createVerticalStrut(10));
    updateMapsCheckBox = new JCheckBox("Update references in existing maps");
    updateMapsCheckBox.setSelected(true);
    updateMapsCheckBox.setAlignmentX(0.0f);
    add(updateMapsCheckBox);
  }
示例#8
0
文件: Parallel.java 项目: visad/visad
  // type 'java Parallel' to run this application
  public static void main(String args[]) throws VisADException, RemoteException, IOException {

    RealType index = RealType.getRealType("index");
    RealType[] coords = new RealType[NCOORDS];
    for (int i = 0; i < NCOORDS; i++) {
      coords[i] = RealType.getRealType("coord" + i);
    }
    RealTupleType range = new RealTupleType(coords);
    FunctionType ftype = new FunctionType(index, range);
    Integer1DSet index_set = new Integer1DSet(NROWS);

    float[][] samples = new float[NCOORDS][NROWS];
    for (int i = 0; i < NCOORDS; i++) {
      for (int j = 0; j < NROWS; j++) {
        samples[i][j] = (float) Math.random();
      }
    }

    FlatField data = new FlatField(ftype, index_set);
    data.setSamples(samples, false);

    // create a 2-D Display using Java3D
    DisplayImpl display = new DisplayImplJ3D("display", new TwoDDisplayRendererJ3D());

    parallel(display, data);

    // create JFrame (i.e., a window) for display and slider
    JFrame frame = new JFrame("Parallel Coordinates VisAD Application");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    // create JPanel in JFrame
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setAlignmentY(JPanel.TOP_ALIGNMENT);
    panel.setAlignmentX(JPanel.LEFT_ALIGNMENT);
    frame.getContentPane().add(panel);

    // add display to JPanel
    panel.add(display.getComponent());

    // set size of JFrame and make it visible
    frame.setSize(500, 500);
    frame.setVisible(true);
  }
  public CategoryPanel(
      String name, List<ResourceLocator> locatorList, Set<String> loadedTrackNames) {

    expanded = true;

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setAlignmentX(LEFT_ALIGNMENT);
    // setLayout(null);

    labelBar = new JPanel();
    // labelBar.setBackground(Color.blue);
    labelBar.setLayout(new BoxLayout(labelBar, BoxLayout.X_AXIS));
    labelBar.setBorder(BorderFactory.createRaisedBevelBorder()); //  new LabelBorder(Color.black));
    labelBar.setAlignmentX(LEFT_ALIGNMENT);
    JideButton toggleButton = new JideButton(expanded ? " - " : " + ");
    toggleButton.setButtonStyle(ButtonStyle.HYPERLINK_STYLE);
    labelBar.add(toggleButton);

    labelBar.add(new JLabel(name));
    this.add(labelBar);

    listPanel = new JPanel();
    listPanel.setLayout(new GridLayout(0, 4));
    for (ResourceLocator loc : locatorList) {
      final String trackName = loc.getTrackName();
      JCheckBox cb = new JCheckBox(trackName);
      cb.setSelected(loadedTrackNames.contains(trackName));
      listPanel.add(cb);
    }
    this.add(listPanel);

    toggleButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            expanded = !expanded;
            listPanel.setVisible(expanded);
          }
        });
    labelBar.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent mouseEvent) {
            expanded = !expanded;
            listPanel.setVisible(expanded);
          }
        });
  }
示例#10
0
  /** Opens a new window with a drawing view. */
  protected void open(DrawingView newDrawingView) {
    getVersionControlStrategy().assertCompatibleVersion();
    setUndoManager(new UndoManager());
    fIconkit = new Iconkit(this);
    getContentPane().setLayout(new BorderLayout());

    // status line must be created before a tool is set
    fStatusLine = createStatusLine();
    getContentPane().add(fStatusLine, BorderLayout.SOUTH);

    // create dummy tool until the default tool is activated during toolDone()
    setTool(new NullTool(this), "");
    setView(newDrawingView);
    JComponent contents = createContents(view());
    contents.setAlignmentX(LEFT_ALIGNMENT);

    JToolBar tools = createToolPalette();
    createTools(tools);

    JPanel activePanel = new JPanel();
    activePanel.setAlignmentX(LEFT_ALIGNMENT);
    activePanel.setAlignmentY(TOP_ALIGNMENT);
    activePanel.setLayout(new BorderLayout());
    activePanel.add(tools, BorderLayout.NORTH);
    activePanel.add(contents, BorderLayout.CENTER);

    getContentPane().add(activePanel, BorderLayout.CENTER);

    JMenuBar mb = new JMenuBar();
    createMenus(mb);
    setJMenuBar(mb);

    Dimension d = defaultSize();
    if (d.width > mb.getPreferredSize().width) {
      setSize(d.width, d.height);
    } else {
      setSize(mb.getPreferredSize().width, d.height);
    }
    addListeners();
    setVisible(true);
    fStorageFormatManager = createStorageFormatManager();

    toolDone();
  }
  /**
   * The constructor.
   *
   * @param parent The parent window.
   * @param idata The installation data.
   */
  public ProcessPanel(InstallerFrame parent, InstallData idata) throws IOException {
    super(parent, idata);

    this.worker = new ProcessPanelWorker(idata, this);

    JLabel heading = new JLabel();
    Font font = heading.getFont();
    font = font.deriveFont(Font.BOLD, font.getSize() * 2.0f);
    heading.setFont(font);
    heading.setHorizontalAlignment(SwingConstants.CENTER);
    heading.setText(parent.langpack.getString("ProcessPanel.heading"));
    heading.setVerticalAlignment(SwingConstants.TOP);
    BorderLayout layout = new BorderLayout();
    layout.setHgap(2);
    layout.setVgap(2);
    setLayout(layout);
    add(heading, BorderLayout.NORTH);

    // put everything but the heading into it's own panel
    // (to center it vertically)
    JPanel subpanel = new JPanel();

    subpanel.setAlignmentX(0.5f);
    subpanel.setLayout(new BoxLayout(subpanel, BoxLayout.Y_AXIS));

    this.processLabel = new JLabel();
    this.processLabel.setAlignmentX(0.5f);
    this.processLabel.setText(" ");
    subpanel.add(this.processLabel);

    this.overallProgressBar = new JProgressBar();
    this.overallProgressBar.setAlignmentX(0.5f);
    this.overallProgressBar.setStringPainted(true);
    subpanel.add(this.overallProgressBar);

    this.outputPane = new JTextArea();
    this.outputPane.setEditable(false);
    JScrollPane outputScrollPane = new JScrollPane(this.outputPane);
    subpanel.add(outputScrollPane);

    add(subpanel, BorderLayout.CENTER);
  }
  public LabeledTextField(boolean isIndentedLabel, String label, String format) {
    super();
    super.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    tag = new JLabel(label);
    if (isIndentedLabel) {
      JPanel tag_panel = new JPanel();
      tag_panel.setLayout(new BoxLayout(tag_panel, BoxLayout.X_AXIS));
      tag_panel.add(Box.createHorizontalStrut(Const.LABEL_INDENTATION));
      tag_panel.add(tag);
      tag_panel.add(Box.createHorizontalGlue());
      tag_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
      super.add(tag_panel);
    } else {
      tag.setAlignmentX(Component.LEFT_ALIGNMENT);
      super.add(tag);
    }

    fld = new ActableTextField();
    tag.setLabelFor(fld);
    fld.setAlignmentX(Component.LEFT_ALIGNMENT);
    super.add(fld);

    // preferred_height = fld.getPreferredSize().height + this.TEXT_HEIGHT;
    if (format != null) {
      int num_col;
      fmt = (DecimalFormat) NumberFormat.getInstance();
      fmt.applyPattern(format);
      num_col = Routines.getAdjNumOfTextColumns(fld, format.length());
      fld.setColumns(num_col);
    } else fmt = null;

    /*  No self DocumentListener by default  */
    self_listener = null;

    // tag.setBorder( BorderFactory.createEtchedBorder() );
    fld.setBorder(BorderFactory.createEtchedBorder());

    if (FONT != null) {
      tag.setFont(FONT);
      fld.setFont(FONT);
    }
  }
示例#13
0
  @SuppressWarnings({"AbstractMethodCallInConstructor", "ThisEscapedInObjectConstruction"})
  protected AbstractGameDisplay() {
    doAddWindowListener(this);

    addMenuBar();

    // A pane for the entire center area: map, status.
    JPanel contentPane = new JPanel(new BorderLayout());
    doAddKeyListener(contentPane);
    setContentPane(contentPane);
    contentPane.setBorder(BorderFactory.createEtchedBorder());

    // ..add the map.
    JPanel westContainer = new JPanel(new BorderLayout());
    _mapPane = createMapPane();
    _mapPane.addMouseListener(this);
    JScrollPane mapContainer = new JScrollPane(_mapPane);
    mapContainer.setBorder(BorderFactory.createEtchedBorder());

    // ..add the status area.
    JPanel statusPaneContainer =
        new JPanel(new BorderLayout()); // hack to deal with text area sizing bug.
    statusPaneContainer.setAlignmentX(Component.LEFT_ALIGNMENT);
    _statusPane = createStatusPane();
    _statusPane.setEditable(false);
    statusPaneContainer.add(_statusPane, BorderLayout.WEST);
    westContainer.add(mapContainer, BorderLayout.CENTER);
    westContainer.add(statusPaneContainer, BorderLayout.SOUTH);

    // The side pane with all the currently relevant details (e.g. selected hex info).
    _detailsPane = createDetailsPane();
    _detailsPane.setBorder(BorderFactory.createEtchedBorder());

    // A bottom pane with a list of the game events from the previously run turn.
    _eventsPane = createEventsPane();
    _eventsPane.setBorder(BorderFactory.createEtchedBorder());

    contentPane.add(westContainer, BorderLayout.CENTER);
    contentPane.add(_detailsPane, BorderLayout.EAST);
    contentPane.add(_eventsPane, BorderLayout.SOUTH);
  }
  /**
   * The constructor.
   *
   * @param parent The parent window.
   * @param idata The installation data.
   */
  public SudoPanel(InstallerFrame parent, InstallData idata) {
    super(parent, idata);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.info")*/ "For installing administrator privileges are necessary",
            JLabel.TRAILING));

    add(Box.createRigidArea(new Dimension(0, 5)));

    add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.tip")*/ "Please note that passwords are case-sensitive",
            parent.icons.getImageIcon("tip"),
            JLabel.TRAILING));

    add(Box.createRigidArea(new Dimension(0, 5)));

    JPanel spacePanel = new JPanel();
    spacePanel.setAlignmentX(LEFT_ALIGNMENT);
    spacePanel.setAlignmentY(CENTER_ALIGNMENT);
    spacePanel.setBorder(BorderFactory.createEmptyBorder(80, 30, 0, 50));
    spacePanel.setLayout(new BorderLayout(5, 5));
    spacePanel.add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.specifyAdminPassword")*/ "Please specify your password:"),
        BorderLayout.NORTH);
    passwordField = new JPasswordField();
    passwordField.addActionListener(this);
    JPanel space2Panel = new JPanel();
    space2Panel.setLayout(new BorderLayout());
    space2Panel.add(passwordField, BorderLayout.NORTH);
    space2Panel.add(Box.createRigidArea(new Dimension(0, 5)), BorderLayout.CENTER);
    spacePanel.add(space2Panel, BorderLayout.CENTER);
    add(spacePanel);
  }
示例#15
0
  private void createProgressPanel() {
    setLayout(new BorderLayout());

    JPanel textWrapper = new JPanel(new BorderLayout());
    textWrapper.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
    textWrapper.setAlignmentX(LEFT_ALIGNMENT);
    progressTextArea = new MyTextArea();

    progressTextArea
        .getAccessibleContext()
        .setAccessibleName(resourceManager.getString("ProgressBarDemo.accessible_text_area_name"));
    progressTextArea
        .getAccessibleContext()
        .setAccessibleName(
            resourceManager.getString("ProgressBarDemo.accessible_text_area_description"));
    textWrapper.add(new JScrollPane(progressTextArea), BorderLayout.CENTER);

    add(textWrapper, BorderLayout.CENTER);

    JPanel progressPanel = new JPanel();
    add(progressPanel, BorderLayout.SOUTH);

    progressBar =
        new JProgressBar(JProgressBar.HORIZONTAL, 0, text.length()) {
          public Dimension getPreferredSize() {
            return new Dimension(300, super.getPreferredSize().height);
          }
        };
    progressBar
        .getAccessibleContext()
        .setAccessibleName(
            resourceManager.getString("ProgressBarDemo.accessible_text_loading_progress"));

    progressPanel.add(progressBar);
    progressPanel.add(createLoadButton());
    progressPanel.add(createStopButton());
  }
  protected JPanel createOptionPanel() {
    JPanel oP = new JPanel();
    oP.setLayout(new BoxLayout(oP, BoxLayout.Y_AXIS));

    preservePermBox.setEnabled(false);

    preservePermBox.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            boolean selected = preservePermBox.isSelected();
            boolean enableTargetPerm = !selected;
            permBox.setEnabled(enableTargetPerm);
            permButton.setEnabled(enableTargetPerm);
          }
        });

    permButton.setActionCommand("permissions");
    permButton.addActionListener(this);

    JPanel permPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    permPanel.add(permBox);
    permPanel.add(permButton);
    permBox.setEnabled(false);
    permButton.setEnabled(false);

    followSymLinkBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    preserveMtimeBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    preservePermBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    permPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    oP.add(followSymLinkBox);
    oP.add(preserveMtimeBox);
    oP.add(preservePermBox);
    oP.add(permPanel);

    return oP;
  }
  public void doInit() {

    final InviteResponseMessageBox _this = this;

    if (!this.message.isDealtWith()) {

      // Show the response.
      this.responseBox = new Box(BoxLayout.Y_AXIS);

      this.add(this.responseBox);

      JComponent l =
          UIUtils.createBoldSubHeader(
              String.format(
                  "%s the invitation", (this.message.isAccepted() ? "Accepted" : "Rejected")),
              (this.message.isAccepted()
                  ? Constants.ACCEPTED_ICON_NAME
                  : Constants.REJECTED_ICON_NAME));

      this.responseBox.add(l);
      this.responseBox.setBorder(UIUtils.createPadding(5, 5, 0, 5));

      if (this.message.isAccepted()) {

        if ((this.message.getEditorName() != null) || (this.message.getEditorAvatar() != null)) {

          JTextPane desc =
              UIUtils.createHelpTextPane(
                  "Additionally they provided the following name/avatar.", this.projectViewer);

          this.responseBox.add(Box.createVerticalStrut(5));

          this.responseBox.add(desc);
          desc.setBorder(null);
          desc.setSize(new Dimension(UIUtils.getPopupWidth() - 20, desc.getPreferredSize().height));

          Box editorInfo = new Box(BoxLayout.X_AXIS);
          editorInfo.setAlignmentX(Component.LEFT_ALIGNMENT);
          editorInfo.setBorder(UIUtils.createPadding(5, 5, 5, 5));

          this.responseBox.add(editorInfo);

          if (this.message.getEditorAvatar() != null) {

            JLabel avatar = new JLabel();

            avatar.setAlignmentY(Component.TOP_ALIGNMENT);
            avatar.setVerticalAlignment(SwingConstants.TOP);

            editorInfo.add(avatar);
            avatar.setOpaque(false);

            avatar.setIcon(
                new ImageIcon(UIUtils.getScaledImage(_this.message.getEditorAvatar(), 50)));

            avatar.setBorder(
                new CompoundBorder(UIUtils.createPadding(0, 0, 0, 5), UIUtils.createLineBorder()));
          }

          if (this.message.getEditorName() != null) {

            JLabel name = new JLabel(this.message.getEditorName());
            editorInfo.add(name);

            name.setBorder(null);
            name.setAlignmentY(Component.TOP_ALIGNMENT);
            name.setVerticalAlignment(JLabel.TOP);
            name.setAlignmentX(Component.LEFT_ALIGNMENT);
            name.setFont(
                name.getFont()
                    .deriveFont((float) UIUtils.getScaledFontSize(14))
                    .deriveFont(java.awt.Font.PLAIN));
          }
        }
      }

      final EditorEditor ed = this.message.getEditor();

      JButton ok = new JButton("Ok, got it");

      ok.addActionListener(
          new ActionAdapter() {

            public void actionPerformed(ActionEvent ev) {

              try {

                if (_this.message.isAccepted()) {

                  ed.setEditorStatus(EditorEditor.EditorStatus.current);

                  if (_this.message.getEditorName() != null) {

                    ed.setName(_this.message.getEditorName());
                  }

                  if (_this.message.getEditorAvatar() != null) {

                    ed.setAvatar(_this.message.getEditorAvatar());
                  }

                  EditorsEnvironment.updateEditor(ed);

                  // Is this response for an invite message or just out of the blue from a web
                  // service invite?
                  if (!EditorsEnvironment.hasSentMessageOfTypeToEditor(
                      ed, InviteMessage.MESSAGE_TYPE)) {

                    EditorsEnvironment.sendUserInformationToEditor(ed, null, null, null);
                  }

                } else {

                  ed.setEditorStatus(EditorEditor.EditorStatus.rejected);

                  EditorsEnvironment.updateEditor(ed);
                }

                _this.message.setDealtWith(true);

                EditorsEnvironment.updateMessage(_this.message);

                _this.responseBox.setVisible(false);

              } catch (Exception e) {

                Environment.logError("Unable to update editor: " + ed, e);

                UIUtils.showErrorMessage(
                    _this.projectViewer,
                    "Unable to update {editor}, please contact Quoll Writer support for assitance.");

                return;
              }
            }
          });

      JButton[] buts = new JButton[] {ok};

      JPanel bb = UIUtils.createButtonBar2(buts, Component.LEFT_ALIGNMENT);
      bb.setOpaque(false);
      bb.setAlignmentX(Component.LEFT_ALIGNMENT);
      bb.setBorder(UIUtils.createPadding(5, 0, 0, 0));

      this.responseBox.add(bb);

      return;
    }

    boolean accepted = this.message.isAccepted();
    String iconName = (accepted ? Constants.ACCEPTED_ICON_NAME : Constants.REJECTED_ICON_NAME);

    String message = "Accepted invitation to be {an editor}";

    if (!accepted) {

      message = "Rejected invitation to be {an editor}";
    }

    JComponent h = UIUtils.createBoldSubHeader(message, iconName);

    this.add(h);
  }
示例#18
0
文件: SeekAction.java 项目: hof/jin
    /** Creates the ui of this panel, laying out all the ui elements. */
    private void createUI() {
      I18n i18n = getI18n();

      final int labelPad = 4; // To align labels with checkboxes

      // Time controls
      JLabel timeLabel = i18n.createLabel("timeLabel");
      timeLabel.setLabelFor(timeField);

      JLabel incLabel = i18n.createLabel("incrementLabel");
      incLabel.setLabelFor(incField);

      JLabel secondsLabel = i18n.createLabel("secondsLabel");
      JLabel minutesLabel = i18n.createLabel("minutesLabel");

      timeField.setMaximumSize(timeField.getPreferredSize());
      incField.setMaximumSize(incField.getPreferredSize());

      JComponent timeContainer = new JPanel(new TableLayout(5, labelPad, 2));
      timeContainer.add(Box.createHorizontalStrut(0));
      timeContainer.add(timeLabel);
      timeContainer.add(Box.createHorizontalStrut(10));
      timeContainer.add(timeField);
      timeContainer.add(minutesLabel);
      timeContainer.add(Box.createHorizontalStrut(0));
      timeContainer.add(incLabel);
      timeContainer.add(Box.createHorizontalStrut(10));
      timeContainer.add(incField);
      timeContainer.add(secondsLabel);

      // Variant
      JLabel variantLabel = i18n.createLabel("variantLabel");
      variantLabel.setLabelFor(variantChoice);
      variantChoice.setMaximumSize(variantChoice.getPreferredSize());

      JComponent variantContainer = SwingUtils.createHorizontalBox();
      variantContainer.add(Box.createHorizontalStrut(labelPad));
      variantContainer.add(variantLabel);
      variantContainer.add(Box.createHorizontalStrut(10));
      variantContainer.add(variantChoice);
      variantContainer.add(Box.createHorizontalGlue());

      // Color
      JLabel colorLabel = i18n.createLabel("colorLabel");

      JComponent colorContainer = SwingUtils.createHorizontalBox();
      colorContainer.add(Box.createHorizontalStrut(labelPad));
      colorContainer.add(colorLabel);
      colorContainer.add(Box.createHorizontalStrut(15));
      colorContainer.add(autoColor);
      colorContainer.add(Box.createHorizontalStrut(10));
      colorContainer.add(whiteColor);
      colorContainer.add(Box.createHorizontalStrut(10));
      colorContainer.add(blackColor);
      colorContainer.add(Box.createHorizontalGlue());

      // Limit opponent rating
      JLabel minLabel = i18n.createLabel("minRatingLabel");
      minLabel.setLabelFor(minRatingField);
      JLabel maxLabel = i18n.createLabel("maxRatingLabel");
      maxLabel.setLabelFor(maxRatingField);
      minRatingField.setMaximumSize(minRatingField.getPreferredSize());
      maxRatingField.setMaximumSize(minRatingField.getPreferredSize());

      JComponent limitRatingBoxContainer = SwingUtils.createHorizontalBox();
      limitRatingBoxContainer.add(limitRatingBox);
      limitRatingBoxContainer.add(Box.createHorizontalGlue());

      final JComponent minMaxContainer = SwingUtils.createHorizontalBox();
      minMaxContainer.add(Box.createHorizontalStrut(40));
      minMaxContainer.add(minLabel);
      minMaxContainer.add(Box.createHorizontalStrut(10));
      minMaxContainer.add(minRatingField);
      minMaxContainer.add(Box.createHorizontalStrut(20));
      minMaxContainer.add(maxLabel);
      minMaxContainer.add(Box.createHorizontalStrut(10));
      minMaxContainer.add(maxRatingField);
      minMaxContainer.add(Box.createHorizontalGlue());

      JComponent limitRatingContainer = SwingUtils.createVerticalBox();
      limitRatingContainer.add(limitRatingBoxContainer);
      limitRatingContainer.add(Box.createVerticalStrut(3));
      limitRatingContainer.add(minMaxContainer);

      // Buttons panel
      JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
      JButton issueSeekButton = i18n.createButton("issueSeekButton");
      JButton cancelButton = i18n.createButton("cancelButton");

      setDefaultButton(issueSeekButton);
      cancelButton.setDefaultCapable(false);

      buttonsPanel.add(issueSeekButton);
      buttonsPanel.add(cancelButton);

      JButton moreLessButton = i18n.createButton("moreOptionsButton");
      moreLessButton.setDefaultCapable(false);
      moreLessButton.setActionCommand("more");
      JPanel moreLessPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
      moreLessPanel.add(moreLessButton);

      final JComponent advancedPanelHolder = new JPanel(new BorderLayout());

      // Layout the subcontainers in the main container
      setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
      timeContainer.setAlignmentX(LEFT_ALIGNMENT);
      add(timeContainer);
      add(Box.createVerticalStrut(2));
      isRatedBox.setAlignmentX(LEFT_ALIGNMENT);
      add(isRatedBox);
      advancedPanelHolder.setAlignmentX(LEFT_ALIGNMENT);
      add(advancedPanelHolder);
      add(Box.createVerticalStrut(5));
      moreLessPanel.setAlignmentX(LEFT_ALIGNMENT);
      add(moreLessPanel);

      add(Box.createVerticalStrut(10));
      buttonsPanel.setAlignmentX(LEFT_ALIGNMENT);
      add(buttonsPanel);

      // Advanced options panel
      final JComponent advancedPanel = SwingUtils.createVerticalBox();
      advancedPanel.add(Box.createVerticalStrut(4));
      variantContainer.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(variantContainer);
      advancedPanel.add(Box.createVerticalStrut(4));
      colorContainer.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(colorContainer);
      advancedPanel.add(Box.createVerticalStrut(2));
      limitRatingContainer.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(limitRatingContainer);
      advancedPanel.add(Box.createVerticalStrut(2));
      manualAcceptBox.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(manualAcceptBox);
      advancedPanel.add(Box.createVerticalStrut(2));
      useFormulaBox.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(useFormulaBox);

      AWTUtilities.setContainerEnabled(minMaxContainer, limitRatingBox.isSelected());
      limitRatingBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent evt) {
              AWTUtilities.setContainerEnabled(minMaxContainer, limitRatingBox.isSelected());
            }
          });

      moreLessButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              if (evt.getActionCommand().equals("more")) {
                JButton moreLessButton = (JButton) evt.getSource();
                moreLessButton.setText(getI18n().getString("lessOptionsButton.text"));
                moreLessButton.setActionCommand("less");
                advancedPanelHolder.add(advancedPanel, BorderLayout.CENTER);
                SeekPanel.this.resizeContainerToFit();
              } else {
                JButton moreLessButton = (JButton) evt.getSource();
                moreLessButton.setText(getI18n().getString("moreOptionsButton.text"));
                moreLessButton.setActionCommand("more");
                advancedPanelHolder.remove(advancedPanel);
                SeekPanel.this.resizeContainerToFit();
              }
            }
          });

      cancelButton.addActionListener(new ClosingListener(null));
      issueSeekButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              int time, inc;

              try {
                time = Integer.parseInt(timeField.getText());
              } catch (NumberFormatException e) {
                getI18n().error("timeError");
                return;
              }

              try {
                inc = Integer.parseInt(incField.getText());
              } catch (NumberFormatException e) {
                getI18n().error("incError");
                return;
              }

              boolean isRated = isRatedBox.isSelected();

              WildVariant variant = (WildVariant) variantChoice.getSelectedItem();

              Player color =
                  autoColor.isSelected()
                      ? null
                      : whiteColor.isSelected() ? Player.WHITE_PLAYER : Player.BLACK_PLAYER;

              int minRating, maxRating;
              if (limitRatingBox.isSelected()) {
                try {
                  minRating = Integer.parseInt(minRatingField.getText());
                } catch (NumberFormatException e) {
                  getI18n().error("minRatingError");
                  return;
                }
                try {
                  maxRating = Integer.parseInt(maxRatingField.getText());
                } catch (NumberFormatException e) {
                  getI18n().error("maxRatingError");
                  return;
                }
              } else {
                minRating = Integer.MIN_VALUE;
                maxRating = Integer.MAX_VALUE;
              }

              boolean manualAccept = manualAcceptBox.isSelected();
              boolean useFormula = useFormulaBox.isSelected();

              close(
                  new UserSeek(
                      time,
                      inc,
                      isRated,
                      variant,
                      color,
                      minRating,
                      maxRating,
                      manualAccept,
                      useFormula));
            }
          });
    }
示例#19
0
  /**
   * run 'java FlowTest middle_latitude' to test with (lat, lon) run 'java FlowTest middle_latitude
   * x' to test with (lon, lat) adjust middle_latitude for south or north
   */
  public static void main(String args[]) throws VisADException, RemoteException {
    double mid_lat = -10.0;
    if (args.length > 0) {
      try {
        mid_lat = Double.valueOf(args[0]).doubleValue();
      } catch (NumberFormatException e) {
      }
    }
    boolean swap = (args.length > 1);
    RealType lat = RealType.Latitude;
    RealType lon = RealType.Longitude;
    RealType[] types;
    if (swap) {
      types = new RealType[] {lon, lat};
    } else {
      types = new RealType[] {lat, lon};
    }
    RealTupleType earth_location = new RealTupleType(types);
    System.out.println("earth_location = " + earth_location + " mid_lat = " + mid_lat);

    RealType flowx = RealType.getRealType("flowx", CommonUnit.meterPerSecond);
    RealType flowy = RealType.getRealType("flowy", CommonUnit.meterPerSecond);
    RealType red = RealType.getRealType("red");
    RealType green = RealType.getRealType("green");
    EarthVectorType flowxy = new EarthVectorType(flowx, flowy);
    TupleType range = null;

    range = new TupleType(new MathType[] {flowxy, red, green});
    FunctionType flow_field = new FunctionType(earth_location, range);

    DisplayImpl display = new DisplayImplJ3D("display1", new TwoDDisplayRendererJ3D());
    ScalarMap xmap = new ScalarMap(lon, Display.XAxis);
    display.addMap(xmap);
    ScalarMap ymap = new ScalarMap(lat, Display.YAxis);
    display.addMap(ymap);
    ScalarMap flowx_map = new ScalarMap(flowx, Display.Flow1X);
    display.addMap(flowx_map);
    flowx_map.setRange(-10.0, 10.0);
    ScalarMap flowy_map = new ScalarMap(flowy, Display.Flow1Y);
    display.addMap(flowy_map);
    flowy_map.setRange(-10.0, 10.0);
    FlowControl flow_control = (FlowControl) flowy_map.getControl();
    flow_control.setFlowScale(0.05f);
    display.addMap(new ScalarMap(red, Display.Red));
    display.addMap(new ScalarMap(green, Display.Green));
    display.addMap(new ConstantMap(1.0, Display.Blue));

    double lonlow = -10.0;
    double lonhi = 10.0;
    double latlow = mid_lat - 10.0;
    double lathi = mid_lat + 10.0;
    Linear2DSet set;
    if (swap) {
      set = new Linear2DSet(earth_location, lonlow, lonhi, N, latlow, lathi, N);
    } else {
      set = new Linear2DSet(earth_location, latlow, lathi, N, lonlow, lonhi, N);
    }
    double[][] values = new double[4][N * N];
    int m = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        int k = i;
        int l = j;
        if (swap) {
          k = j;
          l = i;
        }
        double u = (N - 1.0) / 2.0 - l;
        double v = k - (N - 1.0) / 2.0;
        // double u = 2.0 * k / (N - 1.0) - 1.0;
        // double v = 2.0 * l / (N - 1.0);
        double fx = 6.0 * u;
        double fy = 6.0 * v;
        values[0][m] = fx;
        values[1][m] = fy;
        values[2][m] = u;
        values[3][m] = v;
        m++;
      }
    }
    FlatField field = new FlatField(flow_field, set);
    field.setSamples(values);
    DataReferenceImpl ref = new DataReferenceImpl("ref");
    ref.setData(field);
    display.addReference(ref);

    // create JFrame (i.e., a window) for display and slider
    JFrame frame = new JFrame("test FlowTest");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    // create JPanel in JFrame
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setAlignmentY(JPanel.TOP_ALIGNMENT);
    panel.setAlignmentX(JPanel.LEFT_ALIGNMENT);
    frame.getContentPane().add(panel);

    // add display to JPanel
    panel.add(display.getComponent());

    // set size of JFrame and make it visible
    frame.setSize(500, 500);
    frame.setVisible(true);
  }
  private void layoutComponentsOfProxySocksPanel() {
    proxySocksPanel.setLayout(new GridBagLayout());
    proxySocksPanel.setBackground(Color.WHITE);

    GridBagConstraints gc = new GridBagConstraints();

    ///////////////// First row ////////////////////////////////////////////
    gc.gridy = 0;

    gc.weightx = 1;
    gc.weighty = 0.1;

    gc.gridx = 0;
    gc.fill = GridBagConstraints.NONE;
    gc.anchor = GridBagConstraints.LINE_END;
    gc.insets = new Insets(0, 0, 0, 5);
    proxySocksPanel.add(noProxyLabel, gc);

    gc.gridx = 1;
    gc.insets = new Insets(0, 0, 0, 0);
    gc.anchor = GridBagConstraints.LINE_START;
    proxySocksPanel.add(noProxyRadioButton, gc);
    ///////////////// Next row ////////////////////////////////////////////
    gc.gridy++;

    gc.gridx = 0;
    gc.fill = GridBagConstraints.NONE;
    gc.anchor = GridBagConstraints.LINE_END;
    gc.insets = new Insets(0, 0, 0, 5);
    proxySocksPanel.add(systemProxyLabel, gc);

    gc.gridx = 1;
    gc.insets = new Insets(0, 0, 0, 0);
    gc.anchor = GridBagConstraints.LINE_START;
    proxySocksPanel.add(systemProxyRadioButton, gc);

    ///////////////// Next row ////////////////////////////////////////////
    gc.gridy++;

    gc.gridx = 0;
    gc.fill = GridBagConstraints.NONE;
    gc.anchor = GridBagConstraints.LINE_END;
    gc.insets = new Insets(0, 0, 0, 5);
    proxySocksPanel.add(manualProxyLabel, gc);

    gc.gridx = 1;
    gc.insets = new Insets(0, 0, 0, 0);
    gc.anchor = GridBagConstraints.LINE_START;
    proxySocksPanel.add(manualProxyRadioButton, gc);

    ///////////////// Next row ////////////////////////////////////////////
    //        gc.gridy++;
    //
    //        gc.gridx = 0;
    //        gc.gridwidth = 2;
    //        gc.fill = GridBagConstraints.NONE;
    //        //     gc.anchor = GridBagConstraints.LINE_END;
    //        gc.insets = new Insets(0, 0, 0, 5);
    //        proxyPanel.add(manualProxyPanel, gc);

    //        gc.gridx = 1;
    //        gc.insets = new Insets(0, 0, 0, 0);
    //        gc.anchor = GridBagConstraints.LINE_START;
    //        proxyPanel.add(manualProxyRadioButton, gc);

    proxySocksPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(proxySocksPanel);
  }
示例#21
0
  public ContextEditor(Context cntxt) {
    super("Edit User Context: " + localFileName(cntxt));
    ctxt = cntxt;
    windowNum = ctxt.languageName + " Context Editor";
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    listener = new CEListener(this);

    JPanel nameBox = new JPanel();
    nameBox.setLayout(new BoxLayout(nameBox, BoxLayout.LINE_AXIS));
    name = new JTextField(ctxt.languageName, 28);
    name.setMaximumSize(new Dimension(225, 22));
    name.addFocusListener(
        new java.awt.event.FocusAdapter() {

          public void focusLost(java.awt.event.FocusEvent evt) {
            nameFocusLost(evt);
          }
        });

    JLabel nameLabel = new JLabel("Language Name: ");
    nameBox.add(nameLabel);
    nameBox.add(name);

    JPanel folderBox = new JPanel();
    folderBox.setLayout(new BoxLayout(folderBox, BoxLayout.LINE_AXIS));
    folder = new JTextField(ctxt.editDirectory);
    folder.setMaximumSize(new Dimension(225, 22));
    //        folder.addActionListener(listener);
    //        folder.setActionCommand("folder edit");
    folder.addFocusListener(
        new java.awt.event.FocusAdapter() {

          public void focusLost(java.awt.event.FocusEvent evt) {
            folderFocusLost(evt);
          }
        });

    JLabel folderLabel = new JLabel("SILK file folder: ");
    folderBox.add(folderLabel);
    folderBox.add(folder);

    JPanel nameFolderBox = new JPanel();
    nameFolderBox.setLayout(new BoxLayout(nameFolderBox, BoxLayout.PAGE_AXIS));
    nameBox.setAlignmentX(0.5f);
    nameFolderBox.add(nameBox);
    nameFolderBox.add(Box.createRigidArea(new Dimension(0, 4)));
    nameFolderBox.add(folderBox);
    nameFolderBox.setAlignmentX(0.5f);

    buildPopulationBox();

    JPanel btnBoxUDPs = new JPanel(), subBoxUDP = new JPanel();
    btnBoxUDPs.setLayout(new BoxLayout(btnBoxUDPs, BoxLayout.PAGE_AXIS));
    subBoxUDP.setLayout(new BoxLayout(subBoxUDP, BoxLayout.LINE_AXIS));
    int numUDPs = 0;
    if (ctxt.userDefinedProperties != null) {
      numUDPs = ctxt.userDefinedProperties.size();
    }
    String plur = "ies";
    if (numUDPs == 1) {
      plur = "y";
    }
    JLabel udpLabel = new JLabel("Has " + numUDPs + " User-Defined Propert" + plur);
    subBoxUDP.add(udpLabel);
    JButton addUDP = new JButton("Add UDP");
    addUDP.setActionCommand("add UDP");
    addUDP.addActionListener(listener);
    subBoxUDP.add(addUDP);
    btnBoxUDPs.add(subBoxUDP);
    if (numUDPs > 0) {
      Dimension sizer = new Dimension(250, 50);
      String[] udpMenu = genUDPMenu();
      UDPick = new JComboBox(udpMenu);
      UDPick.addActionListener(listener);
      UDPick.setActionCommand("view/edit UDP");
      UDPick.setMinimumSize(sizer);
      UDPick.setMaximumSize(sizer);
      UDPick.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createLineBorder(Color.blue), "View/Edit UDPs"));
      btnBoxUDPs.add(UDPick);
    } //  end of if-any-UDPs-exist

    JPanel domThs = new JPanel();
    domThs.setLayout(new BoxLayout(domThs, BoxLayout.PAGE_AXIS));
    domThs.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.blue), "Kinship System Domain Theories"));
    domThs.setAlignmentX(0.5f);
    JPanel dtRefBtnBox = new JPanel();
    dtRefBtnBox.setLayout(new BoxLayout(dtRefBtnBox, BoxLayout.LINE_AXIS));
    dtRefBtnBox.setAlignmentX(0.0f);
    JLabel dtRefLabel = new JLabel("Terms of Reference ");
    dtRefBtnBox.add(dtRefLabel);
    if (ctxt.domTheoryRefExists()) {
      JButton dtRefEdit = new JButton("Edit Theory");
      dtRefEdit.setActionCommand("edit dtRef");
      dtRefEdit.addActionListener(listener);
      dtRefBtnBox.add(dtRefEdit);
      //            JButton dtRefDelete = new JButton("Delete Theory");
      //            dtRefDelete.setActionCommand("dtRef delete");
      //            dtRefDelete.addActionListener(listener);
      //            dtRefBtnBox.add(dtRefDelete);
    } //  end of if-dt-exists
    else { //  if does not exist
      JLabel dtRefNone = new JLabel("< None >");
      dtRefBtnBox.add(dtRefNone);
      //            JButton dtRefAdd = new JButton("Add Theory");
      //            dtRefAdd.setActionCommand("dtRef add");
      //            dtRefAdd.addActionListener(listener);
      //            dtRefBtnBox.add(dtRefAdd);
    } //  end of does-not-exist
    domThs.add(dtRefBtnBox);

    JPanel dtAddrBtnBox = new JPanel();
    dtAddrBtnBox.setLayout(new BoxLayout(dtAddrBtnBox, BoxLayout.LINE_AXIS));
    dtAddrBtnBox.setAlignmentX(0.0f);
    JLabel dtAddrLabel = new JLabel("Terms of Address ");
    dtAddrBtnBox.add(dtAddrLabel);
    if (ctxt.domTheoryAdrExists()) {
      JButton dtAddrEdit = new JButton("Edit Theory");
      dtAddrEdit.setActionCommand("edit dtAddr");
      dtAddrEdit.addActionListener(listener);
      dtAddrBtnBox.add(dtAddrEdit);
      //            JButton dtAddrViewList = new JButton("Delete Theory");
      //            dtAddrViewList.setActionCommand("dtAddr delete");
      //            dtAddrViewList.addActionListener(listener);
      //            dtAddrBtnBox.add(dtAddrViewList);
    } //  end of if-dt-exists
    else { //  if does not exist
      JLabel dtAddrNone = new JLabel("< None >");
      dtAddrBtnBox.add(dtAddrNone);
      //            JButton dtAddrAdd = new JButton("Add Theory");
      //            dtAddrAdd.setActionCommand("dtAddr add");
      //            dtAddrAdd.addActionListener(listener);
      //            dtAddrBtnBox.add(dtAddrAdd);
    } //  end of does-not-exist
    domThs.add(dtAddrBtnBox);
    // End of the left hand portion
    // Right hand portion follows. it is narrower.

    JPanel polyBox = new JPanel();
    polyBox.setLayout(new BoxLayout(polyBox, BoxLayout.PAGE_AXIS));
    polyBox.setAlignmentX(0.5f);
    JLabel polyLabelA = new JLabel("Polygamy");
    JLabel polyLabelB = new JLabel("Permitted?");
    JRadioButton yesPoly = new JRadioButton("Yes");
    yesPoly.setActionCommand("polygamy yes");
    yesPoly.addActionListener(listener);
    JRadioButton noPoly = new JRadioButton("No");
    noPoly.setActionCommand("polygamy no");
    noPoly.addActionListener(listener);
    if (cntxt.polygamyPermit) {
      yesPoly.setSelected(true);
    } else {
      noPoly.setSelected(true);
    }
    ButtonGroup polyBtns = new ButtonGroup();
    polyBtns.add(yesPoly);
    polyBtns.add(noPoly);
    polyBox.add(polyLabelA);
    polyBox.add(polyLabelB);
    polyBox.add(yesPoly);
    polyBox.add(noPoly);

    JPanel matrixBox = new JPanel();
    matrixBox.setLayout(new BoxLayout(matrixBox, BoxLayout.PAGE_AXIS));
    matrixBox.setAlignmentX(0.5f);
    JLabel matrixLabelA = new JLabel("Kin Term Matrix");
    JLabel matrixLabelC = new JLabel(ctxt.indSerNumGen + " rows");
    JLabel matrixLabelD = new JLabel(ctxt.ktm.numberOfKinTerms() + " terms");
    matrixLabelA.setAlignmentX(0.5f);
    matrixLabelC.setAlignmentX(0.5f);
    matrixLabelD.setAlignmentX(0.5f);
    JButton matrixEditBtn = new JButton("Edit Matrix");
    matrixEditBtn.setEnabled(false);
    matrixEditBtn.setActionCommand("edit matrix");
    matrixEditBtn.addActionListener(listener);
    matrixEditBtn.setAlignmentX(0.5f);
    matrixBox.add(matrixLabelA);
    matrixBox.add(matrixLabelC);
    matrixBox.add(matrixLabelD);
    matrixBox.add(matrixEditBtn);

    JPanel distinctBox = new JPanel();
    distinctBox.setLayout(new BoxLayout(distinctBox, BoxLayout.PAGE_AXIS));
    distinctBox.setAlignmentX(0.5f);
    JLabel distinctLabelA = new JLabel("Distinct Terms");
    JLabel distinctLabelB = new JLabel("of Address");
    distinctLabelA.setAlignmentX(0.5f);
    distinctLabelB.setAlignmentX(0.5f);
    JRadioButton yesDistinct = new JRadioButton("Yes");
    yesDistinct.setActionCommand("distinct yes");
    yesDistinct.addActionListener(listener);
    JRadioButton noDistinct = new JRadioButton("No");
    noDistinct.setActionCommand("distinct no");
    noDistinct.addActionListener(listener);
    yesDistinct.setAlignmentX(0.5f);
    noDistinct.setAlignmentX(0.5f);
    if (ctxt.distinctAdrTerms) {
      yesDistinct.setSelected(true);
    } else {
      noDistinct.setSelected(true);
    }
    ButtonGroup distinctBtns = new ButtonGroup();
    distinctBtns.add(yesDistinct);
    distinctBtns.add(noDistinct);
    distinctBox.add(distinctLabelA);
    distinctBox.add(distinctLabelB);
    distinctBox.add(yesDistinct);
    distinctBox.add(noDistinct);

    /*
     * NOTE: It should be possible to put all these elements directly into
     * the ContentPane. But that doesn't work; the layout is truly ugly and
     * stuff gets stacked on top of other stuff. What works is to put
     * everything into a JPanel with BoxLayout. Then put the JPanel into
     * ContentPane.
     */
    JPanel leftCol = new JPanel();
    leftCol.setLayout(new BoxLayout(leftCol, BoxLayout.PAGE_AXIS));
    leftCol.add(nameFolderBox);
    leftCol.add(Box.createRigidArea(new Dimension(0, 4)));
    leftCol.add(populationBox);
    leftCol.add(Box.createRigidArea(new Dimension(0, 8)));
    leftCol.add(btnBoxUDPs);
    leftCol.add(Box.createRigidArea(new Dimension(0, 8)));
    leftCol.add(domThs);
    leftCol.add(new JLabel(" "));

    JPanel rightCol = new JPanel();
    rightCol.setLayout(new BoxLayout(rightCol, BoxLayout.PAGE_AXIS));
    rightCol.setBorder(
        BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue), "Options"));
    rightCol.add(Box.createRigidArea(new Dimension(0, 20)));
    rightCol.add(polyBox);
    rightCol.add(Box.createRigidArea(new Dimension(0, 20)));
    rightCol.add(matrixBox);
    int high = (numUDPs > 0 ? 120 : 20);
    rightCol.add(Box.createRigidArea(new Dimension(0, high)));
    rightCol.add(distinctBox);

    JPanel commentBox = new JPanel();
    commentBox.setLayout(new BoxLayout(commentBox, BoxLayout.PAGE_AXIS));
    commentBox.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.blue), "Notes on this culture:"));
    JScrollPane commentsPane = new JScrollPane();
    comments = new JTextArea();
    comments.setColumns(20);
    comments.setEditable(true);
    comments.setRows(3);
    comments.setText(PersonPanel.restoreLineBreaks(ctxt.comments));
    comments.getDocument().addDocumentListener(new CommentListener());
    commentsPane.setViewportView(comments);
    commentBox.add(commentsPane);

    JPanel guts = new JPanel(); // Holds the guts of this window
    guts.setLayout(new BoxLayout(guts, BoxLayout.LINE_AXIS));
    guts.add(leftCol);
    guts.add(Box.createRigidArea(new Dimension(10, 4)));
    guts.add(rightCol);

    JPanel wholeThing = new JPanel();
    wholeThing.setLayout(new BoxLayout(wholeThing, BoxLayout.PAGE_AXIS));
    wholeThing.add(Box.createRigidArea(new Dimension(0, 4)));
    wholeThing.add(guts);
    wholeThing.add(Box.createRigidArea(new Dimension(0, 8)));
    wholeThing.add(commentBox);
    wholeThing.add(Box.createRigidArea(new Dimension(0, 4)));

    getContentPane().add(wholeThing);

    addInternalFrameListener(this);
    setSize(600, 620);
    setVisible(true);
  } //  end of ContextEditor constructor
  private void initialize() {
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JLabel label =
        new JLabel(
            "It is up to you whether or not to include the source when you distribute your robot.");

    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    label =
        new JLabel(
            "If you include the source, other people will be able to look at your code and learn from it.");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    getIncludeSource().setAlignmentX(Component.LEFT_ALIGNMENT);
    add(getIncludeSource());

    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    add(getVersionLabel());

    JPanel p = new JPanel();

    p.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setAlignmentX(Component.LEFT_ALIGNMENT);
    getVersionField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getVersionField().setMaximumSize(getVersionField().getPreferredSize());
    p.setMaximumSize(new Dimension(Integer.MAX_VALUE, getVersionField().getPreferredSize().height));
    p.add(getVersionField());
    p.add(getVersionHelpLabel());
    add(p);

    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    add(getDescriptionLabel());

    JScrollPane scrollPane =
        new JScrollPane(
            getDescriptionArea(),
            ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    scrollPane.setMaximumSize(scrollPane.getPreferredSize());
    scrollPane.setMinimumSize(new Dimension(100, scrollPane.getPreferredSize().height));
    scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(scrollPane);

    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    add(getAuthorLabel());

    getAuthorField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getAuthorField().setMaximumSize(getAuthorField().getPreferredSize());
    add(getAuthorField());

    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    add(getWebpageLabel());

    getWebpageField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getWebpageField().setMaximumSize(getWebpageField().getPreferredSize());
    add(getWebpageField());

    getWebpageHelpLabel().setAlignmentX(Component.LEFT_ALIGNMENT);
    add(getWebpageHelpLabel());

    JPanel panel = new JPanel();

    panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(panel);
    addComponentListener(eventHandler);
  }
  public Displayer(Player x, int num) {
    super("Player " + num + " Information");
    playernum = num;
    this.x = x;

    setSize(400, 400);
    setResizable(false);
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    moneyLabel = new JLabel("Money Owned:" + x.getMoney() + "");
    jcards = new JLabel("Get out of Jail Cards Owned: " + x.getJailCards());

    propertydisplay = new JComboBox(getPropertyName());
    icon = new ImageIcon(Game.wdr + "images/tokens/monopoly_token_" + x.getToken() + ".png");
    mortgage = new JButton("Manage Mortgage");
    mortgage.addActionListener(this);
    mortgage.setActionCommand("mortgage");

    buyHouse = new JButton("Buy a House");
    buyHouse.addActionListener(this);
    buyHouse.setActionCommand("buyHouse");

    sellHouse = new JButton("Sell a House");
    sellHouse.addActionListener(this);
    sellHouse.setActionCommand("sellHouse");

    sellProperty = new JButton("Sell this Property");
    sellProperty.addActionListener(this);
    sellProperty.setActionCommand("sellProperty");

    Image img = icon.getImage();
    Image newimg = img.getScaledInstance(80, 80, java.awt.Image.SCALE_SMOOTH);
    ImageIcon newicon = new ImageIcon(newimg);
    timg = new JLabel(newicon);

    propertydisplay.addItemListener(this);

    p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
    p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
    p2.setAlignmentX(Component.RIGHT_ALIGNMENT);
    p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
    p3.setAlignmentX(Component.LEFT_ALIGNMENT);

    p2.add(timg);
    p3.add(moneyLabel);
    p3.add(jcards);

    p1.add(p2);
    p1.add(p3);

    p4.setLayout(new BoxLayout(p4, BoxLayout.Y_AXIS));
    p4.setAlignmentY(Component.CENTER_ALIGNMENT);

    p4.add(propertydisplay);
    p4.add(pr1);
    p4.add(pr2);
    p4.add(pr3);
    p4.add(pr4);
    p4.add(pr5);

    p5.setLayout(new BoxLayout(p5, BoxLayout.X_AXIS));

    p5.add(mortgage);
    p5.add(buyHouse);
    p5.add(sellHouse);

    p.add(p1);
    p.add(p4);
    p.add(p5);

    add(p);
    setVisible(true);

    timer.setActionCommand("timing");
    timer.setInitialDelay(500);
    timer.start();
  }
  /** @param owner */
  WordArtCustomDialog(Frame owner) {
    super(owner, "Add Text", true);
    this.setResizable(false);
    this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String[] fontList = ge.getAvailableFontFamilyNames();
    fontCombo = new JComboBox<String>(fontList);

    italic = new JCheckBox("Italic");
    bold = new JCheckBox("Bold");

    sizeCombo = new JComboBox<String>(SZ);
    ((JLabel) sizeCombo.getRenderer()).setHorizontalAlignment(SwingConstants.CENTER);
    sizeCombo.setSelectedIndex(4);
    sizeCombo.setPreferredSize(new Dimension(45, 21)); // tweek size

    example = new JTextField(" Example ");
    example.setHorizontalAlignment(SwingConstants.CENTER);
    example.setFont(new Font("sanserif", Font.PLAIN, 28));
    example.setEditable(false);

    ok = new JButton("Apply");
    cancel = new JButton("Cancel");
    ok.setPreferredSize(cancel.getPreferredSize());

    foreground = new JButton("Color");

    fontCombo.addActionListener(this);
    italic.addItemListener(this);
    bold.addItemListener(this);
    sizeCombo.addActionListener(this);
    ok.addActionListener(this);
    cancel.addActionListener(this);
    foreground.addActionListener(this);
    // custom dialog set up
    JPanel p0 = new JPanel();
    p0.add(fontCombo);
    p0.setBorder(new TitledBorder(new EtchedBorder(), "Font family"));

    JPanel p1a = new JPanel();
    p1a.add(italic);
    p1a.add(bold);
    p1a.setBorder(new TitledBorder(new EtchedBorder(), "Font style"));

    JPanel p1b = new JPanel();
    p1b.add(sizeCombo);
    p1b.add(new JLabel("pt."));
    p1b.setBorder(new TitledBorder(new EtchedBorder(), "Font size"));

    JPanel p1 = new JPanel();
    p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
    p1.add(p1a);
    p1.add(p1b);
    p1.setAlignmentX(Component.CENTER_ALIGNMENT);

    JPanel p2 = new JPanel(); // use FlowLayout
    p2.add(foreground);
    p2.setBorder(new TitledBorder(new EtchedBorder(), "Message color"));
    p2.setAlignmentX(Component.CENTER_ALIGNMENT);

    JPanel p3 = new JPanel();
    p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
    p3.add(example);
    p3.setPreferredSize(new Dimension(250, 60));
    p3.setMaximumSize(new Dimension(250, 60));
    p3.setAlignmentX(Component.CENTER_ALIGNMENT);

    JPanel p4 = new JPanel();
    p4.add(ok);
    p4.add(cancel);
    p4.setAlignmentX(Component.CENTER_ALIGNMENT);

    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(p0);
    p.add(Box.createRigidArea(new Dimension(0, 10)));
    p.add(p1);
    p.add(Box.createRigidArea(new Dimension(0, 10)));
    p.add(p2);
    p.add(Box.createRigidArea(new Dimension(0, 10)));
    p.add(p3);
    p.add(Box.createRigidArea(new Dimension(0, 10)));
    p.add(p4);
    p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    // tweek sizes of panels to make the dialog look nice

    Dimension d1 = p3.getPreferredSize();
    Dimension d2 = p1.getPreferredSize();
    p1.setPreferredSize(new Dimension(d1.width, d2.height));
    p1.setMaximumSize(new Dimension(d1.width, d2.height));
    d2 = p2.getPreferredSize();
    p2.setPreferredSize(new Dimension(d1.width, d2.height));
    p2.setMaximumSize(new Dimension(d1.width, d2.height));

    this.setContentPane(p);
    this.pack();
  }
  protected boolean exportApplicationPrompt() throws IOException, SketchException {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(Box.createVerticalStrut(6));

    // Box panel = Box.createVerticalBox();

    // Box labelBox = Box.createHorizontalBox();
    //    String msg = "<html>Click Export to Application to create a standalone, " +
    //      "double-clickable application for the selected plaforms.";

    //    String msg = "Export to Application creates a standalone, \n" +
    //      "double-clickable application for the selected plaforms.";
    String line1 = "Export to Application creates double-clickable,";
    String line2 = "standalone applications for the selected plaforms.";
    JLabel label1 = new JLabel(line1, SwingConstants.CENTER);
    JLabel label2 = new JLabel(line2, SwingConstants.CENTER);
    label1.setAlignmentX(Component.LEFT_ALIGNMENT);
    label2.setAlignmentX(Component.LEFT_ALIGNMENT);
    //    label1.setAlignmentX();
    //    label2.setAlignmentX(0);
    panel.add(label1);
    panel.add(label2);
    int wide = label2.getPreferredSize().width;
    panel.add(Box.createVerticalStrut(12));

    final JCheckBox windowsButton = new JCheckBox("Windows");
    // windowsButton.setMnemonic(KeyEvent.VK_W);
    windowsButton.setSelected(Preferences.getBoolean("export.application.platform.windows"));
    windowsButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean(
                "export.application.platform.windows", windowsButton.isSelected());
          }
        });

    final JCheckBox macosxButton = new JCheckBox("Mac OS X");
    // macosxButton.setMnemonic(KeyEvent.VK_M);
    macosxButton.setSelected(Preferences.getBoolean("export.application.platform.macosx"));
    macosxButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.platform.macosx", macosxButton.isSelected());
          }
        });

    final JCheckBox linuxButton = new JCheckBox("Linux");
    // linuxButton.setMnemonic(KeyEvent.VK_L);
    linuxButton.setSelected(Preferences.getBoolean("export.application.platform.linux"));
    linuxButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.platform.linux", linuxButton.isSelected());
          }
        });

    JPanel platformPanel = new JPanel();
    // platformPanel.setLayout(new BoxLayout(platformPanel, BoxLayout.X_AXIS));
    platformPanel.add(windowsButton);
    platformPanel.add(Box.createHorizontalStrut(6));
    platformPanel.add(macosxButton);
    platformPanel.add(Box.createHorizontalStrut(6));
    platformPanel.add(linuxButton);
    platformPanel.setBorder(new TitledBorder("Platforms"));
    // Dimension goodIdea = new Dimension(wide, platformPanel.getPreferredSize().height);
    // platformPanel.setMaximumSize(goodIdea);
    wide = Math.max(wide, platformPanel.getPreferredSize().width);
    platformPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel.add(platformPanel);

    //  Box indentPanel = Box.createHorizontalBox();
    //  indentPanel.add(Box.createHorizontalStrut(new JCheckBox().getPreferredSize().width));
    final JCheckBox showStopButton = new JCheckBox("Show a Stop button");
    // showStopButton.setMnemonic(KeyEvent.VK_S);
    showStopButton.setSelected(Preferences.getBoolean("export.application.stop"));
    showStopButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.stop", showStopButton.isSelected());
          }
        });
    showStopButton.setEnabled(Preferences.getBoolean("export.application.fullscreen"));
    showStopButton.setBorder(new EmptyBorder(3, 13, 6, 13));
    //  indentPanel.add(showStopButton);
    //  indentPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    final JCheckBox fullScreenButton = new JCheckBox("Full Screen (Present mode)");
    // fullscreenButton.setMnemonic(KeyEvent.VK_F);
    fullScreenButton.setSelected(Preferences.getBoolean("export.application.fullscreen"));
    fullScreenButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            boolean sal = fullScreenButton.isSelected();
            Preferences.setBoolean("export.application.fullscreen", sal);
            showStopButton.setEnabled(sal);
          }
        });
    fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13));

    JPanel optionPanel = new JPanel();
    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
    optionPanel.add(fullScreenButton);
    optionPanel.add(showStopButton);
    //    optionPanel.add(indentPanel);
    optionPanel.setBorder(new TitledBorder("Options"));
    wide = Math.max(wide, platformPanel.getPreferredSize().width);
    // goodIdea = new Dimension(wide, optionPanel.getPreferredSize().height);
    optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    // optionPanel.setMaximumSize(goodIdea);
    panel.add(optionPanel);

    Dimension good;
    // label1, label2, platformPanel, optionPanel
    good = new Dimension(wide, label1.getPreferredSize().height);
    label1.setMaximumSize(good);
    good = new Dimension(wide, label2.getPreferredSize().height);
    label2.setMaximumSize(good);
    good = new Dimension(wide, platformPanel.getPreferredSize().height);
    platformPanel.setMaximumSize(good);
    good = new Dimension(wide, optionPanel.getPreferredSize().height);
    optionPanel.setMaximumSize(good);

    //    JPanel actionPanel = new JPanel();
    //    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS));
    //    optionPanel.add(Box.createHorizontalGlue());

    //    final JDialog frame = new JDialog(editor, "Export to Application");

    //    JButton cancelButton = new JButton("Cancel");
    //    cancelButton.addActionListener(new ActionListener() {
    //      public void actionPerformed(ActionEvent e) {
    //        frame.dispose();
    //        return false;
    //      }
    //    });

    // Add the buttons in platform-specific order
    //    if (PApplet.platform == PConstants.MACOSX) {
    //      optionPanel.add(cancelButton);
    //      optionPanel.add(exportButton);
    //    } else {
    //      optionPanel.add(exportButton);
    //      optionPanel.add(cancelButton);
    //    }
    String[] options = {"Export", "Cancel"};
    final JOptionPane optionPane =
        new JOptionPane(
            panel,
            JOptionPane.PLAIN_MESSAGE,
            // JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_OPTION,
            null,
            options,
            options[0]);

    final JDialog dialog = new JDialog(this, "Export Options", true);
    dialog.setContentPane(optionPane);

    optionPane.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();

            if (dialog.isVisible()
                && (e.getSource() == optionPane)
                && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
              // If you were going to check something
              // before closing the window, you'd do
              // it here.
              dialog.setVisible(false);
            }
          }
        });
    dialog.pack();
    dialog.setResizable(false);

    Rectangle bounds = getBounds();
    dialog.setLocation(
        bounds.x + (bounds.width - dialog.getSize().width) / 2,
        bounds.y + (bounds.height - dialog.getSize().height) / 2);
    dialog.setVisible(true);

    Object value = optionPane.getValue();
    if (value.equals(options[0])) {
      return jmode.handleExportApplication(sketch);
    } else if (value.equals(options[1]) || value.equals(new Integer(-1))) {
      // closed window by hitting Cancel or ESC
      statusNotice("Export to Application canceled.");
    }
    return false;
  }
  public InfoPanelForDrawable(
      final Map map_line2treenodes, final String[] y_colnames, final Drawable dobj) {
    super();
    super.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    /* Define DecialFormat for the displayed time */
    if (fmt == null) {
      fmt = (DecimalFormat) NumberFormat.getInstance();
      fmt.applyPattern(FORMAT);
    }
    if (tfmt == null) tfmt = new TimeFormat();
    if (Normal_Border == null) {
      /*
      Normal_Border = BorderFactory.createCompoundBorder(
                      BorderFactory.createRaisedBevelBorder(),
                      BorderFactory.createLoweredBevelBorder() );
      */
      Normal_Border = BorderFactory.createEtchedBorder();
    }
    if (Shadow_Border == null) {
      Shadow_Border =
          BorderFactory.createTitledBorder(
              Normal_Border,
              " Preview State ",
              TitledBorder.LEFT,
              TitledBorder.TOP,
              Const.FONT,
              Color.magenta);
    }

    drawable = dobj;

    // Set the CategoryLabel Icon
    Dimension panel_max_size;
    Category type = null;
    CategoryLabel label_type = null;
    JPanel top_panel = new JPanel();
    top_panel.setLayout(new BoxLayout(top_panel, BoxLayout.X_AXIS));
    if (drawable instanceof Shadow && ((Shadow) drawable).getSelectedSubCategory() != null) {
      type = ((Shadow) drawable).getSelectedSubCategory();
      label_type = new CategoryLabel(type);
      ((Shadow) drawable).clearSelectedSubCategory();
      top_panel.setBorder(Shadow_Border);
    } else {
      type = drawable.getCategory();
      label_type = new CategoryLabel(type);
      top_panel.setBorder(Normal_Border);
    }
    top_panel.add(STRUT);
    top_panel.add(label_type);
    top_panel.add(GLUE);
    top_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel_max_size = top_panel.getPreferredSize();
    panel_max_size.width = Short.MAX_VALUE;
    top_panel.setMaximumSize(panel_max_size);
    super.add(top_panel);

    // Determine the text of the drawable
    TextAreaBuffer textbuf;
    int num_cols, num_rows;
    textbuf = new TextAreaBuffer(map_line2treenodes, y_colnames);
    if (drawable instanceof Shadow) textbuf.setShadowText((Shadow) drawable, type);
    else if (drawable instanceof Composite) textbuf.setCompositeText((Composite) drawable);
    else textbuf.setPrimitiveText((Primitive) drawable);
    textbuf.finalized();
    num_cols = textbuf.getColumnCount();
    num_rows = textbuf.getRowCount();

    // Set the TextArea
    JTextArea text_area;
    int adj_num_cols;
    text_area = new JTextArea(textbuf.toString());
    adj_num_cols = Routines.getAdjNumOfTextColumns(text_area, num_cols);
    num_cols = (int) Math.ceil(adj_num_cols * 85.0d / 100.0d);
    text_area.setColumns(num_cols);
    text_area.setRows(num_rows);
    text_area.setEditable(false);
    text_area.setLineWrap(true);
    JScrollPane scroller = new JScrollPane(text_area);
    scroller.setAlignmentX(Component.LEFT_ALIGNMENT);
    super.add(scroller);
  }
示例#27
0
  private void makeUi() {
    setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

    JPanel loginPane = createPane();
    loginPane.setLayout(new BoxLayout(loginPane, BoxLayout.Y_AXIS));
    add(loginPane);
    JLabel label = new JLabel("Login");
    loginPane.add(label);
    login = new JTextField();
    login.setAlignmentX(LEFT_ALIGNMENT);
    login.setPreferredSize(new Dimension(225, 25));
    loginPane.add(login);

    JPanel passwordPane = createPane();
    passwordPane.setLayout(new BoxLayout(passwordPane, BoxLayout.Y_AXIS));
    add(passwordPane);
    passwordPane.add(new JLabel("Password"));
    password = new JTextField();
    password.setAlignmentX(LEFT_ALIGNMENT);
    ;
    password.setPreferredSize(new Dimension(225, 25));
    passwordPane.add(password);

    JPanel dirPane = createPane();
    add(dirPane);
    dirPane.add(new JLabel("Directory"));
    JPanel dirSelectPane = new JPanel();
    dirSelectPane.setAlignmentX(LEFT_ALIGNMENT);
    dirPane.add(dirSelectPane);
    dirSelectPane.setLayout(new BoxLayout(dirSelectPane, BoxLayout.X_AXIS));
    directory = new JTextField();
    dirSelectPane.add(directory);
    JButton dirSelBtn = new JButton("...");
    dirSelectPane.add(dirSelBtn);

    final JDialog self = this;
    dirSelBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int returnVal = chooser.showOpenDialog(self);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              directory.setText(chooser.getSelectedFile().getAbsolutePath());
            }
          }
        });

    JPanel buttonsPane = new JPanel();
    buttonsPane.setLayout(new BoxLayout(buttonsPane, BoxLayout.X_AXIS));
    buttonsPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    buttonsPane.setAlignmentX(LEFT_ALIGNMENT);
    buttonsPane.add(Box.createHorizontalGlue());

    JButton okBtn = new JButton("OK");
    okBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            isOk = true;
            setVisible(false);
          }
        });
    buttonsPane.add(okBtn);

    JButton cancelBtn = new JButton("Cancel");
    cancelBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            isOk = false;
            setVisible(false);
          }
        });
    buttonsPane.add(cancelBtn);
    add(buttonsPane);
  }
  private void layoutComponentsOfManualProxyPanel() {
    manualProxyPanel.setLayout(new GridBagLayout());
    manualProxyPanel.setBorder(BorderFactory.createTitledBorder("Manual proxy configuration"));
    manualProxyPanel.setBackground(Color.WHITE);

    GridBagConstraints gc = new GridBagConstraints();

    ///////////////// First row ////////////////////////////////////////////
    gc.gridy = 0;

    gc.weightx = 1;
    gc.weighty = 0.1;

    gc.gridx = 0;
    gc.fill = GridBagConstraints.NONE;
    gc.anchor = GridBagConstraints.LINE_END;
    gc.insets = new Insets(0, 0, 0, 5);
    manualProxyPanel.add(useProxyLabel, gc);

    gc.gridx = 1;
    gc.insets = new Insets(0, 0, 0, 0);
    gc.anchor = GridBagConstraints.LINE_START;
    manualProxyPanel.add(useProxyRadioButton, gc);
    ///////////////// Next row ////////////////////////////////////////////
    gc.gridy++;

    gc.gridx = 1;
    gc.fill = GridBagConstraints.NONE;
    gc.anchor = GridBagConstraints.CENTER;
    manualProxyPanel.add(proxyAddressLabel, gc);
    gc.gridx = 2;
    manualProxyPanel.add(proxyPortLabel, gc);
    gc.gridx = 3;
    manualProxyPanel.add(proxyUserNameLabel, gc);
    gc.gridx = 4;
    manualProxyPanel.add(proxyPasswordLabel, gc);
    ///////////////// Next row ////////////////////////////////////////////
    gc.gridy++;

    gc.gridx = 0;
    gc.fill = GridBagConstraints.NONE;
    gc.anchor = GridBagConstraints.LINE_END;
    gc.insets = new Insets(0, 0, 0, 5);
    manualProxyPanel.add(httpLabel, gc);
    gc.gridx = 1;
    gc.fill = GridBagConstraints.NONE;
    manualProxyPanel.add(httpProxyAddressTextField, gc);
    gc.gridx = 2;
    manualProxyPanel.add(httpProxyPortSpinner, gc);
    gc.gridx = 3;
    manualProxyPanel.add(httpProxyUserNameTextField, gc);
    gc.gridx = 4;
    manualProxyPanel.add(httpProxyPasswordField, gc);
    ///////////////// Next row ////////////////////////////////////////////
    gc.gridy++;

    gc.gridx = 0;
    gc.fill = GridBagConstraints.NONE;
    gc.anchor = GridBagConstraints.LINE_END;
    gc.insets = new Insets(0, 0, 0, 5);
    manualProxyPanel.add(httpsLabel, gc);
    gc.gridx = 1;
    gc.fill = GridBagConstraints.NONE;
    manualProxyPanel.add(httpsProxyAddressTextField, gc);
    gc.gridx = 2;
    manualProxyPanel.add(httpsProxyPortSpinner, gc);
    gc.gridx = 3;
    manualProxyPanel.add(httpsProxyUserNameTextField, gc);
    gc.gridx = 4;
    manualProxyPanel.add(httpsProxyPasswordField, gc);
    ///////////////// Next row ////////////////////////////////////////////
    gc.gridy++;

    gc.gridx = 0;
    gc.fill = GridBagConstraints.NONE;
    gc.anchor = GridBagConstraints.LINE_END;
    gc.insets = new Insets(0, 0, 0, 5);
    manualProxyPanel.add(ftpLabel, gc);
    gc.gridx = 1;
    gc.fill = GridBagConstraints.NONE;
    manualProxyPanel.add(ftpProxyAddressTextField, gc);
    gc.gridx = 2;
    manualProxyPanel.add(ftpProxyPortSpinner, gc);
    gc.gridx = 3;
    manualProxyPanel.add(ftpProxyUserNameTextField, gc);
    gc.gridx = 4;
    manualProxyPanel.add(ftpProxyPasswordField, gc);

    ///////////////// Next row ////////////////////////////////////////////
    gc.gridy++;

    gc.gridx = 0;
    gc.fill = GridBagConstraints.NONE;
    gc.anchor = GridBagConstraints.LINE_END;
    gc.insets = new Insets(0, 0, 0, 5);
    manualProxyPanel.add(useSocksLabel, gc);

    gc.gridx = 1;
    gc.insets = new Insets(0, 0, 0, 0);
    gc.anchor = GridBagConstraints.LINE_START;
    manualProxyPanel.add(useSocksRadioButton, gc);
    ///////////////// Next row ////////////////////////////////////////////
    gc.gridy++;

    gc.gridx = 1;
    gc.fill = GridBagConstraints.NONE;
    gc.anchor = GridBagConstraints.CENTER;
    manualProxyPanel.add(socksProxyAddressLabel, gc);
    gc.gridx = 2;
    manualProxyPanel.add(socksProxyPortLabel, gc);
    gc.gridx = 3;
    manualProxyPanel.add(socksProxyUserNameLabel, gc);
    gc.gridx = 4;
    manualProxyPanel.add(socksProxyPasswordLabel, gc);
    ///////////////// Next row ////////////////////////////////////////////
    gc.gridy++;

    gc.gridx = 0;
    gc.fill = GridBagConstraints.NONE;
    gc.anchor = GridBagConstraints.LINE_END;
    gc.insets = new Insets(0, 0, 0, 5);
    manualProxyPanel.add(socksLabel, gc);
    gc.gridx = 1;
    gc.fill = GridBagConstraints.NONE;
    manualProxyPanel.add(socksProxyAddressTextField, gc);
    gc.gridx = 2;
    manualProxyPanel.add(socksProxyPortSpinner, gc);
    gc.gridx = 3;
    manualProxyPanel.add(socksProxyUserNameTextField, gc);
    gc.gridx = 4;
    manualProxyPanel.add(socksProxyPasswordField, gc);

    manualProxyPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(manualProxyPanel);
  }
  /** test BarbManipulationRendererJ3D */
  public static void main(String args[]) throws VisADException, RemoteException {

    System.out.println("BMR.main()");

    // construct RealTypes for wind record components
    RealType lat = RealType.Latitude;
    RealType lon = RealType.Longitude;
    RealType windx = RealType.getRealType("windx", CommonUnit.meterPerSecond);
    RealType windy = RealType.getRealType("windy", CommonUnit.meterPerSecond);
    RealType red = RealType.getRealType("red");
    RealType green = RealType.getRealType("green");

    // EarthVectorType extends RealTupleType and says that its
    // components are vectors in m/s with components parallel
    // to Longitude (positive east) and Latitude (positive north)
    EarthVectorType windxy = new EarthVectorType(windx, windy);

    RealType wind_dir = RealType.getRealType("wind_dir", CommonUnit.degree);
    RealType wind_speed = RealType.getRealType("wind_speed", CommonUnit.meterPerSecond);
    RealTupleType windds = null;
    if (args.length > 0) {
      System.out.println("polar winds");
      windds =
          new RealTupleType(
              new RealType[] {wind_dir, wind_speed}, new WindPolarCoordinateSystem(windxy), null);
    }

    // construct Java3D display and mappings that govern
    // how wind records are displayed
    DisplayImpl display = new DisplayImplJ3D("display1", new TwoDDisplayRendererJ3D());
    ScalarMap lonmap = new ScalarMap(lon, Display.XAxis);
    display.addMap(lonmap);
    ScalarMap latmap = new ScalarMap(lat, Display.YAxis);
    display.addMap(latmap);

    FlowControl flow_control;
    if (args.length > 0) {
      ScalarMap winds_map = new ScalarMap(wind_speed, Display.Flow1Radial);
      display.addMap(winds_map);
      winds_map.setRange(0.0, 1.0); // do this for barb rendering
      ScalarMap windd_map = new ScalarMap(wind_dir, Display.Flow1Azimuth);
      display.addMap(windd_map);
      windd_map.setRange(0.0, 360.0); // do this for barb rendering
      flow_control = (FlowControl) windd_map.getControl();
      flow_control.setFlowScale(0.15f); // this controls size of barbs
    } else {
      ScalarMap windx_map = new ScalarMap(windx, Display.Flow1X);
      display.addMap(windx_map);
      windx_map.setRange(-1.0, 1.0); // do this for barb rendering
      ScalarMap windy_map = new ScalarMap(windy, Display.Flow1Y);
      display.addMap(windy_map);
      windy_map.setRange(-1.0, 1.0); // do this for barb rendering
      flow_control = (FlowControl) windy_map.getControl();
      flow_control.setFlowScale(0.15f); // this controls size of barbs
    }

    display.addMap(new ScalarMap(red, Display.Red));
    display.addMap(new ScalarMap(green, Display.Green));
    display.addMap(new ConstantMap(1.0, Display.Blue));

    DataReferenceImpl[] refs = new DataReferenceImpl[N * N];
    int k = 0;
    // create an array of N by N winds
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        double u = 2.0 * i / (N - 1.0) - 1.0;
        double v = 2.0 * j / (N - 1.0) - 1.0;

        // each wind record is a Tuple (lon, lat, (windx, windy), red, green)
        // set colors by wind components, just for grins
        Tuple tuple;
        double fx = 30.0 * u;
        double fy = 30.0 * v;
        if (args.length > 0) {
          double fd = Data.RADIANS_TO_DEGREES * Math.atan2(-fx, -fy);
          double fs = Math.sqrt(fx * fx + fy * fy);
          tuple =
              new Tuple(
                  new Data[] {
                    new Real(lon, 10.0 * u),
                    new Real(lat, 10.0 * v - 40.0),
                    new RealTuple(windds, new double[] {fd, fs}),
                    new Real(red, u),
                    new Real(green, v)
                  });
        } else {
          tuple =
              new Tuple(
                  new Data[] {
                    new Real(lon, 10.0 * u),
                    new Real(lat, 10.0 * v - 40.0),
                    new RealTuple(windxy, new double[] {fx, fy}),
                    new Real(red, u),
                    new Real(green, v)
                  });
        }

        // construct reference for wind record
        refs[k] = new DataReferenceImpl("ref_" + k);
        refs[k].setData(tuple);

        // link wind record to display via BarbManipulationRendererJ3D
        // so user can change barb by dragging it
        // drag with right mouse button and shift to change direction
        // drag with right mouse button and no shift to change speed
        BarbManipulationRendererJ3D renderer = new BarbManipulationRendererJ3D();
        renderer.setKnotsConvert(true);
        display.addReferences(renderer, refs[k]);

        // link wind record to a CellImpl that will listen for changes
        // and print them
        WindGetterJ3D cell = new WindGetterJ3D(flow_control, refs[k]);
        cell.addReference(refs[k]);

        k++;
      }
    }

    // instead of linking the wind record "DataReferenceImpl refs" to
    // the WindGetterJ3Ds, you can have some user interface event (e.g.,
    // the user clicks on "DONE") trigger code that does a getData() on
    // all the refs and stores the records in a file.

    // create JFrame (i.e., a window) for display and slider
    JFrame frame = new JFrame("test BarbManipulationRendererJ3D");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    // create JPanel in JFrame
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setAlignmentY(JPanel.TOP_ALIGNMENT);
    panel.setAlignmentX(JPanel.LEFT_ALIGNMENT);
    frame.getContentPane().add(panel);

    // add display to JPanel
    panel.add(display.getComponent());

    // set size of JFrame and make it visible
    frame.setSize(500, 500);
    frame.setVisible(true);
  }