Example #1
0
  public GUI() {
    String[] keys = {"no Quotation found"};
    if (tryDir(".") || tryDir("BLM305") || tryDir("CSE470")) keys = Q.keySet().toArray(keys);
    menu = new JComboBox<String>(keys);
    if (Q.size() > 0) setMessage(0);

    JPanel pan = new JPanel();
    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new javax.swing.border.EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COLOR);

    pan.add(topPanel(), "North");

    txt.setFont(LARGE);
    txt.setEditable(false);
    txt.setRows(5);
    txt.setColumns(30);
    txt.setWrapStyleWord(true);
    txt.setLineWrap(true);
    txt.setDragEnabled(true);
    pan.add(new JScrollPane(txt), "Center");

    ref.setFont(SMALL);
    ref.setEditable(false);
    ref.setColumns(35);
    ref.setDragEnabled(true);
    pan.add(ref, "South");

    pan.setToolTipText("A project realized collectively by the class");
    menu.setToolTipText("Quotation classes");
    who.setToolTipText("author()+year()");
    txt.setToolTipText("text()");
    ref.setToolTipText("reference()");

    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frm.setLocation(scaled(120), scaled(90));
    frm.pack();
    frm.setVisible(true);
  }
Example #2
0
  public Gui2() {

    setTitle("My First Gui");
    setSize(600, 600);
    setLocation(100, 100);
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    pane = getContentPane();
    // pane.setLayout(new GridLayout(3,3));
    pane.setLayout(new FlowLayout());
    b1 = new JButton("Click me");
    b1.addActionListener(this);
    pane.add(b1);

    b2 = new JButton("exit");
    b2.addActionListener(this);
    pane.add(b2);

    labeler = new JButton("Labeler");
    labeler.addActionListener(this);
    pane.add(labeler);

    label = new JLabel("The Label:");
    pane.add(label);

    box = new JCheckBox("Cap");
    pane.add(box);
    text = new JTextArea();
    text.setColumns(40);
    text.setRows(5);
    text.setBorder(BorderFactory.createLineBorder(Color.red, 2));
    text.addKeyListener(new Key());
    pane.add(text);

    canvas = new Canvas();
    canvas.setPreferredSize(new Dimension(300, 300));
    canvas.setBorder(BorderFactory.createLineBorder(Color.blue, 2));
    pane.add(canvas);
  }
  public static void makescalaSciCodeFromParams(int odeSolveMethod) {
    switch (odeSolveMethod) {
      case ODEWizardScalaSci.ODErke:
        scriptText =
            " import scala._ \n import scalaSci._ \n import scalaSci.Vec._ \n"
                + " import scalaSci.Mat._ \n import java.util.Vector \n"
                + " import numal._ \n import  scalaSci.math.plot.plot._  \n";

        scriptText +=
            " \n var  n= "
                + systemOrder
                + ";  // the number of equations of the system\n"
                + "var  x = new Array[Double](1)     // entry:   x(0) is the initial value of the independent variable  \n"
                + "var  xe = new Array[Double](1)    //  entry:  xe(0) is the final value of the independent variable    \n"
                + "var y = new Array[Double](n+1)   // entry: the dependent variable, the initial values at x = x0 \n"
                + "var data = new Array[Double](7)   // in array data one should give: \n"
                + "                                        //     data(1):   the relative tolerance \n"
                + "                                        //     data(2):  the absolute tolerance  \n"
                + "                                        //  after each step data(3:6) contains:  \n"
                + "                                        //      data(3):  the steplength used for the last step \n"
                + "                                       //      data(4):  the number of integration steps performed \n"
                + "                                       //      data(5):  the number of integration steps rejected  \n "
                + "                                       //      data(6):  the number of integration steps skipped \n"
                + "                                 // if upon completion of rke data(6) > 0, then results should be considered most criticallly \n"
                + " fi = true;                        // if fi is true then the integration starts at x0 with a trial step xe-x0;  \n"
                + "                                        // if fi is false then the integration is continued with a step length data(3)* sign(xe-x0) \n"
                + "data(1) = 1.0e-6;  data(2) = 1.0e-6; \n\n"
                + "var xOut:Vector[Array[Double]] = new Vector();  \n"
                + "var yOut:Vector[Array[Double]] = new Vector();  \n"
                + "// a Java class that implements the AP_rke_methods interface should be specified \n"
                + "// The AP_rke_methods interface requires the implementation of two procedures: \n"
                + "//    void der(int n, double t, double v[]) \n"
                + "//              this procedure performs an evaluation of the right-hand side of the system with dependent variable v[1:n] and \n"
                + "//              and independent variable t; upon completion of der the right-hand side should be overwritten on v[1:n] \n"
                + "//    void out(int n, double x[], double xe[], double y[], double data[]) \n"
                + "//              after each integration step performed, out can be used to obtain information from the solution process, \n"
                + "//              e.g., the values of x, y[1:n], and data[3:6]; out can also be used to update data, but x and xe remain unchanged \n\n";

        scriptText +=
            "\n var xStart = "
                + xStart
                + ";"
                + "\n var xEnd =  "
                + xEnd
                + ";   // start and end values of integration \n \n";
        for (int k = 1; k <= systemOrder; k++)
          scriptText += "y(" + k + ") = " + Math.random() + "; \n";

        scriptText += " x(0) = xStart; \n  xe(0) = xEnd; \n";
        scriptText +=
            "var javaClassName  = "
                + "\""
                + editingClassName
                + "\""
                + ";   // name of the Java class that implements the ODE \n";

        scriptText +=
            "\n var invocationObject = Class.forName(javaClassName, false, GlobalValues.globalInterpreter.classLoader).newInstance(); \n"
                + "\n var lorenz2RKEObject = invocationObject.asInstanceOf[AP_rke_methods] \n";

        scriptText += "tic() \n";
        scriptText += "var fi = true \n";
        scriptText +=
            "\nAnalytic_problems.rke(x, xe, n, y, lorenz2RKEObject,  data, fi,  xOut, yOut); \n"
                + "\n var timeCompute = toc() \n";

        scriptText +=
            "var plotTitle = \"Lorenz attractor in ScalaSci, time =  \"+timeCompute+ \" Runge-Kutta (rke()),  integrating from \"+xStart+\", to tEnd= \"+xEnd  \n";
        scriptText += "var color = Color.RED \n";

        scriptText += "  figure3d(1); plotV(yOut, color, plotTitle) \n";

        break;

      case ODEWizardScalaSci.ODEmultistep:
        scriptText =
            " import scala._ \n import scalaSci._  \n import scalaSci.Vec._ \n import scalaSci.Mat._ \n "
                + "import java.util.Vector \n import numal._ \n import  scalaSci.math.plot.plot._\n";

        scriptText +=
            "\n var n= "
                + systemOrder
                + "; // the number of equations of the system \n"
                + "var first = new  Array[Boolean](1);   // if first is true then the procedure starts the integration with a first order Adams method \n"
                + "// and a steplength equal to hmin,  upon completion of a call, first is set to false \n"
                + "first(0)=true; \n"
                + "var btmp = new Array[Boolean](2) \n"
                + "var itmp = new Array[Int](3) \n"
                + "var xtmp = new Array[Double](7) \n"
                + "var x = new Array[Double](1) \n"
                + "var y = new Array[Double](6*n+1) \n"
                + "var ymax = new Array[Double](4) \n"
                + "var save = new Array[Double](6*n+39)  //    in this array the procedure stores information which can be used in a continuing call \n"
                + "          // with first = false; also the following messages are delivered: \n"
                + "          //      save[38] == 0;  an Adams method has been used  \n"
                + "          //      save[38] == 1;  the procedure switched to Gear's method \n"
                + "          //      save[37] == 0;  no error message  \n"
                + "          //      save[37] == 1; with the hmin specified the procedure cannot handle the nonlinearity (decrease hmin!) \n"
                + "          //      save[36] ;  number of times that the requested local error bound was exceeded   \n"
                + "         //      save[35] ;  if save[36] is nonzero then save[35] gives an estimate of the maximal local error bound, otherwise save[35]=0 \n\n"
                + "\n  var   jac = Array.ofDim[Double](n+1)  \n"
                + "var k=0;     while (k<=n) {        jac(k) = new Array[Double](n+1);    k += 1; } \n"
                + "var xOut:Vector[Array[Double]] = new Vector() \n"
                + "var yOut:Vector[Array[Double]] = new Vector() \n"
                + "var hmin=1.0e-10;    var eps=1.0e-9 \n"
                + "\n y(1)=0.12; y(2)=0.3; y(3)=0.12; \n"
                + "ymax(1) = 0.00001;   ymax(2) = 0.00001;    ymax(3) = 0.00001;    var tstart = 0.0;    x(0) = tstart \n"
                + "var xendDefault =\"100.0\"  // end point of integration, default value \n"
                + "var prompt = \"Specify the end integration value\" \n"
                + "var inVal  = JOptionPane.showInputDialog(prompt, xendDefault) \n"
                + "var tend = inVal.toDouble \n";

        scriptText +=
            "var javaClassName  = "
                + "\""
                + editingClassName
                + "\""
                + ";   // name of the Java class that implements the ODE \n";

        scriptText +=
            "\n var invocationObject = Class.forName(javaClassName, false, GlobalValues.globalInterpreter.classLoader).newInstance(); \n";

        scriptText +=
            "\n var multistepObject = invocationObject.asInstanceOf[AP_multistep_methods] \n";

        scriptText +=
            "\ntic() \n"
                + "\nAnalytic_problems.multistep(x, tend,y,hmin,5,ymax,eps,first, save, multistepObject, jac, true,n,btmp,itmp,xtmp, xOut, yOut) \n"
                + "var  runTime =  toc() \n"
                + "var plotTitle = \"Lorenz system, method Multistep,  ntegratin from \"+tstart+\", to tEnd= \"+tend+\", runTime = \"+runTime \n";

        scriptText += "var color = Color.RED \n  figure3d(1); plotV(yOut, color, plotTitle) ";

        break;

      case ODEWizardScalaSci.ODEdiffsys:
        scriptText =
            " import scala._ \n import scalaSci._ \n import scalaSci.Vec._  \n "
                + "import scalaSci.Mat._ \n import java.util.Vector  \n import  numal._  \n import scalaSci.math.plot.plot._  \n";

        scriptText +=
            "var tol = 0.0000000000004 \n var aeta = tol; var reta = tol\n "
                + "var n = 3; // the number of equations of the system \n"
                + "var x = new Array[Double](1)  // entry: x(0) is the initial value of the independent variable \n"
                + "var y = new Array[Double](n+1)   // entry: the dependent variable, the initial values at x = x0 \n"
                + "aeta = tol  // aeta: required absolute precision in the integration process \n"
                + "reta = tol // reta: required relative precision in the integration process \n"
                + "var s = new Array[Double](n+1) \n"
                + "var h0=0.000001  // h0: the initial step to be taken \n"
                + "var xOut:Vector[Array[Double]] = new Vector() \n"
                + "var yOut:Vector[Array[Double]] = new Vector() \n"
                + "y(1)=0.4; y(2)= -0.3; y(3)=0.9; \n"
                + "\n x(0)=0;  var xe = 720; \n"
                + "\nvar javaClassName  = "
                + "\""
                + editingClassName
                + "\""
                + ";   // name of the Java class that implements the ODE \n";

        scriptText +=
            "\n var invocationObject = Class.forName(javaClassName, false, GlobalValues.globalInterpreter.classLoader).newInstance(); \n"
                + "var diffSysObject = invocationObject.asInstanceOf[AP_diffsys_methods] \n"
                + "\n tic() \n"
                + "Analytic_problems.diffsys(x, xe, n, y, diffSysObject, aeta, reta , s, h0, xOut, yOut) \n"
                + "var timeCompute = toc() \n"
                + "var plotTitle = \"Double Scroll attractor with ScalaSci, time \"+timeCompute+ \" end point = \"+xe \n"
                + "var color = Color.RED \n"
                + " figure3d(1); plotV(yOut, color, plotTitle); \n";

        break;

      default:
        scriptText = "";
    }

    scriptTextArea.setFont(new Font("Arial", Font.PLAIN, 12));
    scriptTextArea.setRows(30);
    scriptTextArea.setText(scriptText);

    scriptPanel = new JPanel();
    scriptScrollPane = new JScrollPane(scriptTextArea);
    scriptPanel.add(scriptScrollPane);

    JButton scriptSaveButton = new JButton("Save Script Code");
    scriptSaveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String currentWorkingDirectory = GlobalValues.ScalaSciClassPath;
            JFileChooser chooser = new JFileChooser(currentWorkingDirectory);
            chooser.setSelectedFile(new File(editingClassName + ".gsci"));
            int ret = chooser.showSaveDialog(ODEWizardScalaSci.scriptFrame);

            if (ret != JFileChooser.APPROVE_OPTION) {
              return;
            }
            File f = chooser.getSelectedFile();
            try {
              PrintWriter out = new PrintWriter(f);
              String scriptCodeText = scriptTextArea.getText();
              out.write(scriptCodeText);
              out.close();
            } catch (java.io.FileNotFoundException enf) {
              System.out.println("File " + f.getName() + " not found");
              enf.printStackTrace();
            }
          }
        });

    JButton scriptRunButton = new JButton("Run Script Code");
    scriptRunButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            GlobalValues.scalalabMainFrame.scalalabConsole.interpretLine(scriptText + "\n");
          }
        });
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.add(scriptSaveButton);
    buttonsPanel.add(scriptRunButton);

    ODEWizardScalaSciScala.scriptFrame = new JFrame("Your script code");
    ODEWizardScalaSciScala.scriptFrame.setLayout(new BorderLayout());
    ODEWizardScalaSciScala.scriptFrame.add(scriptPanel, BorderLayout.CENTER);
    ODEWizardScalaSciScala.scriptFrame.add(buttonsPanel, BorderLayout.SOUTH);
    ODEWizardScalaSciScala.scriptFrame.setSize(
        GlobalValues.figFrameSizeX, GlobalValues.figFrameSizeY);
    ODEWizardScalaSciScala.scriptFrame.setVisible(true);
  }
