@Override
  public JComponent createContentPanel() {
    JPanel panel = new JPanel(new BorderLayout(10, 10));
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));

    JLabel label = new JLabel("Initial Focused Component: ");
    label.setDisplayedMnemonic('I');
    label.setHorizontalAlignment(SwingConstants.CENTER);

    JTextField textField = new JTextField();
    label.setLabelFor(textField);

    JPanel topPanel = new JPanel(new BorderLayout(6, 6));
    topPanel.add(label, BorderLayout.BEFORE_LINE_BEGINS);
    topPanel.add(textField, BorderLayout.CENTER);
    panel.add(topPanel, BorderLayout.BEFORE_FIRST_LINE);

    JTextArea textArea = new MultilineLabel();
    textArea.setColumns(50);
    textArea.setRows(20);
    textArea.setText(
        "This is an example using StandardDialog."
            + "\n\nIn this example, we create a dialog with banner, some example contents in content area, and a button panel with three buttons at the bottom of the dialog.");
    panel.add(new JScrollPane(textArea), BorderLayout.CENTER);
    setInitFocusedComponent(textField);
    return panel;
  }
  @Override
  protected JPanel createFormPanel() {
    JPanel mainPanel = new JPanel();
    JScrollPane scroll = new JScrollPane();
    JTextArea textArea = new JTextArea();

    textArea.setColumns(20);
    textArea.setRows(5);
    scroll.setViewportView(textArea);

    textArea.setText(HELP_TXT);
    textArea.setEditable(false);

    GroupLayout layout = new GroupLayout(mainPanel);
    mainPanel.setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(scroll, GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(scroll, GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE)
                    .addContainerGap()));
    return mainPanel;
  }
Exemple #3
0
  /**
   * Creates the terminal for interaction with client from server
   *
   * @param s
   */
  public Terminal(Server s) {
    mServer = s;

    TextFieldListener tfListener = new TextFieldListener();
    input.addActionListener(tfListener);

    Display = new javax.swing.JLayeredPane();

    input.setColumns(50);
    output.setColumns(50);
    output.setRows(30);
    output.setEditable(false);

    output.setBackground(Color.BLACK);
    output.setForeground(Color.WHITE);

    input.requestFocus(); // start with focus on this field

    output.setBounds(0, 0, 550, 310);
    Display.add(output, javax.swing.JLayeredPane.DEFAULT_LAYER);

    input.setBounds(0, 320, 550, 25);
    Display.add(input, javax.swing.JLayeredPane.DEFAULT_LAYER);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addComponent(
                        Display,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        550,
                        javax.swing.GroupLayout.PREFERRED_SIZE)));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(
                                Display,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                350,
                                javax.swing.GroupLayout.PREFERRED_SIZE))));

    pack();
  }
  // Constructor
  public ProcessRentalView() {
    this.f = new JFrame("Process Rental");
    f.pack();
    p = new JPanel();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int height = screenSize.height;
    int width = screenSize.width;
    f.setSize(width / 2, height / 2);

    f.setLocationRelativeTo(null);
    fl = new FlowLayout(FlowLayout.CENTER);
    idLabel = new JLabel("Item ID: ");
    idTextField = new JTextField(5);
    quantityLabel = new JLabel("Quantity: ");
    quantityTextField = new JTextField(5);
    dateLabel = new JLabel("Date(MM/DD/YYYY): ");
    dateTextField = new JTextField(8);
    dateTextField.setText("");
    totalItemsLabel = new JLabel("Items:");
    totalItems = new JTextArea("");
    totalItems.setEditable(false);
    totalItems.setColumns(10);
    totalItems.setRows(12);
    totalCostLabel = new JLabel("Total Cost:");
    totalCost = new JTextField(10);
    totalCost.setEditable(false);

    addButton = new JButton("Add Item");
    exitButton = new JButton("Exit");
    checkoutButton = new JButton("Checkout");
    p.add(idLabel);
    p.add(idTextField);
    p.add(quantityLabel);
    p.add(quantityTextField);
    p.add(dateLabel);
    p.add(dateTextField);
    p.add(addButton);
    p.add(exitButton);
    p.add(totalItemsLabel);
    p.add(totalItems);
    p.add(totalCostLabel);
    p.add(totalCost);
    p.add(checkoutButton);
    p.setLayout(fl);

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(p);
    f.setVisible(true);
  }
Exemple #5
0
  public JStatusBar() {
    setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    setLayout(new BorderLayout(0, 0));

    statusBar = new JLabel();
    statusBar.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    statusBar.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    miniBuf = new JTextArea();
    miniBuf.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    miniBuf.setEditable(false);
    miniBuf.setLineWrap(true);
    miniBuf.setRows(1);
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.getViewport().setView(miniBuf);
    add(statusBar, BorderLayout.PAGE_START);
    add(scrollPane, BorderLayout.PAGE_END);

    statusBar.setText(" ");
    miniBuf.setText("");
  }
  public CandleTypeTestForm() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(new Dimension(250, 400));
    setLayout(new BorderLayout());

    JPanel pnlSliders = new JPanel(new FlowLayout());
    pnlSliders.setLayout(new FlowLayout());
    pnlSliders.add(sldSize);
    pnlSliders.add(sldOpen);
    pnlSliders.add(sldClose);

    sldOpen.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            changed();
          }
        });
    sldClose.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            changed();
          }
        });
    sldSize.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            changed();
          }
        });

    add(pnlSliders, BorderLayout.CENTER);

    txt.setLineWrap(true);
    txt.setWrapStyleWord(true);
    txt.setRows(4);

    add(txt, BorderLayout.SOUTH);
  }
