Exemplo n.º 1
0
  /** Initializes the call button. */
  private void initCallButton() {
    List<ProtocolProviderService> telephonyProviders = CallManager.getTelephonyProviders();

    if (telephonyProviders != null && telephonyProviders.size() > 0) {
      if (callButton.getParent() != null) return;

      callButton.setAlignmentX(JButton.CENTER_ALIGNMENT);

      callButton.setMnemonic(
          GuiActivator.getResources().getI18nMnemonic("service.gui.CALL_CONTACT"));

      buttonPanel.add(callButton);

      callButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              String searchText = parentWindow.getCurrentSearchText();

              if (searchText == null) return;

              CallManager.createCall(searchText, callButton);
            }
          });
    } else {
      buttonPanel.remove(callButton);
    }
  }
Exemplo n.º 2
0
  // constructor of TextFrame
  public TextFrame() {
    // this.message = message;
    message = "Click to Edit Text";
    messageFont = new Font("Arial", Font.PLAIN, 30);
    foreground = Color.black;
    background = Color.white;

    // custom dialog (it's a private class inside TextFrame)
    cd = new CustomDialog(this);

    messageField = new JTextField();
    messageField.setPreferredSize(new Dimension(300, 200));
    messageField.setEditable(false);
    messageField.setHorizontalAlignment(SwingConstants.CENTER);
    messageField.setAlignmentX(Component.CENTER_ALIGNMENT);
    updateMessage();

    customize = new JButton("Customize");
    customize.setMaximumSize(customize.getPreferredSize());
    customize.setAlignmentX(Component.CENTER_ALIGNMENT);

    apply = new JButton("Apply");
    apply.setMaximumSize(customize.getPreferredSize());
    apply.setAlignmentX(Component.CENTER_ALIGNMENT);

    /*add the listeners*/
    customize.addActionListener(this);
    apply.addActionListener(this);
    messageField.addMouseListener(new PopUpClass());

    // customize
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(customize);
    p.add(Box.createRigidArea(new Dimension(0, 25)));
    p.add(messageField);
    p.add(Box.createRigidArea(new Dimension(0, 25)));
    p.add(apply);
    p.setBorder(BorderFactory.createEmptyBorder(25, 25, 25, 25));

    // make panel this JFrame's content pane

    this.setContentPane(p);
  }
  protected JToolBar createToolBar() {

    JToolBar jtoolbar = new JToolBar();

    jtoolbar.putClientProperty("JToolBar.isRollover", Boolean.TRUE);

    // ---------------------------------------
    JButton jbuttonClear = new JButton("Clear SQL Statement");

    jbuttonClear.setToolTipText("Clear SQL Statement");
    jbuttonClear.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent actionevent) {
            clear();
          }
        });

    // ---------------------------------------
    JButton jbuttonExecute = new JButton("Execute SQL Statement");

    jbuttonExecute.setToolTipText("Execute SQL Statement");
    jbuttonExecute.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent actionevent) {
            execute();
          }
        });
    jtoolbar.addSeparator();
    jtoolbar.add(jbuttonClear);
    jtoolbar.addSeparator();
    jtoolbar.add(jbuttonExecute);
    jtoolbar.addSeparator();
    jbuttonClear.setAlignmentY(0.5F);
    jbuttonClear.setAlignmentX(0.5F);
    jbuttonExecute.setAlignmentY(0.5F);
    jbuttonExecute.setAlignmentX(0.5F);

    return jtoolbar;
  }
Exemplo n.º 4
0
  private void initAddContactButton() {
    addButton.setAlignmentX(JButton.CENTER_ALIGNMENT);

    addButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.ADD_CONTACT"));

    buttonPanel.add(addButton);

    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            AddContactDialog dialog = new AddContactDialog(parentWindow);

            dialog.setContactAddress(parentWindow.getCurrentSearchText());
            dialog.setVisible(true);
          }
        });
  }