Example #4
0
  private void initComponents() {
    try {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception e) {
      // If Nimbus is not available, you can set the GUI to another look and feel.
    }

    usernameLabel = new JLabel();
    usernameField = new JTextField();
    chatroomScrollPane = new JScrollPane();
    chatroomArea = new JTextArea();
    chatMsgLabel = new JLabel();
    chatMsgField = new JTextField();
    chatIPLabel = new JLabel();
    chatIPField = new JTextField();
    portLabel = new JLabel();
    portField = new JTextField();
    joinButton = new JToggleButton();
    sendButton = new JButton();
    leaveButton = new JButton();
    exitButton = new JButton();

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    usernameLabel.setText("Username:"******" ");

    chatroomArea.setEditable(false);
    chatroomArea.setColumns(20);
    chatroomArea.setRows(5);
    chatroomScrollPane.setViewportView(chatroomArea);

    chatMsgLabel.setText("Chat Message:");

    chatIPLabel.setText("Chat Group IP");

    chatIPField.setText("224.27.43.188");

    portLabel.setText("Port");

    portField.setText("4001");

    joinButton.setText("JOIN CHAT");
    joinButton.addActionListener(this);

    sendButton.setText("SEND MESSAGE");
    sendButton.addActionListener(this);

    leaveButton.setText("LEAVE CHAT");
    leaveButton.addActionListener(this);

    exitButton.setText("EXIT");
    exitButton.addActionListener(this);

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addGroup(
                                GroupLayout.Alignment.TRAILING,
                                layout
                                    .createSequentialGroup()
                                    .addGap(0, 0, Short.MAX_VALUE)
                                    .addComponent(usernameLabel)
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(
                                        usernameField,
                                        GroupLayout.PREFERRED_SIZE,
                                        83,
                                        GroupLayout.PREFERRED_SIZE))
                            .addComponent(chatroomScrollPane)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGroup(
                                        layout
                                            .createParallelGroup(GroupLayout.Alignment.LEADING)
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addComponent(chatMsgLabel)
                                                    .addPreferredGap(
                                                        LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(
                                                        chatMsgField,
                                                        GroupLayout.PREFERRED_SIZE,
                                                        296,
                                                        GroupLayout.PREFERRED_SIZE))
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addGroup(
                                                        layout
                                                            .createParallelGroup(
                                                                GroupLayout.Alignment.TRAILING,
                                                                false)
                                                            .addComponent(
                                                                chatIPField,
                                                                GroupLayout.Alignment.LEADING)
                                                            .addComponent(
                                                                chatIPLabel,
                                                                GroupLayout.Alignment.LEADING,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE))
                                                    .addGap(18, 18, 18)
                                                    .addGroup(
                                                        layout
                                                            .createParallelGroup(
                                                                GroupLayout.Alignment.LEADING,
                                                                false)
                                                            .addComponent(
                                                                portField,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                46,
                                                                Short.MAX_VALUE)
                                                            .addComponent(
                                                                portLabel,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE))
                                                    .addGap(18, 18, 18)
                                                    .addGroup(
                                                        layout
                                                            .createParallelGroup(
                                                                GroupLayout.Alignment.LEADING,
                                                                false)
                                                            .addGroup(
                                                                layout
                                                                    .createSequentialGroup()
                                                                    .addComponent(leaveButton)
                                                                    .addGap(18, 18, 18)
                                                                    .addComponent(
                                                                        exitButton,
                                                                        GroupLayout.DEFAULT_SIZE,
                                                                        GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE))
                                                            .addGroup(
                                                                layout
                                                                    .createSequentialGroup()
                                                                    .addComponent(
                                                                        joinButton,
                                                                        GroupLayout.PREFERRED_SIZE,
                                                                        93,
                                                                        GroupLayout.PREFERRED_SIZE)
                                                                    .addGap(18, 18, 18)
                                                                    .addComponent(sendButton)))))
                                    .addGap(0, 8, Short.MAX_VALUE)))
                    .addContainerGap()));

    layout.setVerticalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(GroupLayout.Alignment.LEADING, false)
                            .addComponent(usernameField)
                            .addComponent(
                                usernameLabel,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE))
                    .addGap(3, 3, 3)
                    .addComponent(
                        chatroomScrollPane,
                        GroupLayout.PREFERRED_SIZE,
                        178,
                        GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                chatMsgLabel,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                chatMsgField,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .addGroup(
                        layout
                            .createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                                            .addComponent(chatIPLabel)
                                            .addComponent(portLabel))
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                                            .addComponent(
                                                chatIPField,
                                                GroupLayout.PREFERRED_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.PREFERRED_SIZE)
                                            .addComponent(
                                                portField,
                                                GroupLayout.PREFERRED_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.PREFERRED_SIZE)))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGap(16, 16, 16)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                GroupLayout.Alignment.LEADING, false)
                                            .addComponent(
                                                joinButton,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .addComponent(
                                                sendButton,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE))
                                    .addGap(8, 8, 8)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                                            .addComponent(leaveButton)
                                            .addComponent(exitButton))))
                    .addGap(17, 17, 17)));
    pack();
    setVisible(true);
  }