Exemple #7
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);
  }
  private void jbInit() throws Exception {
    label1.setText("En Label");

    button1.setText("OK");

    checkbox1.setText("En"); // sæt afkrydsningsfelternes navne
    checkbox2.setText("To");
    checkbox3.setText("Tre");

    radio1.setText("Radio1"); // sæt radioknappernes navne og
    radio2.setText("Radio2");
    buttonGroup1.add(radio1); // gruppe - så de gensidigt udelukker hinanden
    buttonGroup1.add(radio2);
    radio1.setSelected(true);

    comboBox1.addItem("ComboBox Rød");
    comboBox1.addItem("ComboBox Grøn");
    comboBox1.addItem("ComboBox Blå");

    textField1.setColumns(10);
    textField1.setText("Et TextField");

    textArea1.setColumns(15);
    textArea1.setRows(5);
    textArea1.setText("Et TextArea");

    this.setLayout(flowLayout1); // sæt layout-manager (se senere)

    this.add(label1); // til sidst skal komponenterne føjes
    this.add(button1); // til containeren (se senere)
    this.add(checkbox1);
    this.add(checkbox2);
    this.add(checkbox3);
    this.add(radio1);
    this.add(radio2);
    this.add(textField1);
    this.add(textArea1);
    this.add(comboBox1);
    this.add(list1);
  }
 private void initProgressFrame() {
   progressFrame = new JFrame("Progress");
   JPanel mainPanel = new JPanel();
   mainPanel.setLayout(new BorderLayout());
   progressBar = new JProgressBar();
   progressBar.setMinimum(0);
   progressBar.setMaximum(100);
   progressBar.setPreferredSize(new Dimension(500, 25));
   JPanel progressPanel = new JPanel();
   progressPanel.add(progressBar);
   progressPanel.setBorder(new EmptyBorder(10, 0, 0, 0));
   mainPanel.add(progressPanel, BorderLayout.NORTH);
   textArea = new JTextArea();
   textArea.setRows(20);
   textArea.setEditable(false);
   JScrollPane scrollPane = new JScrollPane(textArea);
   scrollPane.setBorder(new EmptyBorder(10, 10, 10, 10));
   mainPanel.add(scrollPane, BorderLayout.CENTER);
   doneButton = new JButton("Done");
   doneButton.setPreferredSize(new Dimension(495, 25));
   doneButton.setEnabled(false);
   doneButton.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           doneButton.setEnabled(false);
           progressFrame.setVisible(false);
           optionsFrame.setVisible(true);
         }
       });
   JPanel donePanel = new JPanel();
   donePanel.setLayout(new BorderLayout());
   donePanel.add(doneButton, BorderLayout.CENTER);
   donePanel.setBorder(new EmptyBorder(0, 10, 10, 10));
   mainPanel.add(donePanel, BorderLayout.SOUTH);
   progressFrame.getContentPane().add(mainPanel);
   progressFrame.pack();
   progressFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }
Exemple #10
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);
  }
  public PlayerSideBar(JPanel panel, final PlayerMedia frame) {
    this.contentPane = panel;
    this.frame = frame;
    // ******************** Button for listening to text entered **********
    btnListen = new JButton("Listen");
    btnListen.setEnabled(false);
    btnListen.setBackground(Color.GRAY);
    btnListen.setForeground(Color.WHITE);
    // ActionListener to perform the speaking when pressed
    btnListen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {

            // disable listen button so speak only one thing at a time
            btnListen.setEnabled(false);

            ListenBG ListenWorker = new ListenBG(frame);

            // execute SwingWorker
            ListenWorker.execute();
          }
        });
    btnListen.setBounds(750, 192, 135, 40);
    contentPane.add(btnListen);
    // ******************************************************************

    // ********************** Create mp3 (TTS) *****************************
    btnCreateMp = new JButton("Create mp3");
    btnCreateMp.setEnabled(false);
    btnCreateMp.setBackground(Color.GRAY);
    btnCreateMp.setForeground(Color.WHITE);
    // ActionListener: Creates mp3 from text entered TTS
    btnCreateMp.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            // ask user to enter desired output name
            final String output = JOptionPane.showInputDialog(null, "Enter Mp3 Name: ");
            File f = new File(output + ".mp3");

            if (output != null && output.length() > 0) {
              if (f.exists() && !f.isDirectory()) {
                // ask if user would want to overwrite existing file
                int reply =
                    JOptionPane.showConfirmDialog(
                        null,
                        "File already exists, overwrite?",
                        "Overwrite?",
                        JOptionPane.YES_NO_OPTION);
                if (reply == JOptionPane.YES_OPTION) {
                  CreateMp3BG maker = new CreateMp3BG(frame, output);
                  maker.execute();
                }
              } else {
                CreateMp3BG maker = new CreateMp3BG(frame, output);
                maker.execute();
              }
            }
          }
        });
    btnCreateMp.setBounds(905, 192, 142, 40);
    contentPane.add(btnCreateMp);
    // ******************************************************************

    // *************Button to combined selected audio and video files*************
    btnAddCom = new JButton("Merge Video/Audio\n");
    btnAddCom.setBackground(Color.GRAY);
    btnAddCom.setForeground(Color.WHITE);
    btnAddCom.setFont(new Font("Dialog", Font.BOLD, 22));
    btnAddCom.setBounds(750, 334, 297, 100);
    btnAddCom.setEnabled(false);
    btnAddCom.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            // pick a name for the output file
            final String comOutName = JOptionPane.showInputDialog("Enter New Video Name: ");
            File f = new File(comOutName + ".avi");

            if (comOutName != null && comOutName.length() > 0) {
              if (f.exists() && !f.isDirectory()) {
                // ask if user would want to overwrite existing file
                int reply =
                    JOptionPane.showConfirmDialog(
                        null,
                        "File already exists, overwrite?",
                        "Overwrite?",
                        JOptionPane.YES_NO_OPTION);

                if (reply == JOptionPane.YES_OPTION) {
                  // generate swingworker instance
                  AddCommentaryBG adder = new AddCommentaryBG(frame, comOutName);
                  adder.execute();
                }

              } else {
                // generate swingworker instance
                AddCommentaryBG adder = new AddCommentaryBG(frame, comOutName);
                adder.execute();
              }
            }
          }
        });
    contentPane.add(btnAddCom);

    // Label to indicate how many characters are remaining
    lblChars = new JLabel("200/200");
    lblChars.setForeground(Color.WHITE);
    lblChars.setBounds(980, 170, 70, 15);
    contentPane.add(lblChars);
    // ***************************************************************************

    // *****************simple text area for the user to enter text ******************
    txtArea = new JTextArea();
    txtArea.setText("Add Text Here");
    txtArea.setWrapStyleWord(true);
    txtArea.setRows(5);
    txtArea.setToolTipText("Enter text for text to speech. ");
    txtArea.setFont(new Font("Dialog", Font.PLAIN, 15));
    txtArea.setLineWrap(true);
    txtArea.setBounds(551, 41, 302, 122);
    txtArea.setDocument(docfilt);
    contentPane.add(txtArea);

    // ****** Scroll pane which allow text area to scroll **************************
    scrollPane = new JScrollPane(txtArea);
    scrollPane.setBounds(750, 41, 297, 122);
    contentPane.add(scrollPane);

    JLabel textLabel = new JLabel("Enter text for text-to-speech");
    scrollPane.setColumnHeaderView(textLabel);

    // **************** Document Filter to count characters ************************
    // set the maximum character to 200 so the festival voice doesn't die
    docfilt.setDocumentFilter(new DocumentSizeFilter(200));
    // add a listener to show user how many characters remaining
    docfilt.addDocumentListener(
        new DocumentListener() {
          @Override
          public void changedUpdate(DocumentEvent e) {
            charCount();
          }

          @Override
          public void insertUpdate(DocumentEvent e) {
            charCount();
          }

          @Override
          public void removeUpdate(DocumentEvent e) {
            charCount();
          }
        });
    // ******************************************************************

    // *************** Button to open window for eiditing commentary *****************
    btnEdit = new JButton("Add Audio Files To Merge");
    btnEdit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            edit.setVisible(true);
          }
        });
    btnEdit.setForeground(Color.WHITE);
    btnEdit.setFont(new Font("Dialog", Font.BOLD, 18));
    btnEdit.setBackground(Color.GRAY);
    btnEdit.setBounds(750, 244, 297, 78);
    contentPane.add(btnEdit);
    // *********************************************************************************

  }