Exemplo n.º 5
0
  /** Creates an instance of <tt>SkinManagerPanel</tt>. */
  public SkinManagerPanel() {
    super(new BorderLayout());

    JPanel selectorPanel = new TransparentPanel();
    selectorPanel.setLayout(new BoxLayout(selectorPanel, BoxLayout.Y_AXIS));

    skinSelector.setAlignmentX(Component.CENTER_ALIGNMENT);
    skinSelector.addItemListener(new EnableDisableListener());
    selectorPanel.add(skinSelector);

    rmButton.setAlignmentX(Component.CENTER_ALIGNMENT);
    rmButton.addActionListener(new RemoveListener());
    selectorPanel.add(rmButton);

    enableDisableButton();

    add(selectorPanel, BorderLayout.NORTH);
  }
Exemplo n.º 6
0
  Primary() {
    // Initial declarations, adding of listeners, and database linking.
    // Database link
    DBHookUp db = new DBHookUp();

    // Frame stuff
    frame = new JFrame("4 Byte Warrior");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBackground(Color.RED);
    frame.setResizable(false);
    // Panels
    main = new JPanel();
    scores = new JPanel();
    credits = new JPanel();
    story = new JPanel();
    tutorial = new JPanel();
    main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS));
    main.setBackground(Color.RED);
    main.setOpaque(true);
    scores.setLayout(new BorderLayout());
    scores.setBackground(Color.RED);
    scores.setOpaque(true);
    credits.setLayout(new BorderLayout());
    credits.setBackground(Color.RED);
    credits.setOpaque(true);
    // story.setLayout(new BoxLayout(story, BoxLayout.PAGE_AXIS));
    story.setLayout(new BorderLayout());
    story.setBackground(Color.RED);
    story.setOpaque(true);
    // tutorial.setLayout(new BoxLayout(tutorial, BoxLayout.PAGE_AXIS));
    tutorial.setLayout(new BorderLayout());
    tutorial.setBackground(Color.RED);
    tutorial.setOpaque(true);

    // Buttons
    start = new JButton("Go");
    start.addActionListener(this);
    start.setPreferredSize(new Dimension(125, 35));
    start.setAlignmentX(start.CENTER_ALIGNMENT);
    start.setBackground(Color.BLACK);
    start.setForeground(Color.WHITE);
    start.setHorizontalAlignment(SwingConstants.CENTER);
    cred = new JButton("Credits");
    cred.setPreferredSize(new Dimension(125, 35));
    cred.addActionListener(this);
    cred.setAlignmentX(cred.CENTER_ALIGNMENT);
    cred.setBackground(Color.BLACK);
    cred.setForeground(Color.WHITE);
    cred.setHorizontalAlignment(SwingConstants.CENTER);
    high = new JButton("High Scores");
    high.addActionListener(this);
    high.setPreferredSize(new Dimension(125, 35));
    high.setAlignmentX(high.CENTER_ALIGNMENT);
    high.setBackground(Color.BLACK);
    high.setForeground(Color.WHITE);
    high.setHorizontalAlignment(SwingConstants.CENTER);
    stor = new JButton("Next");
    stor.addActionListener(this);
    stor.setPreferredSize(new Dimension(100, 35));
    stor.setAlignmentX(stor.CENTER_ALIGNMENT);
    stor.setBackground(Color.BLACK);
    stor.setForeground(Color.WHITE);
    stor.setHorizontalAlignment(SwingConstants.CENTER);
    tutor = new JButton("Play");
    tutor.addActionListener(this);
    tutor.setPreferredSize(new Dimension(100, 35));
    tutor.setAlignmentX(tutor.CENTER_ALIGNMENT);
    tutor.setBackground(Color.BLACK);
    tutor.setForeground(Color.WHITE);
    returns1 = new JButton("Return");
    returns1.addActionListener(this);
    returns1.setPreferredSize(new Dimension(100, 35));
    returns1.setAlignmentX(returns1.CENTER_ALIGNMENT);
    returns1.setBackground(Color.BLACK);
    returns1.setForeground(Color.WHITE);
    returns1.setHorizontalAlignment(SwingConstants.CENTER);
    returns2 = new JButton("Return");
    returns2.addActionListener(this);
    returns2.setPreferredSize(new Dimension(100, 35));
    returns2.setAlignmentX(returns2.CENTER_ALIGNMENT);
    returns2.setBackground(Color.BLACK);
    returns2.setForeground(Color.WHITE);
    returns2.setHorizontalAlignment(SwingConstants.CENTER);
    returns3 = new JButton("Return");
    returns3.addActionListener(this);
    returns3.setPreferredSize(new Dimension(100, 35));
    returns3.setAlignmentX(returns3.CENTER_ALIGNMENT);
    returns3.setBackground(Color.BLACK);
    returns3.setForeground(Color.WHITE);
    returns3.setHorizontalAlignment(SwingConstants.CENTER);
    returns4 = new JButton("Return");
    returns4.addActionListener(this);
    returns4.setPreferredSize(new Dimension(100, 35));
    returns4.setAlignmentX(returns4.CENTER_ALIGNMENT);
    returns4.setBackground(Color.BLACK);
    returns4.setForeground(Color.WHITE);
    returns4.setHorizontalAlignment(SwingConstants.CENTER);

    // Text display
    theme = new JLabel();
    String text =
        String.format(
            "<html><div style=\"width:%dpx;\"><center><font size = \"4\">%s</font></center></div><html>",
            300,
            "Binary was a land of peace, ruled by the good king Groshi. "
                + "One day, the Dark Knight and his armies descended upon "
                + "the kingdom, throwing it into chaos. The Dark Knight "
                + "killed Groshi and kidnapped his daughter Elsie. "
                + "Only one memember of the kingdom could hope to "
                + "save the kingdom...<br/><br/>"
                + "<font size = \"7\"> THE 4 BYTE WARRIOR </font>");
    theme.setText(text);
    theme.setHorizontalAlignment(JLabel.CENTER);
    theme.setVerticalAlignment(JLabel.CENTER);
    theme.setForeground(Color.WHITE);
    instruct = new JLabel();
    String instruction =
        String.format(
            "<html><div style=\"width:%dpx;\"><center>%s</center></div><html>",
            200,
            "Z Key: Attack<br/>X Key: Cycle through inventory<br/>D-Pad: Movement<br/>A: Pause<br/><br/><br/>Defeat the enemeies to advance. Fight the bosses, get through the 8 worlds of Binary, and save Princess Elsie.");
    instruct.setText(instruction);
    instruct.setHorizontalAlignment(JLabel.CENTER);
    instruct.setVerticalAlignment(JLabel.CENTER);
    instruct.setForeground(Color.WHITE);
    String names =
        String.format(
            "<html><div style=\"width:%dpx;\"><center>%s</center></div><html>",
            150, "Alexander Friebe<br/>Charles Heckel<br/>Nicholas Lindsley<br/>Ben McWerthy<br/>");
    people = new JLabel(names);
    people.setHorizontalAlignment(JLabel.CENTER);
    people.setVerticalAlignment(JLabel.CENTER);
    people.setForeground(Color.WHITE);
    String major =
        String.format(
            "<html><div style=\"width:%dpx;\"><center>%s</center></div><html>",
            150,
            "Computer Science<br/>Computer Engineering<br/>Computer Engineering<br/>Computer Science<br/>");
    majors = new JLabel(major);
    majors.setHorizontalAlignment(JLabel.CENTER);
    majors.setVerticalAlignment(JLabel.CENTER);
    majors.setForeground(Color.WHITE);
    String credi =
        String.format(
            "<html><div style=\"width:%dpx;\"><center><font size = \"4\">%s</font></center></div><html>",
            150, "Credits");
    top = new JLabel(credi);
    top.setHorizontalAlignment(JLabel.CENTER);
    top.setVerticalAlignment(JLabel.CENTER);
    top.setForeground(Color.WHITE);
    scoresTop = new JLabel();
    String scTop =
        String.format(
            "<html><div style=\"width:%dpx;\"><center><font size = \"4\">%s</font></center></div><html>",
            200, "High Scores for Enemies Killed");
    scoresTop.setText(scTop);
    scoresTop.setForeground(Color.WHITE);
    scoresTop.setHorizontalAlignment(JLabel.CENTER);
    scoresTop.setVerticalAlignment(JLabel.CENTER);
    JLabel dbScores = new JLabel();
    ArrayList<Integer> sc = db.getScores();
    System.out.println(sc.size());
    // System.out.println(sc.get(0));
    String actual =
        String.format(
            "<html><div style=\"width:%dpx;\"><center><font size = \"4\">%s</font></center></div><html>",
            100, sc.get(0) + "<br/>" + sc.get(1) + "<br/>" + sc.get(2) + "<br/>");
    dbScores.setText(actual);
    dbScores.setHorizontalAlignment(JLabel.CENTER);
    dbScores.setVerticalAlignment(JLabel.CENTER);
    dbScores.setForeground(Color.WHITE);

    // Additions to main
    mainButtons = new JPanel(new GridLayout(3, 1));
    mainButtons.add(start);
    mainButtons.add(high);
    mainButtons.add(cred);
    main.add(mainButtons);

    // Additions to credits
    credits.add(top, BorderLayout.PAGE_START);
    // credits.add(people, BorderLayout.LINE_START);
    // credits.add(majors, BorderLayout.LINE_END);
    JPanel middle = new JPanel(new GridLayout(1, 2));
    middle.add(people);
    middle.add(majors);
    middle.setBackground(Color.RED);
    JPanel bottom = new JPanel(new GridLayout(1, 1));
    bottom.add(returns2);
    bottom.setBackground(Color.RED);
    credits.add(middle, BorderLayout.CENTER);
    credits.add(bottom, BorderLayout.PAGE_END);

    // Additions to high scores
    scores.add(scoresTop, BorderLayout.PAGE_START);
    scores.add(dbScores, BorderLayout.CENTER);
    JPanel bot = new JPanel(new GridLayout(1, 1));
    bot.add(returns1);
    bot.setBackground(Color.RED);
    scores.add(bot, BorderLayout.PAGE_END);

    // Additions to story
    story.add(theme, BorderLayout.CENTER);
    buttons = new JPanel(new GridLayout(2, 1));
    buttons.setBackground(Color.RED);
    // buttons.setOpaque(true);
    buttons.add(stor);
    buttons.add(returns3);
    story.add(buttons, BorderLayout.PAGE_END);

    // Additions to tutorial
    JPanel tutButtons = new JPanel(new GridLayout(2, 1));
    tutorial.add(instruct, BorderLayout.CENTER);
    tutButtons.add(tutor);
    tutButtons.add(returns4);
    tutButtons.setBackground(Color.RED);
    tutorial.add(tutButtons, BorderLayout.PAGE_END);

    main.setBorder(new EmptyBorder(100, 150, 100, 150));
    bot.setBorder(new EmptyBorder(0, 150, 0, 150));
    // middle.setBorder(new EmptyBorder(0,150,0,150));
    bottom.setBorder(new EmptyBorder(0, 150, 0, 150));
    buttons.setBorder(new EmptyBorder(0, 150, 0, 150));
    tutButtons.setBorder(new EmptyBorder(0, 150, 0, 150));
    frame.add(main);

    frame
        .pack(); // critical to call before you make the window visible in order to make everything
                 // look right 100% of the time
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
 /**
  * Constructor to setup GUI components and event handling; Pre: null; Post: the safety questions
  * will be set and stored into database.
  */
 public GUISafetyQues() {
   frame = new JFrame("Safety Questions");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   contentPane = new JPanel();
   contentPane.setLayout(
       new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); // To use BoxLayout to line items up
   contentPane.setBorder(
       BorderFactory.createEmptyBorder(10, 10, 10, 10)); // Create empty borders around items
   ques1 = new JLabel(CustInfo.safetyQues[0]);
   ques1.setFont(f); // To keep the font of texts on items the same
   ques1.setAlignmentX(
       JLabel.CENTER_ALIGNMENT); // To line the items up at the centre of the window
   ques1.setBorder(BorderFactory.createEmptyBorder(5, 12, 5, 12));
   ques2 = new JLabel(CustInfo.safetyQues[1]);
   ques2.setFont(f);
   ques2.setAlignmentX(JLabel.CENTER_ALIGNMENT);
   ques2.setBorder(BorderFactory.createEmptyBorder(5, 12, 5, 12));
   ques3 = new JLabel(CustInfo.safetyQues[2]);
   ques3.setFont(f);
   ques3.setAlignmentX(JLabel.CENTER_ALIGNMENT);
   ques3.setBorder(BorderFactory.createEmptyBorder(5, 12, 5, 12));
   info = new JLabel("Please answer the three safety questions below: ");
   info.setFont(f);
   info.setAlignmentX(JLabel.CENTER_ALIGNMENT);
   info.setBorder(BorderFactory.createEmptyBorder(5, 12, 5, 12));
   as1 = new JTextField(40);
   as1.setEditable(true); // To allow the textfield to be editted
   as2 = new JTextField(40);
   as2.setEditable(true);
   as3 = new JTextField(40);
   as3.setEditable(true);
   warning = new JLabel("Please provide an unique answer to each question.");
   warning.setAlignmentX(JLabel.CENTER_ALIGNMENT);
   warning.setBorder(BorderFactory.createEmptyBorder(5, 12, 5, 12));
   nullWarning = new JLabel("The answers should be longer than 3 characters.");
   nullWarning.setAlignmentX(JLabel.CENTER_ALIGNMENT);
   nullWarning.setBorder(BorderFactory.createEmptyBorder(5, 12, 5, 12));
   finish = new JButton("Save");
   finish.setFont(f);
   finish.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           String ans1 = as1.getText();
           String ans2 = as2.getText();
           String ans3 = as3.getText();
           if (ans1.length() < 3 || ans2.length() < 3 || ans3.length() < 3) {
             frame.setVisible(false);
             frame.remove(warning);
             frame.add(nullWarning);
             frame.setSize(480, 310);
             frame.setVisible(true);
           } else {
             if (ans1.equals(ans2) || ans2.equals(ans3) || ans1.equals(ans3)) {
               frame.setVisible(false);
               frame.remove(nullWarning);
               frame.add(warning);
               frame.setSize(480, 310);
               frame.setVisible(true);
             } else {
               GUIUserOpen.up.addCust(
                   GUIUserOpen.UserID,
                   GUIUserOpen
                       .password); // If the user finished safety questions, add the customer in
               GUIUserOpen.engine.SafetyQuestion(
                   ans1, ans2, ans3); // To write the answers into file
               frame.setVisible(false);
               GUIUserOpen open =
                   new GUIUserOpen(true); // Go to main page to let the user log in
             }
           }
         }
       });
   finish.setAlignmentX(JLabel.CENTER_ALIGNMENT);
   finish.setBorder(BorderFactory.createEmptyBorder(5, 12, 5, 12));
   setNull = new JButton("Clean");
   setNull.setFont(f);
   setNull.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           frame.setVisible(false); // Close the current window
           GUISafetyQues que =
               new GUISafetyQues(); // Create a new window for enter the answers again
         }
       });
   setNull.setAlignmentX(JLabel.CENTER_ALIGNMENT);
   setNull.setBorder(BorderFactory.createEmptyBorder(5, 12, 5, 12));
   contentPane.add(info);
   contentPane.add(ques1);
   contentPane.add(as1);
   contentPane.add(ques2);
   contentPane.add(as2);
   contentPane.add(ques3);
   contentPane.add(as3);
   contentPane.add(finish);
   contentPane.add(setNull);
   frame.setContentPane(contentPane);
   frame.pack();
   frame.setVisible(true); // Open the pop-up window
   frame.setLocationRelativeTo(
       null); // Set the location of the pop-up window at the centre of the computer
 }
 /**
  * Constructor to setup GUI components and event handling; Pre: name, author and theme should not
  * be null, avg and pop should not be 0; Post: the user will successfully rate the book.
  *
  * @param bookName is the name of the book.
  * @param author is the author of the book.
  * @param genre is the genre of the book.
  * @param avg is the average score of the book.
  * @param pop is the population of people that have rated the book.
  */
 public GUIBookRating(String bookName, String author, String genre, int avg, int pop) {
   frame = new JFrame("Book Rating");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   contentPane = new JPanel();
   contentPane.setLayout(
       new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); // To use BoxLayout to keep items in order
   contentPane.setBorder(
       BorderFactory.createEmptyBorder(10, 10, 10, 10)); // To create an empty border around items
   label = new JLabel("Please give rank to the book " + bookName + ":");
   label.setFont(f); // To keep the font of texts on items the same
   label.setAlignmentX(
       JLabel.CENTER_ALIGNMENT); // To line the items up at the centre of the window
   label.setBorder(BorderFactory.createEmptyBorder(5, 12, 5, 12));
   submit = new JButton("Submit");
   submit.setFont(f);
   submit.setAlignmentX(JLabel.CENTER_ALIGNMENT);
   submit.setBorder(BorderFactory.createEmptyBorder(5, 12, 5, 12));
   rankStop = new JButton("Not Now");
   rankStop.setFont(f);
   rankStop.setAlignmentX(JLabel.CENTER_ALIGNMENT);
   rankStop.setBorder(BorderFactory.createEmptyBorder(5, 12, 5, 12));
   String[] list = {
     "1 Awful >_<", "2 Bad T_T", "3 So So -_-", "4 Good ^_^", "5 Perfect ^3^"
   }; // To create a list for user to choose rate from 1 to 5
   ratingList = new JComboBox(list);
   ratingList.setAlignmentX(JComboBox.CENTER_ALIGNMENT);
   ratingList.setSelectedIndex(0); // Set the original rate to be 1
   submit.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           String rankGet = (String) ratingList.getSelectedItem();
           /*To transfer the rate user chosen in the combobox to the number of rankings in the database*/
           if (rankGet.equalsIgnoreCase("1 Awful >_<")) {
             engine.rankGive(bookName, 1);
             GUILogOut out =
                 new GUILogOut(
                     String.valueOf(1), String.valueOf(avg), engine.customerBasedRec(bookName));
           } else if (rankGet.equalsIgnoreCase("2 Bad T_T")) {
             engine.rankGive(bookName, 2);
             GUILogOut out =
                 new GUILogOut(
                     String.valueOf(2), String.valueOf(avg), engine.customerBasedRec(bookName));
           } else if (rankGet.equalsIgnoreCase("3 So So -_-")) {
             engine.rankGive(bookName, 3);
             GUILogOut out =
                 new GUILogOut(
                     String.valueOf(3), String.valueOf(avg), engine.customerBasedRec(bookName));
           } else if (rankGet.equalsIgnoreCase("4 Good ^_^")) {
             engine.rankGive(bookName, 4);
             GUILogOut out =
                 new GUILogOut(
                     String.valueOf(4), String.valueOf(avg), engine.bookBasedRec(bookName));
           } else {
             engine.rankGive(bookName, 5);
             GUILogOut out =
                 new GUILogOut(
                     String.valueOf(5), String.valueOf(avg), engine.bookBasedRec(bookName));
           }
           frame.setVisible(false); // Close the window after going to the next step
         }
       });
   rankStop.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           GUIBookInfo info =
               new GUIBookInfo(
                   bookName,
                   author,
                   genre,
                   avg,
                   pop,
                   custrating); // To review the information of the book if the user do not want to
                                // rate the book
           frame.setVisible(false);
         }
       });
   contentPane.add(label);
   contentPane.add(ratingList);
   contentPane.add(submit);
   contentPane.add(rankStop);
   frame.setContentPane(contentPane);
   frame.pack();
   frame.setVisible(true); // Open the pop-up window
   frame.setLocationRelativeTo(
       null); // Set the location of the pop-up window at the centre of the window of computer
 }
Exemplo n.º 9
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