Example #5
0
  private boolean updateTextComponent(final boolean search) {
    JTextComponent oldComponent = search ? mySearchTextComponent : myReplaceTextComponent;
    Color oldBackground = oldComponent != null ? oldComponent.getBackground() : null;
    Wrapper wrapper = search ? mySearchFieldWrapper : myReplaceFieldWrapper;
    boolean multiline = myFindModel.isMultiline();
    if (multiline && oldComponent instanceof JTextArea) return false;
    if (!multiline && oldComponent instanceof JTextField) return false;

    final JTextComponent textComponent;
    if (multiline) {
      textComponent = new JTextArea();
      ((JTextArea) textComponent).setColumns(25);
      ((JTextArea) textComponent).setRows(2);
      wrapper.setContent(
          new SearchWrapper(textComponent, new ShowHistoryAction(textComponent, this)));
    } else {
      SearchTextField searchTextField = new SearchTextField(true);
      searchTextField.setOpaque(false);
      textComponent = searchTextField.getTextEditor();
      searchTextField.getTextEditor().setColumns(25);
      if (UIUtil.isUnderGTKLookAndFeel()) {
        textComponent.setOpaque(false);
      }
      setupHistoryToSearchField(
          searchTextField,
          search
              ? FindSettings.getInstance().getRecentFindStrings()
              : FindSettings.getInstance().getRecentReplaceStrings());
      textComponent.registerKeyboardAction(
          new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
              final String text = textComponent.getText();
              myFindModel.setMultiline(true);
              ApplicationManager.getApplication()
                  .invokeLater(
                      new Runnable() {
                        @Override
                        public void run() {
                          if (search) {
                            mySearchTextComponent.setText(text + "\n");
                          } else {
                            myReplaceTextComponent.setText(text + "\n");
                          }
                        }
                      });
            }
          },
          KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.ALT_DOWN_MASK),
          JComponent.WHEN_FOCUSED);
      wrapper.setContent(searchTextField);
    }

    if (search) {
      mySearchTextComponent = textComponent;
    } else {
      myReplaceTextComponent = textComponent;
    }

    UIUtil.addUndoRedoActions(textComponent);
    Utils.setSmallerFont(textComponent);

    textComponent.putClientProperty("AuxEditorComponent", Boolean.TRUE);
    if (oldBackground != null) {
      textComponent.setBackground(oldBackground);
    }
    textComponent.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(final FocusEvent e) {
            textComponent.repaint();
          }

          @Override
          public void focusLost(final FocusEvent e) {
            textComponent.repaint();
          }
        });
    new CloseOnESCAction(this, textComponent);
    return true;
  }