Exemple #13
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);
  }
Exemple #14
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();
  }
Exemple #15
0
  public static void ConfigureMainWindow() {
    userNameLabel.setFont(new Font("Lucida Console", 0, 14));
    userNameLabel.setForeground(new Color(255, 255, 255));

    mainWindow.getContentPane().setBackground(new Color(4, 3, 10));
    mainWindow.setSize(800, 600);
    mainWindow.getContentPane().setLayout(null);
    connectButton.setBackground(new Color(255, 255, 255));
    connectButton.setForeground(new Color(4, 3, 10));
    connectButton.setFont(new Font("Lucida Console", 0, 14));

    connectButton.setText("Anslut");
    connectButton.setToolTipText("");
    mainWindow.getContentPane().add(connectButton);
    connectButton.setBounds(455, 10, 100, 25);

    conversation.setColumns(20);
    conversation.setFont(new Font("Lucida Console", 0, 14));
    conversation.setForeground(new Color(4, 3, 10));
    conversation.setLineWrap(true);
    conversation.setRows(5);
    // conversation.setEditable(false);

    tpConversation.setForeground(new Color(255, 255, 255));
    tpConversation.setBounds(10, 10, 600, 500);
    tpConversation.setBackground(new Color(4, 3, 10));
    tpConversation.setFont(new Font("Lucida Console", 0, 14));

    spConversation.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    spConversation.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    spConversation.setViewportView(tpConversation);
    mainWindow.getContentPane().add(spConversation);
    spConversation.setBounds(10, 10, 600, 500);

    userNameBox.setBounds(120, 10, 325, 25);
    userNameLabel.setBounds(10, 10, 130, 25);
    mainWindow.getContentPane().add(userNameBox);
    mainWindow.getContentPane().add(userNameLabel);

    usersOnline.setForeground(new Color(0, 180, 255));
    usersOnline.setBackground(new Color(4, 3, 10));
    usersOnline.setFont(new Font("Lucida Console", 0, 14));
    spUsersOnline.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    spUsersOnline.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    spUsersOnline.setViewportView(usersOnline);
    mainWindow.getContentPane().add(spUsersOnline);
    spUsersOnline.setBounds(620, 10, 165, 300);

    messageField.setForeground(new Color(255, 255, 255));
    messageField.setBackground(new Color(4, 3, 10));
    messageField.requestFocus();
    messageField.addActionListener(action);
    mainWindow.getContentPane().add(messageField);
    messageField.setBounds(10, 520, 600, 30);

    send.setBackground(new Color(255, 255, 255));
    send.setForeground(new Color(4, 3, 10));
    send.setText("Skicka");
    send.setFont(new Font("Lucida Console", 0, 14));
    mainWindow.getContentPane().add(send);
    send.setBounds(620, 520, 165, 30);

    disconnect.setBackground(new Color(255, 255, 255));
    disconnect.setForeground(new Color(4, 3, 10));
    disconnect.setText("Avsluta chatten");
    disconnect.setFont(new Font("Lucida Console", 0, 14));
    mainWindow.getContentPane().add(disconnect);
    disconnect.setBounds(620, 320, 165, 30);

    error.setFont(new Font("Lucida Console", 0, 14));
    error.setForeground(new Color(255, 0, 23));
    error.setBounds(120, 40, 525, 25);

    mainWindow.getContentPane().add(error);
  }