Example #6
0
 private static void adjustRows(JTextArea area) {
   area.setRows(Math.max(2, Math.min(3, StringUtil.countChars(area.getText(), '\n') + 1)));
 }
  /** Create the window UI. */
  private void buildUI() {
    Container cPane = getContentPane();
    cPane.setLayout(new GridBagLayout());
    GridBagConstraints c;
    JLabel label;
    String msg;
    JTextField field;

    int row = 0;

    label = new JLabel(sTimeStampFormat.format(mInvite.getTimestamp()));
    label.setFont(new Font("SansSerif", Font.PLAIN, 9));
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = row++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.EAST;
    c.insets = new Insets(SPACING, MARGIN, 0, MARGIN);
    cPane.add(label, c);

    msg = mInvite.getPlayerJID();
    msg = StringUtils.parseBareAddress(msg);
    field = new JTextField(msg);
    field.setEditable(false);
    field.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = row++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(SPACING, MARGIN, 0, MARGIN);
    cPane.add(field, c);

    String gamename = mInvite.getGameName();
    if (gamename != null) gamename = gamename.trim();

    if (gamename != null && !gamename.equals("")) msg = "  " + localize("MessageInvitedOf");
    else msg = "  " + localize("MessageInvited");
    label = new JLabel(msg);
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = row++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(SPACING, MARGIN, 0, MARGIN);
    cPane.add(label, c);

    if (gamename != null && !gamename.equals("")) {
      field = new JTextField(gamename);
      field.setEditable(false);
      field.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));
      c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = row++;
      c.gridwidth = GridBagConstraints.REMAINDER;
      c.anchor = GridBagConstraints.WEST;
      c.insets = new Insets(SPACING, MARGIN, 0, MARGIN);
      cPane.add(field, c);
    }

    String message = mInvite.getMessage();
    if (message != null) message = message.trim();

    if (message != null && !message.equals("")) {
      JTextArea textarea = new JTextArea();
      textarea.setEditable(false);
      textarea.setRows(4);
      textarea.setLineWrap(true);
      textarea.setWrapStyleWord(true);
      textarea.setText(message);
      c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = row++;
      c.gridwidth = GridBagConstraints.REMAINDER;
      c.weightx = 1;
      c.fill = GridBagConstraints.HORIZONTAL;
      c.anchor = GridBagConstraints.WEST;
      c.insets = new Insets(GAP, MARGIN, 0, MARGIN);
      JScrollPane scroller = new JScrollPane(textarea);
      scroller.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));
      cPane.add(scroller, c);
    }

    label = new JLabel(localize("LabelNickname"));
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = row;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(GAP, MARGIN, 0, MARGIN);
    cPane.add(label, c);

    mNicknameField = new JTextField(20);
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = row++;
    c.weightx = 1;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(GAP, SPACING, 0, MARGIN);
    cPane.add(mNicknameField, c);

    // Add panel with Cancel and Create buttons
    JPanel buttonPanel = new JPanel(new GridBagLayout());
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = row++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.insets = new Insets(GAP, MARGIN, MARGIN, MARGIN);
    c.anchor = GridBagConstraints.EAST;
    c.weightx = 1;
    cPane.add(buttonPanel, c);

    mAcceptButton = new JButton(localize("ButtonAccept"));
    c = new GridBagConstraints();
    c.gridx = 2;
    c.gridy = 0;
    c.insets = new Insets(0, 0, 0, 0);
    c.anchor = GridBagConstraints.EAST;
    buttonPanel.add(mAcceptButton, c);

    mChatButton = new JButton(localize("ButtonDeclineChat"));
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = 0;
    c.insets = new Insets(0, SPACING, 0, 0);
    c.anchor = GridBagConstraints.EAST;
    buttonPanel.add(mChatButton, c);

    mDeclineButton = new JButton(localize("ButtonDecline"));
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(0, SPACING, 0, 0);
    c.anchor = GridBagConstraints.EAST;
    buttonPanel.add(mDeclineButton, c);
  }