Exemple #16
0
 private static void adjustRows(JTextArea area) {
   area.setRows(Math.max(2, Math.min(3, StringUtil.countChars(area.getText(), '\n') + 1)));
 }
  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);
  }
  /** 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);
  }
  public void initComponents() {
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    setBounds(100, 100, 902, 597);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    panel_4 = new JPanel();
    panel_4.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Geral",
            TitledBorder.LEFT,
            TitledBorder.TOP,
            null,
            null));
    panel_4.setBounds(10, 11, 426, 236);
    contentPane.add(panel_4);
    panel_4.setLayout(null);

    lblModeloDoAutomato = new JLabel("Defini\u00E7\u00E3o do Automato:");
    lblModeloDoAutomato.setBounds(10, 47, 125, 14);
    panel_4.add(lblModeloDoAutomato);

    JScrollPane scrollPane_2 = new JScrollPane();
    scrollPane_2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane_2.setBounds(10, 72, 406, 124);
    panel_4.add(scrollPane_2);

    textArea = new JTextArea();
    textArea.setColumns(100);
    scrollPane_2.setColumnHeaderView(textArea);
    textArea.setAutoscrolls(true);
    textArea.setRows(9);

    JButton btnMinimizar = new JButton("Minimizar");
    btnMinimizar.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            minimizarAutomato();
          }
        });
    btnMinimizar.setBounds(10, 207, 104, 23);
    panel_4.add(btnMinimizar);

    JPanel panel = new JPanel();
    panel.setBounds(10, 15, 250, 25);
    panel_4.add(panel);
    panel.setBorder(null);
    panel.setLayout(null);

    JLabel lblNome = new JLabel("Criar estado:");
    lblNome.setBounds(10, 5, 82, 14);
    panel.add(lblNome);
    lblNome.setHorizontalAlignment(SwingConstants.CENTER);

    isfinal = new JCheckBox("Final");
    isfinal.setBounds(98, 1, 56, 23);
    panel.add(isfinal);

    btnNovo = new JButton("Novo");
    btnNovo.setBounds(160, 1, 73, 23);
    panel.add(btnNovo);
    btnNovo.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            novoEstado();
          }
        });

    JPanel panel_5 = new JPanel();
    panel_5.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Visualiza\u00E7\u00E3o",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_5.setBounds(10, 258, 1310, 390);
    contentPane.add(panel_5);
    panel_5.setLayout(null);

    painelView = new JPanelVisualizacao(this);
    painelView.setBounds(10, 22, 1290, 357);
    panel_5.add(painelView);

    JPanel panel_2 = new JPanel();
    panel_2.setBounds(558, 11, 314, 251);
    contentPane.add(panel_2);
    panel_2.setLayout(null);

    lblNewLabel = new JLabel("Detalhes de ");
    lblNewLabel.setBounds(10, 11, 152, 14);
    panel_2.add(lblNewLabel);

    cbisFinal = new JCheckBox("Final");
    cbisFinal.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent arg0) {
            turnFinal();
          }
        });
    cbisFinal.setBounds(168, 7, 60, 23);
    panel_2.add(cbisFinal);

    btnExcluir = new JButton("Excluir");
    btnExcluir.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            excluirEstado();
          }
        });
    btnExcluir.setBounds(231, 7, 73, 23);
    panel_2.add(btnExcluir);

    panel_3 = new JPanel();
    panel_3.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Transi\u00E7\u00F5es",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_3.setBounds(10, 36, 294, 204);
    panel_2.add(panel_3);
    panel_3.setLayout(null);

    JLabel lblSimbolo = new JLabel("Simbolo:");
    lblSimbolo.setBounds(10, 29, 96, 14);
    panel_3.add(lblSimbolo);

    cbAlfabeto = new JComboBox();
    cbAlfabeto.setBounds(122, 26, 49, 20);
    panel_3.add(cbAlfabeto);

    JLabel lblEstadosDestinos = new JLabel("Estados Destinos:");
    lblEstadosDestinos.setBounds(10, 57, 96, 14);
    panel_3.add(lblEstadosDestinos);

    cbEstadosDestinos = new JComboBox();
    cbEstadosDestinos.setBounds(122, 54, 49, 20);
    panel_3.add(cbEstadosDestinos);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(10, 82, 274, 111);
    panel_3.add(scrollPane_1);

    tblTrans = new JTable();
    scrollPane_1.setViewportView(tblTrans);

    btnNova = new JButton("Nova");
    btnNova.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            novaTransicao();
          }
        });
    btnNova.setBounds(181, 25, 89, 23);
    panel_3.add(btnNova);

    btnRemover = new JButton("Remover");
    btnRemover.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            removerTransicao();
          }
        });
    btnRemover.setBounds(181, 53, 89, 23);
    panel_3.add(btnRemover);

    JPanel panel_1 = new JPanel();
    panel_1.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Estados",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_1.setBounds(446, 11, 102, 236);
    contentPane.add(panel_1);
    panel_1.setLayout(null);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 26, 82, 199);
    panel_1.add(scrollPane);

    tblEstados = new JTable();
    scrollPane.setViewportView(tblEstados);
    tblEstados.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent arg0) {
            selecionaEstadoAtual(a.getEstados().get(tblEstados.getSelectedRow()));
          }
        });
    tblEstados.setAutoscrolls(true);
    tblEstados.add(new Scrollbar());
  }
  public Component getDemoPanel() {
    final String[] fontNames = DemoData.getFontNames();
    // create file text field
    List<String> urls = null;
    try {
      urls = readUrls();
    } catch (IOException e) {
      //noinspection CallToPrintStackTrace
      e.printStackTrace();
    }

    JTextField urlTextField = new JTextField("http://");
    urlTextField.setName("URL IntelliHint");
    SelectAllUtils.install(urlTextField);
    ListDataIntelliHints intelliHints = new ListDataIntelliHints<String>(urlTextField, urls);
    intelliHints.setCaseSensitive(false);

    JTextField pathTextField = new JTextField();
    SelectAllUtils.install(pathTextField);
    FileIntelliHints fileIntelliHints = new FileIntelliHints(pathTextField);
    fileIntelliHints.setFilter(
        new FilenameFilter() {
          public boolean accept(File dir, String name) {
            return !_applyFileFilter
                || dir.getAbsolutePath().contains("Program")
                || name.contains("Program");
          }
        });
    fileIntelliHints.setFolderOnly(false);
    fileIntelliHints.setFollowCaret(true);
    fileIntelliHints.setShowFullPath(false);

    // create file text field
    JTextField fileTextField = new JTextField();
    fileTextField.setName("File IntelliHint");
    SelectAllUtils.install(fileTextField);
    new FileIntelliHints(fileTextField);

    // create file text field
    JTextArea fileTextArea = new JTextArea();
    new FileIntelliHints(fileTextArea);
    fileTextArea.setRows(4);

    // create file text field
    JTextField fontTextField = new JTextField();
    fontTextField.setName("Font IntelliHint");
    SelectAllUtils.install(fontTextField);
    ListDataIntelliHints fontIntelliHints =
        new ListDataIntelliHints<String>(fontTextField, fontNames);
    fontIntelliHints.setCaseSensitive(false);

    JTextField textField = new JTextField();
    SelectAllUtils.install(textField);
    //noinspection UnusedDeclaration
    new AbstractListIntelliHints(textField) {
      protected JLabel _messageLabel;

      @Override
      public JComponent createHintsComponent() {
        JPanel panel = (JPanel) super.createHintsComponent();
        _messageLabel = new JLabel();
        panel.add(_messageLabel, BorderLayout.BEFORE_FIRST_LINE);
        return panel;
      }

      // update list model depending on the data in textfield
      public boolean updateHints(Object value) {
        if (value == null) {
          return false;
        }
        String s = value.toString();
        s = s.trim();
        if (s.length() == 0) {
          return false;
        }
        try {
          long l = Long.parseLong(s);
          boolean prime = isProbablePrime(l);
          _messageLabel.setText("");
          if (prime) {
            return false;
          } else {
            Vector<Long> list = new Vector<Long>();
            long nextPrime = l;
            for (int i = 0; i < 10; i++) {
              nextPrime = nextPrime(nextPrime);
              list.add(nextPrime);
            }
            setListData(list);
            _messageLabel.setText("Next 10 prime numbers:");
            _messageLabel.setForeground(Color.DARK_GRAY);
            return true;
          }
        } catch (NumberFormatException e) {
          setListData(new Object[0]);
          _messageLabel.setText("Invalid long number");
          setListData(new Object[0]);
          _messageLabel.setForeground(Color.RED);
          return true;
        }
      }
    };

    DefaultTableModel model =
        new DefaultTableModel(0, 1) {
          private static final long serialVersionUID = -2794741068912785630L;

          @Override
          public Class<?> getColumnClass(int columnIndex) {
            return String.class;
          }

          @Override
          public String getColumnName(int column) {
            return "Font";
          }
        };
    model.addRow(new Object[] {"Arial"});
    model.addRow(new Object[] {"Tahoma"});
    SortableTable table = new SortableTable(model);
    table
        .getColumnModel()
        .getColumn(0)
        .setCellEditor(
            new TextFieldCellEditor(String.class) {
              private static final long serialVersionUID = 2023654568542192380L;

              @Override
              protected JTextField createTextField() {
                JTextField cellEditorTextField = new JTextField();
                ListDataIntelliHints fontIntellihints =
                    new ListDataIntelliHints<String>(cellEditorTextField, fontNames);
                fontIntellihints.setCaseSensitive(false);
                return cellEditorTextField;
              }
            });
    table.setPreferredScrollableViewportSize(new Dimension(100, 100));

    JPanel panel = new JPanel();
    panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS, 3));
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    panel.add(new JLabel("ListDataIntelliHints TextField for URLs: "));
    panel.add(urlTextField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    // create path text field
    panel.add(
        new JLabel("FileIntelliHints TextField for paths (folders only, show partial path):"));
    panel.add(pathTextField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(
        new JLabel("FileIntelliHints TextField for files (files and folders, show full path):"));
    panel.add(fileTextField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(new JLabel("FileIntelliHints TextArea for files (each line is for a new file):"));
    panel.add(new JScrollPane(fileTextArea));
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(new JLabel("IntelliHints TextField to choose a font:"));
    panel.add(fontTextField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(new JLabel("A custom IntelliHints for prime numbers: "));
    panel.add(textField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(new JLabel("Using IntelliHint in JTable's cell editor"));
    panel.add(new JScrollPane(table), JideBoxLayout.FLEXIBLE);

    panel.add(Box.createGlue(), JideBoxLayout.VARY);

    return panel;
  }
  @Override
  public boolean onStart() {
    window = new JFrame("Interface Explorer");
    treeModel = new InterfaceTreeModel();
    treeModel.update("");
    tree = new JTree(treeModel);
    tree.setRootVisible(false);
    tree.setEditable(false);
    renderer = new HighlightTreeCellRenderer(tree.getCellRenderer());
    tree.setCellRenderer(renderer);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addTreeSelectionListener(
        new TreeSelectionListener() {
          private void addInfo(final String key, final String value, final boolean highlight) {
            final JPanel row = new JPanel();
            row.setAlignmentX(Component.LEFT_ALIGNMENT);
            row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS));
            for (final String data : new String[] {key, value}) {
              final JLabel label = new JLabel(data);
              label.setAlignmentY(Component.TOP_ALIGNMENT);
              if (highlight) {
                label.setForeground(Color.magenta);
              }
              row.add(label);
            }
            infoArea.add(row);
          }

          public void valueChanged(final TreeSelectionEvent e) {
            final Object node = tree.getLastSelectedPathComponent();
            if (node == null || node instanceof RSInterfaceWrap) {
              return;
            }
            infoArea.removeAll();
            RSComponent iface = null;
            if (node instanceof RSComponentWrap) {
              iface = ((RSComponentWrap) node).wrapped;
            }
            if (iface == null) {
              return;
            }
            List<Integer> changes = new ArrayList<Integer>();
            for (int i = 0; i < HighLightWraps.size(); i++) {
              if (iface.getParent() == null) {
                if (HighLightWraps.get(i).getChild().getIndex() == iface.getIndex()
                    && HighLightWraps.get(i).getParent().getIndex()
                        == iface.getInterface().getIndex()) {
                  changes.add(HighLightWraps.get(i).getChange());
                }
              } else {
                if (HighLightWraps.get(i).getChild().getIndex() == iface.getParent().getIndex()
                    && HighLightWraps.get(i).getParent().getIndex()
                        == iface.getParent().getInterface().getIndex()) {
                  changes.add(HighLightWraps.get(i).getChange());
                }
              }
            }
            addInfo("Type: ", "" + iface.getType(), changes.contains(1));
            addInfo("SpecialType: ", "" + iface.getSpecialType(), changes.contains(2));
            addInfo("Bounds Index: ", "" + iface.getBoundsArrayIndex(), changes.contains(3));
            if (iface.getArea() != null) {
              Rectangle size = iface.getArea();
              addInfo("Size: ", size.width + "," + size.height, changes.contains(15));
            }
            addInfo("Model ID: ", "" + iface.getModelID(), changes.contains(4));
            addInfo("Texture ID: ", "" + iface.getBackgroundColor(), changes.contains(5));
            addInfo("Parent ID: ", "" + iface.getParentID(), changes.contains(6));
            addInfo("Text: ", "" + iface.getText(), changes.contains(7));
            addInfo("Tooltip: ", "" + iface.getTooltip(), changes.contains(8));
            addInfo("SelActionName: ", "" + iface.getSelectedActionName(), changes.contains(9));
            if (iface.getActions() != null) {
              String actions = "";
              for (final String action : iface.getActions()) {
                if (!actions.equals("")) {
                  actions += "\n";
                }
                actions += action;
              }
              addInfo("Actions: ", actions, changes.contains(10));
            }
            addInfo("Component ID: ", "" + iface.getComponentID(), changes.contains(11));
            addInfo(
                "Component Stack Size: ", "" + iface.getComponentStackSize(), changes.contains(12));
            addInfo(
                "Relative Location: ",
                "(" + iface.getRelativeX() + "," + iface.getRelativeY() + ")",
                changes.contains(13));
            addInfo(
                "Absolute Location: ",
                "(" + iface.getAbsoluteX() + "," + iface.getAbsoluteY() + ")",
                changes.contains(14));
            addInfo(
                "Rotation: ",
                "x: "
                    + iface.getXRotation()
                    + "  y: "
                    + iface.getYRotation()
                    + "  z: "
                    + iface.getZRotation(),
                changes.contains(16));
            setHighlightArea(iface.getArea());
            infoArea.validate();
            infoArea.repaint();
          }
        });
    final JDialog Help = new JDialog();
    JScrollPane jScrollPane1;
    JTextArea jTextArea1;
    jScrollPane1 = new JScrollPane();
    jTextArea1 = new JTextArea();
    Help.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Help.setTitle("Help");
    Help.setResizable(false);
    jTextArea1.setColumns(20);
    jTextArea1.setEditable(false);
    jTextArea1.setFont(new java.awt.Font("MS UI Gothic", 0, 12));
    jTextArea1.setLineWrap(true);
    jTextArea1.setRows(5);
    jTextArea1.setText(
        "Once toggled the listener feature of the interface explorer will detect any changes made to Runescapes interfaces in realtime. If a change is found that interface and data will then be highlighted within the explorers tree model. To use the listener feature you would :\n\n1) Toggle the listener button as active\n2) Wait or commit changes in Runescape\n3) Repaint tree using repaint button or reclick interface folders in GUI\n\n\nTips : While listening for changes the tree model in the GUI will not update itself, changing colors. To refresh the GUI either use the repaint button or close and open Interface folder already within the tree model.");
    jTextArea1.setWrapStyleWord(true);
    jScrollPane1.setViewportView(jTextArea1);
    final GroupLayout layout = new GroupLayout(Help.getContentPane());
    Help.getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        jScrollPane1, GroupLayout.PREFERRED_SIZE, 220, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    Help.pack();
    JScrollPane scrollPane = new JScrollPane(tree);
    scrollPane.setPreferredSize(new Dimension(250, 500));
    window.add(scrollPane, BorderLayout.WEST);
    infoArea = new JPanel();
    infoArea.setLayout(new BoxLayout(infoArea, BoxLayout.Y_AXIS));
    scrollPane = new JScrollPane(infoArea);
    scrollPane.setPreferredSize(new Dimension(250, 500));
    window.add(scrollPane, BorderLayout.CENTER);
    final ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            treeModel.update(searchBox.getText());
            infoArea.removeAll();
            infoArea.validate();
            infoArea.repaint();
          }
        };
    final ActionListener toggleListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            if (listenerButton.isSelected()) {
              log("Cleared");
              HighLightWraps.clear();
            }
            check();
          }
        };
    final ActionListener repaintListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            log("Refreshed Tree");
            treeModel.fireTreeStructureChanged(treeModel.getRoot());
            infoArea.removeAll();
            infoArea.validate();
            infoArea.repaint();
          }
        };
    final ActionListener helpListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            Help.setVisible(true);
          }
        };
    final JPanel toolArea = new JPanel();
    toolArea.setLayout(new FlowLayout(FlowLayout.LEFT));
    toolArea.add(new JLabel("Filter:"));
    searchBox = new JTextField(20);
    searchBox.addActionListener(actionListener);
    toolArea.add(searchBox);
    final JButton updateButton = new JButton("Update");
    final JButton repaintButton = new JButton("Repaint");
    final JButton helpButton = new JButton("Help");
    helpButton.addActionListener(helpListener);
    listenerButton.addActionListener(toggleListener);
    updateButton.addActionListener(actionListener);
    repaintButton.addActionListener(repaintListener);
    toolArea.add(updateButton);
    toolArea.add(listenerButton);
    toolArea.add(repaintButton);
    toolArea.add(helpButton);
    window.add(toolArea, BorderLayout.NORTH);
    window.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    window.pack();
    window.setVisible(true);
    return true;
  }
Exemple #22
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;
  }
    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getActionCommand().equals("Acties")) {
            controller.add(new Actiescreen());
        }

        if (e.getActionCommand().equals("Editmenu")) {
            JDialog dialog = new JDialog();
            dialog.setBounds(0, 0, 300, 500);

            dialog.add(new EditScreen(1));
            dialog.pack();
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
        }

        if (e.getActionCommand().equals("Kalenderoverzicht")) {
            controller.add(new Kalenderscreen());
        }

        if (e.getActionCommand().equals("Gedachte toevoegen")) {
            JDialog dialog = new JDialog();
            dialog.setTitle("Gedachte Toevoegen");
            dialog.setModal(true);
            dialog.setBounds(0, 0, 300, 500);

            dialog.add(new EditScreen(2));
            dialog.pack();
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
            dialog.validate();
        }

        if (e.getActionCommand().equals("Edit gedachte")) {
            final JDialog dialog = new JDialog();
            dialog.setTitle("Edit gedachte");
            dialog.setModal(true);
            dialog.setBounds(0, 0, 300, 500);

            JPanel panel = new JPanel();
            panel.setLayout(new BorderLayout());
            final JTextField text = new JTextField();
            JButton button = new JButton("Toepassen");
            panel.add(text, BorderLayout.NORTH);
            panel.add(button, BorderLayout.SOUTH);
            button.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    String change = text.getText();
                    int gedachte = controller.getCurrentThought();
                    DataLayer.changeThought(gedachte, change);
                    dialog.setVisible(false);
                    controller.updateThouhts();
                }
            });

            dialog.add(panel);
            dialog.pack();
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
            dialog.validate();
        }

        if (e.getActionCommand().equals("Gedachte omzetten naar actie")) {
            ArrayList<Projectscreen> test = controller.getProjects();
            if (test.get(0).getList().getSelectedIndex() == -1) {
                JOptionPane.showMessageDialog(null, "Selecteer eerst een gedachte", "Error", JOptionPane.ERROR_MESSAGE);
            } else {
                final JDialog dialog = new JDialog();
                dialog.setPreferredSize(new Dimension(500, 200));
                dialog.setTitle("Gedachte omzetten naar actie");
                dialog.setModal(true);

                JPanel master = new JPanel();
                dialog.add(master);
                master.setLayout(new GridLayout(0, 1));

                // Project kiezen
                JPanel projects = new JPanel();
                projects.setLayout(new BorderLayout());
                JLabel projectnaam = new JLabel("Project");
                final JComboBox box = new JComboBox();
                final ArrayList<Projectscreen> arraylist = controller.getProjects();
                Projectscreen thoughts = arraylist.get(0);
                for (Projectscreen s : arraylist) {
                    if (!s.getNaam().equals("Gedachten")){
                    String naam = s.getNaam();
                    box.addItem(naam);
                    box.validate();
                    }
                }
                projects.add(projectnaam, BorderLayout.WEST);
                projects.add(box, BorderLayout.CENTER);
                master.add(projects);

                //gedachte
                JPanel gedachten = new JPanel();
                gedachten.setLayout(new BorderLayout());
                JLabel n = new JLabel("Gedachte: ");
                final JTextField n1 = new JTextField();
                final int id = controller.getCurrentThought();
                final JList list = thoughts.getList();
                final String s = (String) list.getSelectedValue();
                String[] s1 = s.split(" ");
                String s2 = s1[0];
                n1.setText(s.replaceFirst(s2, ""));
                n1.setText(n1.getText().trim());
                gedachten.add(n, BorderLayout.WEST);
                gedachten.add(n1, BorderLayout.CENTER);
                master.add(gedachten);

                // beschrijving
                JPanel beschrijving = new JPanel();
                beschrijving.setLayout(new BorderLayout());
                JLabel b = new JLabel("Beschrijving");
                final JTextArea b1 = new JTextArea(0, 3);
                b1.setLineWrap(true);
                b1.setRows(3);
                b1.setWrapStyleWord(true);
                b1.setColumns(0);
                JScrollPane scroll = new JScrollPane();
                scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
                scroll.getViewport().setView(b1);
                beschrijving.add(b, BorderLayout.WEST);
                beschrijving.add(scroll, BorderLayout.CENTER);
                master.add(beschrijving);
                
                // context
                
                JPanel context = new JPanel();
                context.setLayout(new BorderLayout());
                JLabel co = new JLabel("Context");
                final JComboBox co1 = new JComboBox();
                co1.setEditable(true);
                final ArrayList<String> co2 = DataLayer.getContexts();
                if (!co2.isEmpty()){
                    for (String t : co2){
                        co1.addItem(t);
                    }
                }
                
                context.add(co, BorderLayout.WEST);
                context.add(co1, BorderLayout.CENTER);
                master.add(context);

                // status
                JPanel status = new JPanel();
                status.setLayout(new BorderLayout());
                JLabel st = new JLabel("Status");
                final JComboBox box1 = new JComboBox();
                ArrayList<String> arrayStatus = DataLayer.getStatuses();
                for (String t : arrayStatus) {
                    box1.addItem(t.toString());
                    box1.validate();
                }
                status.add(st, BorderLayout.WEST);
                status.add(box1, BorderLayout.CENTER);
                master.add(status);

                // datum
                JPanel datum = new JPanel();
                datum.setLayout(new BorderLayout());
                JLabel d = new JLabel("Datum");
                final JFormattedTextField d1 = new JFormattedTextField(new SimpleDateFormat("yyyy-mm-dd"));
                d1.setText("yyyy-mm-dd");
                datum.add(d, BorderLayout.WEST);
                datum.add(d1, BorderLayout.CENTER);
                master.add(datum);

                // button
                JButton toepassen = new JButton("Toepassen");
                master.add(toepassen);
                toepassen.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent ae) {
                        String description = n1.getText();
                        String notes = b1.getText();
                        
                        String co3 = (String) co1.getSelectedItem();
                        boolean bestaat = false;
                        for (String t : co2){
                            if (t.equals(co3)){
                                bestaat = true;
                            }
                        }
                        
                        if (!bestaat){
                            DataLayer.addContext(co3);
                        }
                        
                        String context = co3;
                        String status = box1.getSelectedItem().toString();
                        int projectid = arraylist.get(box.getSelectedIndex()).getID() + 1;
                        String datum = d1.getText();
                        int idGedachte = Integer.parseInt("" + s.charAt(0)) - 1;

                        if (datum.equals("yyyy-mm-dd") | datum.equals("")) {
                            JOptionPane.showMessageDialog(null, "Vul een datum in", "Error", JOptionPane.ERROR_MESSAGE);
                        } else {
                            DataLayer.addAction(description, notes, context, status, projectid, datum);
                            DataLayer.deleteThought(idGedachte);
                            controller.updateThouhts();
                            controller.updateProjects();
                            dialog.setVisible(false);
                            ArrayList<Projectscreen> project = controller.getProjects();
                            Projectscreen t = project.get(0);
                            int i = t.getList().getModel().getSize();
                            int x = t.getList().getSelectedIndex();
                        }
                    }
                });

                dialog.pack();
                dialog.setLocationRelativeTo(null);
                dialog.setVisible(true);
                dialog.validate();
            }
        }

        if (e.getActionCommand().equals("Wis gedachte")) {
            DataLayer.deleteThought(controller.getCurrentThought());
            controller.updateThouhts();
        }

        if (e.getActionCommand().equals("Voeg project toe")) {
            final JDialog dialog = new JDialog();
            dialog.setTitle("Project toevoegen");
            dialog.setModal(true);

            JPanel panel = new JPanel();
            panel.setLayout(new BorderLayout());
            final JTextField naam = new JTextField();

            JPanel projectnaam = new JPanel();
            projectnaam.setLayout(new BorderLayout());
            projectnaam.add(new JLabel("Projectnaam"), BorderLayout.WEST);
            projectnaam.add(naam, BorderLayout.CENTER);

            JButton button = new JButton("Aanmaken");
            panel.add(projectnaam, BorderLayout.NORTH);
            panel.add(button, BorderLayout.SOUTH);
            button.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    String e = DataLayer.addProject(naam.getText());
                    controller.updateProjects(e);
                    dialog.setVisible(false);
                    validate();
                }
            });

            dialog.add(panel);
            dialog.pack();
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
            dialog.validate();
        }

        if (e.getActionCommand().equals("Bewerk project")) {
            final JDialog dialog = new JDialog();
            dialog.setTitle("Bewerk project");
            dialog.setModal(true);
            dialog.setBounds(0, 0, 300, 500);

            JPanel panel = new JPanel();
            panel.setLayout(new BorderLayout());
            final JTextField naam = new JTextField();
            final JComboBox box = new JComboBox();
            box.setEditable(false);
            final ArrayList<Projectscreen> projects = controller.getProjects();
            projects.remove(0);
            for (Projectscreen t : projects) {
                box.addItem(t.getNaam());
                box.validate();
            }

            JPanel projectid = new JPanel();
            projectid.setLayout(new BorderLayout());
            projectid.add(new JLabel("Kies project"), BorderLayout.WEST);
            projectid.add(box, BorderLayout.CENTER);

            JPanel projectnaam = new JPanel();
            projectnaam.setLayout(new BorderLayout());
            projectnaam.add(new JLabel("Nieuwe projectnaam"), BorderLayout.WEST);
            projectnaam.add(naam, BorderLayout.CENTER);

            JButton button = new JButton("Bewerk");
            panel.add(projectid, BorderLayout.NORTH);
            panel.add(projectnaam, BorderLayout.CENTER);
            panel.add(button, BorderLayout.SOUTH);
            button.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    int d = box.getSelectedIndex();
                    projects.get(d).changeName(naam.getText());
                    DataLayer.changeProject(projects.get(d).getID(), naam.getText());
                    dialog.setVisible(false);
                    validate();
                }
            });

            dialog.add(panel);
            dialog.pack();
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
            dialog.validate();
        }

        if (e.getActionCommand().equals("Verwijder project")) {
            final JDialog dialog = new JDialog();
            dialog.setTitle("Wis project");
            dialog.setModal(true);
            dialog.setBounds(0, 0, 300, 500);

            JPanel panel = new JPanel();
            panel.setLayout(new BorderLayout());
            final JTextField naam = new JTextField();

            final JComboBox box = new JComboBox();
            box.setEditable(false);
            final ArrayList<Projectscreen> projects = controller.getProjects();
            projects.remove(0);
            for (Projectscreen t : projects) {
                box.addItem(t.getNaam());
                box.validate();
            }

            JPanel projectnaam = new JPanel();
            projectnaam.setLayout(new BorderLayout());
            projectnaam.add(new JLabel("Project"), BorderLayout.WEST);
            projectnaam.add(box, BorderLayout.CENTER);

            JButton button = new JButton("Wissen");
            panel.add(projectnaam, BorderLayout.NORTH);
            panel.add(button, BorderLayout.SOUTH);
            button.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    //pj.deleteProject(naam.getText(), id.getNumber().intValue()); 
                    int d = box.getSelectedIndex();
                    projects.get(d).changeName(naam.getText());
                    DataLayer.deleteProject(projects.get(d).getID());
                    controller.updateIDprojects(d);
                    dialog.setVisible(false);
                    validate();
                }
            });

            dialog.add(panel);
            dialog.pack();
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
            dialog.validate();
        }

        if (e.getActionCommand().equals("Uitloggen")) {
            controller.logOff();
        }

        if (e.getActionCommand().equals("Afsluiten")) {
            controller.quit();
        }
    }
Exemple #24
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);
  }
  private void initComponents() {
    entry = new JTextField();
    textArea = new JTextArea();
    status = new JLabel();
    jLabel1 = new JLabel();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle("TextFieldDemo");

    textArea.setColumns(20);
    textArea.setLineWrap(true);
    textArea.setRows(5);
    textArea.setWrapStyleWord(true);
    textArea.setEditable(false);
    jScrollPane1 = new JScrollPane(textArea);

    jLabel1.setText("Enter text to search:");

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);

    ParallelGroup hGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);

    SequentialGroup h1 = layout.createSequentialGroup();
    ParallelGroup h2 = layout.createParallelGroup(GroupLayout.Alignment.TRAILING);

    h1.addContainerGap();

    h2.addComponent(
        jScrollPane1,
        GroupLayout.Alignment.LEADING,
        GroupLayout.DEFAULT_SIZE,
        450,
        Short.MAX_VALUE);
    h2.addComponent(
        status, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE);

    SequentialGroup h3 = layout.createSequentialGroup();
    h3.addComponent(jLabel1);
    h3.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
    h3.addComponent(entry, GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE);

    h2.addGroup(h3);
    h1.addGroup(h2);

    h1.addContainerGap();

    hGroup.addGroup(GroupLayout.Alignment.TRAILING, h1);
    layout.setHorizontalGroup(hGroup);

    ParallelGroup vGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    SequentialGroup v1 = layout.createSequentialGroup();
    v1.addContainerGap();
    ParallelGroup v2 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v2.addComponent(jLabel1);
    v2.addComponent(
        entry, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
    v1.addGroup(v2);
    v1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
    v1.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE);

    v1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
    v1.addComponent(status);
    v1.addContainerGap();

    vGroup.addGroup(v1);
    layout.setVerticalGroup(vGroup);
    pack();
  }
Exemple #26
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 updateViewerForSelection() {
    if (myAllContents.isEmpty()) return;
    String fullString = getSelectedText();

    if (myViewer != null) {
      EditorFactory.getInstance().releaseEditor(myViewer);
    }

    if (myUseIdeaEditor) {
      myViewer = createIdeaEditor(fullString);
      JComponent component = myViewer.getComponent();
      component.setPreferredSize(JBUI.size(300, 500));
      mySplitter.setSecondComponent(component);
    } else {
      final JTextArea textArea = new JTextArea(fullString);
      textArea.setRows(3);
      textArea.setWrapStyleWord(true);
      textArea.setLineWrap(true);
      textArea.setSelectionStart(0);
      textArea.setSelectionEnd(textArea.getText().length());
      textArea.setEditable(false);
      mySplitter.setSecondComponent(ScrollPaneFactory.createScrollPane(textArea));
    }
    mySplitter.revalidate();
  }