Example #8
0
  /** Shows a dialog with input for logs description. */
  private void uploadLogs() {
    ResourceManagementService resources = LoggingUtilsActivator.getResourceService();

    final SIPCommDialog dialog =
        new SIPCommDialog(false) {
          /** Serial version UID. */
          private static final long serialVersionUID = 0L;

          /**
           * Dialog is closed. Do nothing.
           *
           * @param escaped <tt>true</tt> if this dialog has been closed by pressing
           */
          @Override
          protected void close(boolean escaped) {}
        };

    dialog.setModal(true);
    dialog.setTitle(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON"));

    Container container = dialog.getContentPane();
    container.setLayout(new GridBagLayout());

    JLabel descriptionLabel = new JLabel("Add a comment:");
    final JTextArea commentTextArea = new JTextArea();
    commentTextArea.setRows(4);
    final JButton uploadButton =
        new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_BUTTON"));
    final SIPCommTextField emailField =
        new SIPCommTextField(resources.getI18NString("plugin.loggingutils.ARCHIVE_UPREPORT_EMAIL"));
    final JCheckBox emailCheckBox =
        new SIPCommCheckBox("Email me when more information is available");
    emailCheckBox.setSelected(true);
    emailCheckBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (!emailCheckBox.isSelected()) {
              uploadButton.setEnabled(true);
              emailField.setEnabled(false);
            } else {
              emailField.setEnabled(true);

              if (emailField.getText() != null && emailField.getText().trim().length() > 0)
                uploadButton.setEnabled(true);
              else uploadButton.setEnabled(false);
            }
          }
        });

    emailField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void insertUpdate(DocumentEvent e) {
                updateButtonsState();
              }

              public void removeUpdate(DocumentEvent e) {
                updateButtonsState();
              }

              public void changedUpdate(DocumentEvent e) {}

              /** Check whether we should enable upload button. */
              private void updateButtonsState() {
                if (emailCheckBox.isSelected()
                    && emailField.getText() != null
                    && emailField.getText().trim().length() > 0) uploadButton.setEnabled(true);
                else uploadButton.setEnabled(false);
              }
            });

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(10, 10, 3, 10);
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;

    container.add(descriptionLabel, c);

    c.insets = new Insets(0, 10, 10, 10);
    c.gridy = 1;
    container.add(new JScrollPane(commentTextArea), c);

    c.insets = new Insets(0, 10, 0, 10);
    c.gridy = 2;
    container.add(emailCheckBox, c);

    c.insets = new Insets(0, 10, 10, 10);
    c.gridy = 3;
    container.add(emailField, c);

    JButton cancelButton = new JButton(resources.getI18NString("service.gui.CANCEL"));
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dialog.dispose();
          }
        });

    uploadButton.setEnabled(false);
    uploadButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              final ArrayList<String> paramNames = new ArrayList<String>();
              final ArrayList<String> paramValues = new ArrayList<String>();

              if (emailCheckBox.isSelected()) {
                paramNames.add("Email");
                paramValues.add(emailField.getText());
              }

              paramNames.add("Description");
              paramValues.add(commentTextArea.getText());

              // don't block the UI thread we may need to show
              // some ui for password input if protected area on the way
              new Thread(
                      new Runnable() {
                        public void run() {
                          uploadLogs(
                              getUploadLocation(),
                              LogsCollector.getDefaultFileName(),
                              paramNames.toArray(new String[] {}),
                              paramValues.toArray(new String[] {}));
                        }
                      })
                  .start();
            } finally {
              dialog.dispose();
            }
          }
        });
    JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
    buttonsPanel.add(uploadButton);
    buttonsPanel.add(cancelButton);

    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0;
    c.gridy = 4;
    container.add(buttonsPanel, c);

    dialog.setVisible(true);
  }
Example #9
0
  private void initializeUI() {

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle(Constants.WINDOW_TITLE);

    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            closePort();
          }
        });

    JMenuBar menuBar = new JMenuBar();
    portMenu = new JMenu(Constants.WINDOW_PORT);
    menuBar.add(portMenu);

    refreshItem = new JMenuItem(Constants.WINDOW_REFRESH_PORTS);
    refreshItem.addActionListener(e -> refreshSerialPortList());

    portMenu.add(refreshItem);

    setJMenuBar(menuBar);

    Container mainPane = getContentPane();

    mainPane.setLayout(new BorderLayout());

    textArea = new JTextArea();
    textArea.setRows(16);
    textArea.setColumns(40);
    textArea.setEditable(false);

    JScrollPane scrollPane = new JScrollPane(textArea);

    mainPane.add(scrollPane, BorderLayout.CENTER);

    JPanel lowerPane = new JPanel();
    lowerPane.setLayout(new BoxLayout(lowerPane, BoxLayout.X_AXIS));
    lowerPane.setBorder(new EmptyBorder(4, 4, 4, 4));

    JButton transferFileButton = new JButton(Constants.WINDOW_TRANSFER_FILE);
    transferFileButton.addActionListener(e -> onTransferFileClicked());
    lowerPane.add(transferFileButton);
    lowerPane.add(Box.createRigidArea(new Dimension(4, 0)));

    textField = new JTextField(40);
    textField.addKeyListener(this);

    JButton sendButton = new JButton(Constants.WINDOW_SEND);

    JButton clearButton = new JButton(Constants.WINDOW_CLEAN);
    clearButton.addActionListener(e -> textArea.setText(""));

    sendButton.addActionListener(e -> onSendButtonClicked());

    lowerPane.add(textField);
    lowerPane.add(Box.createRigidArea(new Dimension(4, 0)));
    lowerPane.add(sendButton);
    lowerPane.add(Box.createRigidArea(new Dimension(4, 0)));
    lowerPane.add(clearButton);

    mainPane.add(lowerPane, BorderLayout.SOUTH);

    pack();

    refreshSerialPortList();
  }
Example #10
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