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

    famList.addAll(ctxt.familyCensus); //  end of filtering deleted records
    plur = (famList.size() == 1 ? "y" : "ies");
    famLabel = new JLabel("Contains " + famList.size() + " Famil" + plur);
    famLabel.setAlignmentX(0.5f);
    populationBox.add(Box.createRigidArea(new Dimension(0, 4)));
    populationBox.add(famLabel);
    if (famList.size() > 0) {
      JPanel famBtnBox = new JPanel();
      famBtnBox.setLayout(new BoxLayout(famBtnBox, BoxLayout.LINE_AXIS));
      Dimension sizer2 = new Dimension(350, 50);
      String[] famMenu = genFamMenu(famList);
      famPick = new JComboBox(famMenu);
      famPick.addActionListener(listener);
      famPick.setActionCommand("view/edit family");
      famPick.setMinimumSize(sizer2);
      famPick.setMaximumSize(sizer2);
      famPick.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createLineBorder(Color.blue), "View/Edit Family"));
      famBtnBox.add(famPick);
      populationBox.add(famBtnBox);
    } //  end of if-any-families-exist
    rebuilding = false;
  } //  end of method buildPopulationBox
Ejemplo n.º 2
0
  public DetectiveNotes(ArrayList<Card> cards) {
    // Sets the standard window information
    this.setLayout(new GridLayout(0, 2));
    setTitle("Detective Notes");
    setSize(600, 700);

    // Initialize the lists
    playerList = new ArrayList<String>();
    weaponList = new ArrayList<String>();
    roomList = new ArrayList<String>();

    // Adds an "unsure" option to each list
    playerList.add("Unsure");
    weaponList.add("Unsure");
    roomList.add("Unsure");

    // Reads the card names out of the file, storing it in the appropriate list
    for (Card card : cards) {
      if (card.getCardType() == CardType.PERSON) playerList.add(card.getName());
      else if (card.getCardType() == CardType.WEAPON) weaponList.add(card.getName());
      else if (card.getCardType() == CardType.ROOM) roomList.add(card.getName());
    }

    // Sets up the selection boxes for the people, weapons, and rooms
    JPanel people = new JPanel();
    people.setBorder(new TitledBorder(new EtchedBorder(), "People"));
    JComboBox PeopleCombo = new JComboBox(playerList.toArray());
    PeopleCombo.setBorder(new TitledBorder(new EtchedBorder(), "People Guess"));

    JPanel weapons = new JPanel();
    weapons.setBorder(new TitledBorder(new EtchedBorder(), "Weapons"));
    JComboBox WeaponsCombo = new JComboBox(weaponList.toArray());
    WeaponsCombo.setBorder(new TitledBorder(new EtchedBorder(), "Weapons Guess"));

    JPanel rooms = new JPanel();
    rooms.setBorder(new TitledBorder(new EtchedBorder(), "Rooms"));
    JComboBox RoomsCombo = new JComboBox(roomList.toArray());
    RoomsCombo.setBorder(new TitledBorder(new EtchedBorder(), "Rooms Guess"));

    // Adds the player information to the JFrame
    addPlayerCheckboxes(people);
    add(people);
    add(PeopleCombo);

    // Adds the weapon information to the JFrame
    addWeaponCheckboxes(weapons);
    add(weapons);
    add(WeaponsCombo);

    // Adds the room information to the JFrame
    addRoomCheckboxes(rooms);
    add(rooms);
    add(RoomsCombo);
  }
Ejemplo n.º 3
0
  public void refreshSupplier(boolean remove) {

    if (remove) panel.remove(supplierCombo);

    try {
      model =
          new DefaultComboBoxModel(
              Manager.getInstance().getSupplierManager().getSuppliers().toArray());
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    supplierCombo = new JComboBox(model);
    supplierCombo.setUI(ColorArrowUI.createUI(this));
    supplierCombo.setEditable(true);
    supplierComboField = (JTextField) supplierCombo.getEditor().getEditorComponent();
    supplierComboField.setText("");
    supplierComboField.setOpaque(false);
    supplierComboField.setBorder(BorderFactory.createEmptyBorder());
    supplierComboField.addKeyListener(new ComboKeyHandler(supplierCombo));

    supplierCombo.setFont(new Font("Arial Narrow", Font.PLAIN, 14));
    supplierCombo.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.BLACK));
    supplierCombo.setOpaque(false);

    supplierCombo.setSelectedIndex(-1);

    supplierCombo.setVisible(supplierLabel.isVisible());

    supplierCombo.setBounds(85, 56, 220, 20);

    panel.add(supplierCombo);
  }
  public StructureFunctionCellEditor() {
    eventListenerList = new EventListenerList();
    this.dataAttributeContext = new DefaultDataAttributeContext();

    final EllipsisButton ellipsisButton = new EllipsisButton("...");
    ellipsisButton.addActionListener(new ExtendedEditorAction());

    expressionEditor = new SmartComboBox<ExpressionMetaData>();
    expressionEditor.setEditable(false);
    expressionEditor.setEditor(
        new ValuePassThroughCellEditor(expressionEditor, new ExpressionListCellRenderer()));
    expressionEditor.setRenderer(new ExpressionListCellRenderer());
    expressionEditor
        .getInputMap()
        .put(
            UtilMessages.getInstance()
                .getKeyStroke("PropertyCellEditorWithEllipsis.PopupEditor.Accelerator"),
            POPUP_EDITOR);
    expressionEditor.getActionMap().put(POPUP_EDITOR, new ExtendedEditorAction());
    expressionEditor.setBorder(BorderFactory.createEmptyBorder());

    carrierPanel = new JPanel(new BorderLayout());
    carrierPanel.add(expressionEditor, BorderLayout.CENTER);
    carrierPanel.add(ellipsisButton, BorderLayout.EAST);
  }
 private JComboBox getCbx() {
   if (myCbx == null) {
     myCbx = new JComboBox(myPairs);
     myCbx.setBorder(BorderFactory.createEmptyBorder());
     myCbx.addPopupMenuListener(new MyPopupMenuListener());
   }
   return myCbx;
 }
Ejemplo n.º 6
0
 private JComboBox getJComboBox1() {
   if (jComboBox1 == null) {
     jComboBox1 = new JComboBox();
     jComboBox1.setModel(new DefaultComboBoxModel(new Object[] {"GB2312", "UTF-8", "ASCII"}));
     jComboBox1.setDoubleBuffered(false);
     jComboBox1.setBorder(null);
   }
   return jComboBox1;
 }
Ejemplo n.º 7
0
 private JComboBox getJComboBox0() {
   if (jComboBox0 == null) {
     jComboBox0 = new JComboBox();
     jComboBox0.setModel(new DefaultComboBoxModel(new Object[] {",", ";", "space", "tab"}));
     jComboBox0.setDoubleBuffered(false);
     jComboBox0.setBorder(null);
   }
   return jComboBox0;
 }
Ejemplo n.º 8
0
 private void initJComboBox(JComboBox jcb) {
   jcb.setSize(120, 20);
   jcb.setOpaque(false);
   jcb.setFocusable(false);
   jcb.setRenderer(new StarComboBoxRender());
   jcb.setUI((ComboBoxUI) StarComboBoxUI.createUI(jcb));
   jcb.setBorder(new RoundBorder(Color.red));
   add(jcb);
 }
Ejemplo n.º 9
0
 private void initializeField() {
   field.addItemListener(
       new java.awt.event.ItemListener() {
         @Override
         public void itemStateChanged(java.awt.event.ItemEvent evt) {
           fieldItemStateChanged(evt);
         }
       });
   field.setFont(new Font("Arial", Font.ITALIC, 9));
   field.setBorder(null);
 }
Ejemplo n.º 10
0
 private JComboBox getJComboBoxSize() {
   if (jComboBoxSize == null) {
     jComboBoxSize = new JComboBox();
     jComboBoxSize.setModel(new DefaultComboBoxModel(new Integer[] {5, 6, 7, 8}));
     jComboBoxSize.setDoubleBuffered(false);
     jComboBoxSize.setBorder(null);
     jComboBoxSize.addItemListener(
         new ItemListener() {
           @Override
           public void itemStateChanged(ItemEvent arg0) {
             boardSize = (Integer) jComboBoxSize.getItemAt(jComboBoxSize.getSelectedIndex());
           }
         });
   }
   return jComboBoxSize;
 }
Ejemplo n.º 11
0
 private JComboBox getJComboBoxRow() {
   if (jComboBoxRow == null) {
     jComboBoxRow = new JComboBox();
     jComboBoxRow.setModel(
         new DefaultComboBoxModel(new String[] {"1", "2", "3", "4", "5", "6", "7", "8"}));
     jComboBoxRow.setDoubleBuffered(false);
     jComboBoxRow.setBorder(null);
     jComboBoxRow.addItemListener(
         new ItemListener() {
           @Override
           public void itemStateChanged(ItemEvent arg0) {
             knightRow = jComboBoxRow.getSelectedIndex();
           }
         });
   }
   return jComboBoxRow;
 }
Ejemplo n.º 12
0
 private JComboBox getJComboBoxColumn() {
   if (jComboBoxColumn == null) {
     jComboBoxColumn = new JComboBox();
     jComboBoxColumn.setModel(
         new DefaultComboBoxModel(new String[] {"a", "b", "c", "d", "e", "f", "g", "h"}));
     jComboBoxColumn.setDoubleBuffered(false);
     jComboBoxColumn.setBorder(null);
     jComboBoxColumn.addItemListener(
         new ItemListener() {
           @Override
           public void itemStateChanged(ItemEvent arg0) {
             knightColumn = jComboBoxColumn.getSelectedIndex();
           }
         });
   }
   return jComboBoxColumn;
 }
  private void setLinieComboBox() {
    Vector<String> linie = null;
    if (dbConnection != null) {
      linie = dbConnection.getBuses();
    }
    linieComboBox = new JComboBox(linie);
    TitledBorder tr = BorderFactory.createTitledBorder("Linia");
    linieComboBox.setBorder(tr);
    linieComboBox.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            String liniaString = (String) linieComboBox.getSelectedItem();
            setLinia(liniaString);
            frame.setTitle("Szczegóły linii " + liniaString);
            updateKierunekComboBox();
            updatePrzystankiScrollPane();
            updateRozkladScrollPane();
          }
        });
  }
  private void setKierunekComboBox() {
    Vector<String> kierunki = new Vector<String>();
    if (linia != null) {
      for (Trasa t : linia.getTrasy()) {
        kierunki.add(t.getKierunek());
      }
    }
    kierunkiComboBox = new JComboBox(kierunki);
    TitledBorder tr = BorderFactory.createTitledBorder("Kierunek");
    kierunkiComboBox.setBorder(tr);
    kierunkiComboBox.setPreferredSize(new Dimension(300, 50));
    kierunkiComboBox.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            String kierunekString = (String) kierunkiComboBox.getSelectedItem();
            trasa = linia.getTrasa(kierunekString);
            updatePrzystankiScrollPane();
            updateRozkladScrollPane();
          }
        });
  }
Ejemplo n.º 15
0
  private void build() {
    // ============= le panel du dialog
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    // ================================
    catBox = new JComboBox(categories);
    catBox.setMinimumSize(new Dimension(150, 60));
    catBox.setMaximumSize(new Dimension(2000, 80));
    catBox.setBorder(BorderFactory.createTitledBorder("TYPE"));
    catBox.addFocusListener(this);
    panel.add(catBox);

    // ========= Le nom du nouveau media
    nameField.setMinimumSize(new Dimension(150, 60));
    nameField.setMaximumSize(new Dimension(2000, 80));
    nameField.setBorder(BorderFactory.createTitledBorder("NAME"));
    nameField.addFocusListener(this);
    nameField.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            nameField.selectAll();
          }

          public void focusLost(FocusEvent e) {}
        });
    panel.add(nameField);

    // ========== La release date par default
    dateChooser.setMinimumSize(new Dimension(150, 60));
    dateChooser.setMaximumSize(new Dimension(2000, 80));
    dateChooser.setFormats(UiConfig.getProperty(UiConfig.LONG_DATE_FORMAT));
    dateChooser.setDate(new Date());
    dateChooser.setBorder(BorderFactory.createTitledBorder("RELEASE DATE"));
    panel.add(dateChooser);

    // ============
    formatField.setMinimumSize(new Dimension(150, 60));
    formatField.setMaximumSize(new Dimension(2000, 80));
    formatField.setBorder(BorderFactory.createTitledBorder("FORMAT(experimental)"));
    formatField.addFocusListener(this);
    formatField.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            formatField.selectAll();
          }

          public void focusLost(FocusEvent e) {}
        });
    panel.add(formatField);

    // ============ Le bouton ok
    okButton.setActionCommand("CREATE");
    okButton.setToolTipText("Create " + catBox.getSelectedItem() + " " + nameField.getText());
    okButton.addActionListener(this);
    Icon icon1 = ThemeIcon.SAVE.d32x32();
    if (icon1 != null) {
      okButton.setText("");
      okButton.setIcon(icon1);
    }

    // =========== Le bouton cancel
    cancelButton.setActionCommand("CANCEL");
    cancelButton.addActionListener(this);
    cancelButton.setToolTipText("Cancel");
    Icon icon2 = ThemeIcon.CANCEL.d32x32();
    if (icon2 != null) {
      cancelButton.setText("");
      cancelButton.setIcon(icon2);
    }

    // =========== La toolBar
    toolBar.add(okButton);
    toolBar.add(cancelButton);
    panel.add(new JLabel());
    panel.add(toolBar);
    toolBar.setAlignmentX(CENTER_ALIGNMENT);
  }
  public Design() throws Exception {
    super.setBackground(Color.BLACK);
    this.setTitle("");
    con = getContentPane();
    con.setLayout(null);
    dim = tk.getDefaultToolkit().getScreenSize();
    this.setTitle("Customer Peer Login");

    l1 = new JLabel(new ImageIcon("plain.jpg"));
    l1.setBounds(0, 0, 400, 400);
    con.add(l1);
    l1.setBorder(BorderFactory.createEtchedBorder(5, Color.black, Color.black));

    title = new JLabel("CUSTOMER PEER LOGIN ");
    title.setFont(new Font("Bookman Old Style", Font.ROMAN_BASELINE, 20));
    title.setForeground(Color.red);
    title.setBounds(80, 30, 300, 30);
    l1.add(title);

    l4 = new JLabel("CMACHINE NAME");
    l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l4.setForeground(Color.BLUE);
    l4.setBounds(70, 100, 160, 20);
    //	l4.setBorder(BorderFactory.createEtchedBorder(5,Color.green,Color.green));

    l1.add(l4);
    jtf2 = new JTextField();
    jtf2.setBounds(250, 100, 100, 20);
    jtf2.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));

    l1.add(jtf2);

    l2 = new JLabel("CUSER LOGIN");
    l2.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l2.setForeground(Color.blue);
    l2.setBounds(70, 150, 120, 20);
    l1.add(l2);

    jtf1 = new JTextField();
    jtf1.setBounds(250, 150, 100, 20);
    jtf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));

    l1.add(jtf1);

    l3 = new JLabel("CPASSWORD");
    l3.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l3.setForeground(Color.blue);
    l3.setBounds(70, 200, 120, 20);
    l1.add(l3);

    jptf1 = new JPasswordField();
    jptf1.setBounds(250, 200, 100, 20);
    jptf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));

    l1.add(jptf1);

    JLabel l4 = new JLabel("DAgent");
    l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l4.setForeground(Color.blue);
    l4.setBounds(70, 250, 120, 20);
    l1.add(l4);

    box = new JComboBox();
    box.setBounds(250, 250, 100, 20);
    box.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));
    l1.add(box);

    b2 = new JButton("Register");
    b2.setBounds(50, 300, 100, 20);
    l1.add(b2);
    b2.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE));

    b3 = new JButton("Login");
    b3.setBounds(150, 300, 100, 20);
    b3.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE));
    l1.add(b3);

    b1 = new JButton("Cancel");
    b1.setBounds(250, 300, 100, 20);
    b1.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE));

    l1.add(b1);

    b1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent we) {

            dispose();
          }
        });

    try {

      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      conn = DriverManager.getConnection("jdbc:odbc:agent");

    } catch (Exception exp) {

    }

    try {
      Statement satem = conn.createStatement();
      ResultSet rsatem = satem.executeQuery("select * from Dagent");
      while (rsatem.next()) {
        String namem = rsatem.getString("uname");
        box.addItem(namem);
      }

    } catch (Exception expo1) {

    }

    b2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent we) {

            String username = jtf1.getText().trim();
            String password = jptf1.getText().trim();
            String mechine = jtf2.getText().trim();
            String dname = box.getSelectedItem().toString();
            int porte = 0;

            try {
              Statement sate = conn.createStatement();
              ResultSet rsate =
                  sate.executeQuery("select * from Dagent where uname='" + dname + "'");
              if (rsate.next()) {
                servermachine = rsate.getString("umechine");
                porte = rsate.getInt("ulistport");
                System.out.println(servermachine);
              }
              System.out.println(servermachine);

            } catch (Exception exp) {
              exp.printStackTrace();
            }

            try {
              packet p = new packet();
              p.setaction("Creg");
              p.setCuser(username);
              p.setCpass(password);
              p.setCmname(mechine);
              p.setCDpeer(dname);
              Socket soc = new Socket(servermachine, porte);
              ObjectOutputStream out = new ObjectOutputStream(soc.getOutputStream());
              out.writeObject(p);
              ObjectInputStream in = new ObjectInputStream(soc.getInputStream());
              packet rpac = (packet) in.readObject();
              if (rpac.getaction().equals("ok")) {

                JOptionPane.showMessageDialog(null, "Sucessfully Registered");

                jtf2.setText("");
                jtf1.setText("");
                jptf1.setText("");

              } else {

                JOptionPane.showMessageDialog(null, "Already Registered");
                jtf2.setText("");
                jtf1.setText("");
                jptf1.setText("");
              }

            } catch (Exception exp) {
            }
          }
        });

    b3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent we) {

            String username = jtf1.getText().trim();
            String password = jptf1.getText().trim();
            String mechine = jtf2.getText().trim();
            String Dname = box.getSelectedItem().toString();

            int porte = 0;

            try {
              Statement sate = conn.createStatement();
              ResultSet rsate =
                  sate.executeQuery("select * from Dagent where uname='" + Dname + "'");
              if (rsate.next()) {
                servermachine = rsate.getString("umechine");
                porte = rsate.getInt("ulistport");
                System.out.println(servermachine);
              }
              System.out.println(servermachine);

            } catch (Exception exp) {

            }

            try {

              packet p1 = new packet();
              p1.setaction("clogin");
              p1.setCuser(username);
              p1.setCpass(password);
              p1.setCmname(mechine);
              p1.setCDpeer(Dname);
              Socket soc1 = new Socket(servermachine, porte);
              ObjectOutputStream out1 = new ObjectOutputStream(soc1.getOutputStream());
              out1.writeObject(p1);
              ObjectInputStream in1 = new ObjectInputStream(soc1.getInputStream());
              packet rpac1 = (packet) in1.readObject();
              if (rpac1.getaction().equals("ok")) {
                int port1 = 0;
                try {

                  int portm = rpac1.getCport();
                  System.out.println("XXXXXXX" + portm);
                  //	JOptionPane.showMessageDialog(null,"Sucessfully Started");

                  new Listen(portm);
                  new process(username, portm);
                  dispose();
                } catch (Exception exp) {
                }
              } else {
                JOptionPane.showMessageDialog(
                    null, "Enter valid username and password", "Server reply", 2);
                jtf1.setText("");
                jtf2.setText("");
                jptf1.setText("");
              }

            } catch (Exception exp) {
            }
          }
        });

    setSize(400, 400);
    show();
    setLocation(150, 100);
    setResizable(false);
  }
Ejemplo n.º 17
0
  /** Initialize the contents of the frame. */
  private void initialize(String integer) {
    frame = new JDialog(mainFrame, true);
    frame.setTitle(integer);
    frame.setBounds(100, 100, 450, 300);
    frame.setBounds( // 让新窗口与Swing7窗口示例错开50像素。
        new Rectangle(
            (int) frame.getBounds().getX() + 50,
            (int) frame.getBounds().getY() + 50,
            (int) frame.getBounds().getWidth(),
            (int) frame.getBounds().getHeight()));

    JPanel panel = new JPanel();
    frame.getContentPane().add(panel, BorderLayout.NORTH);
    //		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel v1 = new JPanel();
    panel.add(v1);

    v1.setLayout((LayoutManager) new FlowLayout(FlowLayout.CENTER, 5, 5));

    final JComboBox comboBox_target = new JComboBox(); // 故障类型选择
    comboBox_target.setBorder(
        new TitledBorder(null, "故障目标:", TitledBorder.LEADING, TitledBorder.BELOW_TOP, null, null));
    comboBox_target.setModel(new DefaultComboBoxModel(new String[] {"内存注入", "CPU", "I/O", "bus"}));
    comboBox_target.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            System.out.println(comboBox_target.getSelectedItem()); // 将参数传递给“故障开始时间参数”

            target = comboBox_target.getSelectedIndex();
            // comboBox_1.
            switch (target) {
              case 0:
                object = new MemWave();
                System.out.println("mem ready");
                break;

              case 1:
                object = new CpuWave();
                System.out.println("cpu ready");
                break;
              case 2:
                object = new IOWave();
                System.out.println("Io ready");
                break;
              case 3:
                object = new BusWave();
                System.out.println("bus ready");
                break;

              default:
                break;
            }
          }
        });

    v1.add(comboBox_target);

    final JComboBox comboBox_type = new JComboBox();
    comboBox_type.setBorder(
        new TitledBorder(null, "故障类型:", TitledBorder.LEADING, TitledBorder.BELOW_TOP, null, null));
    comboBox_type.setModel(new DefaultComboBoxModel(new String[] {"线性增加", "指数增加", "恒定值", "正弦变化"}));
    comboBox_type.setToolTipText("\u7EBF\u6027b\r\n");

    comboBox_type.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            System.out.println(comboBox_type.getSelectedItem());
            type = comboBox_type.getSelectedIndex();
          }
        });
    v1.add(comboBox_type);

    JButton button = new JButton("\u786E\u5B9A");
    v1.add(button);
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // CpuWave cpuWave= new CpuWave();

            try {
              //					CpuWave cpuWave = new CpuWave();
              //
              //					String string="第"+i+"个阶段";
              //					i=i++;
              //
              //					mainFrame.map.put(string, cpuWave);
              //					frame.dispatchEvent(new WindowEvent(frame,WindowEvent.WINDOW_CLOSING) );
              //					System.out.println(mainFrame.map);
              //					for (String key : mainFrame.map.keySet()) {
              //
              //					    Object value = mainFrame.map.get(key);
              //
              //					    System.out.println("Key = " + key +"ddd"+value.toString());
              //
              //					}
              //					mainFrame.fillPList();
              //
            } catch (Exception e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
            }
          }
        });

    JButton button_1 = new JButton("\u53D6\u6D88");
    v1.add(button_1);

    JLabel lblNewLabel = new JLabel();
    frame.getContentPane().add(lblNewLabel, BorderLayout.SOUTH);

    button_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            Console console = new Console();
            //				CpuWave cpuWave = new CpuWave();
            mainFrame.bObjects.add(object);
            frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
            mainFrame.fillPList();
            Iterator<Object> iter = mainFrame.bObjects.iterator();

            while (iter.hasNext()) {
              System.out.println(iter.next().toString());
            }
          }
        });
  }
Ejemplo n.º 18
0
  private void initializePanel() {
    visPanel = new VisPanel();
    visPanel.setBackground(Color.white);
    visPanel.setForeground(Color.darkGray);

    JPanel mainPanel = (JPanel) appFrame.getContentPane();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(visPanel, BorderLayout.CENTER);

    // Add two JComboBoxs for x and y axis and set up the action listeners
    jbX = new JComboBox<String>(columnNamestring);
    jbX.setEnabled(true);
    jbX.setBorder(BorderFactory.createTitledBorder("Choose X-axis"));

    ActionListener xListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            x_index = columnNames.indexOf(jbX.getSelectedItem());
            maxminXY = new Double[] {max[x_index], min[x_index], max[y_index], min[y_index]};

            float xValues[] = new float[rows.size()];
            float yValues[] = new float[rows.size()];
            float zValues[] = new float[rows.size()];

            for (int irow = 0; irow < rows.size(); irow++) {
              ArrayList<Double> row = rows.get(irow);
              xValues[irow] = row.get(x_index).floatValue();
              yValues[irow] = row.get(y_index).floatValue();
              if (z_index >= 0) {
                zValues[irow] =
                    (float) ((row.get(z_index) - min[z_index]) / (max[z_index] - min[z_index]));
              } else zValues[irow] = 1;

              //					xValues[irow] = (float) ((row.get(x_index) - min[x_index]) / (max[x_index] -
              // min[x_index]));
              //					yValues[irow] = (float) ((row.get(y_index) - min[y_index]) / (max[y_index] -
              // min[y_index]));
            }
            //				visPanel.setData(xValues, yValues, columnNames.get(x_index),
            // columnNames.get(y_index));
            visPanel.setData(
                xValues,
                yValues,
                zValues,
                columnNames.get(y_index),
                columnNames.get(x_index),
                maxminXY);
            Double[] meanDev = new Double[4];
            meanDev[0] = mean.get(x_index).doubleValue();
            meanDev[1] = mean.get(y_index).doubleValue();
            meanDev[2] = deviation.get(x_index).doubleValue();
            meanDev[3] = deviation.get(y_index).doubleValue();
            visPanel.setStaticdata(meanDev, binCounter.get(x_index), binCounter.get(y_index));
          }
        };
    jbX.addActionListener(xListener);
    mainPanel.add(jbX, BorderLayout.PAGE_START);

    jbY = new JComboBox<String>(columnNamestring);
    jbY.setEnabled(true);
    jbY.setBorder(BorderFactory.createTitledBorder("Choose Y-axis"));
    ActionListener yListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            y_index = columnNames.indexOf(jbY.getSelectedItem());
            maxminXY = new Double[] {max[x_index], min[x_index], max[y_index], min[y_index]};

            float xValues[] = new float[rows.size()];
            float yValues[] = new float[rows.size()];
            float zValues[] = new float[rows.size()];
            for (int irow = 0; irow < rows.size(); irow++) {
              ArrayList<Double> row = rows.get(irow);
              xValues[irow] = row.get(x_index).floatValue();
              yValues[irow] = row.get(y_index).floatValue();
              if (z_index >= 0) {
                zValues[irow] =
                    (float) ((row.get(z_index) - min[z_index]) / (max[z_index] - min[z_index]));
              } else zValues[irow] = 1;
            }
            visPanel.setData(
                xValues,
                yValues,
                zValues,
                columnNames.get(y_index),
                columnNames.get(x_index),
                maxminXY);
            Double[] meanDev = new Double[4];
            meanDev[0] = mean.get(x_index).doubleValue();
            meanDev[1] = mean.get(y_index).doubleValue();
            meanDev[2] = deviation.get(x_index).doubleValue();
            meanDev[3] = deviation.get(y_index).doubleValue();
            visPanel.setStaticdata(meanDev, binCounter.get(x_index), binCounter.get(y_index));
          }
        };
    jbY.addActionListener(yListener);
    mainPanel.add(jbY, BorderLayout.PAGE_END);

    jbZ = new JComboBox<String>(columnNamestringZ);
    jbZ.setEnabled(true);
    jbZ.setBorder(BorderFactory.createTitledBorder("Choose Circle Radius"));

    ActionListener zListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            z_index = columnNames.indexOf(jbZ.getSelectedItem());
            maxminXY = new Double[] {max[x_index], min[x_index], max[y_index], min[y_index]};

            float xValues[] = new float[rows.size()];
            float yValues[] = new float[rows.size()];
            float zValues[] = new float[rows.size()];
            for (int irow = 0; irow < rows.size(); irow++) {
              ArrayList<Double> row = rows.get(irow);
              xValues[irow] = row.get(x_index).floatValue();
              yValues[irow] = row.get(y_index).floatValue();
              if (z_index >= 0) {
                zValues[irow] =
                    (float) ((row.get(z_index) - min[z_index]) / (max[z_index] - min[z_index]));
              } else zValues[irow] = 1;
            }
            visPanel.setData(
                xValues,
                yValues,
                zValues,
                columnNames.get(y_index),
                columnNames.get(x_index),
                maxminXY);
            Double[] meanDev = new Double[4];
            meanDev[0] = mean.get(x_index).doubleValue();
            meanDev[1] = mean.get(y_index).doubleValue();
            meanDev[2] = deviation.get(x_index).doubleValue();
            meanDev[3] = deviation.get(y_index).doubleValue();
            visPanel.setStaticdata(meanDev, binCounter.get(x_index), binCounter.get(y_index));
          }
        };
    jbZ.addActionListener(zListener);
    mainPanel.add(jbZ, BorderLayout.WEST);
  }
Ejemplo n.º 19
0
  private void createUI() {
    // General
    scrollingToBottomCheckbox = new JCheckBox("Initial 'Scrolling to Bottom' setting");
    coloringWholeRowCheckbox = new JCheckBox("Color whole row according to Level or Status");

    showFullCallstackCheckbox = new JCheckBox("Show full Callstack.");
    showStackTraceCheckbox = new JCheckBox("Show stacktrace of Throwables");
    usingWrappedExceptionStyleCheckbox = new JCheckBox("Use wrapped exception style.");

    applicationPathFileChooser = new JFileChooser();
    applicationPathFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    appPathTextField = new JTextField();
    appPathTextField.setEditable(false);
    Action browseAppPathAction = new BrowseApplicationPathAction();
    JButton browseAppPathButton = new JButton(browseAppPathAction);

    JPanel appPathPanel = new JPanel();
    appPathPanel.setBorder(
        new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Application Path"));
    appPathPanel.setLayout(new GridBagLayout());
    // Application Path
    {
      GridBagConstraints gbc = new GridBagConstraints();

      gbc.gridwidth = 1;
      gbc.weightx = 1;
      gbc.fill = GridBagConstraints.HORIZONTAL;

      gbc.gridx = 0;
      gbc.gridy = 0;
      appPathPanel.add(appPathTextField, gbc);

      gbc.gridx = 1;
      gbc.gridy = 0;
      gbc.weightx = 0;
      appPathPanel.add(browseAppPathButton, gbc);
    }
    lookAndFeelCombo = new JComboBox<>();
    defaultConditionCombo = new JComboBox<>();

    globalLoggingEnabledCheckbox = new JCheckBox("Enable global logs.");
    loggingStatsEnabledCheckbox = new JCheckBox("Enable logging statistics.");
    trayActiveCheckbox = new JCheckBox("Enable tray icon.");
    hidingOnCloseCheckbox = new JCheckBox("Hide windows on close.");
    hidingOnCloseCheckbox.setToolTipText(
        "Hide all windows on close of main frame instead of exiting the application. This is only relevant if tray icon is enabled.");

    JPanel viewPanel = new JPanel(new GridLayout(2, 1));
    viewPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "View"));
    viewPanel.add(scrollingToBottomCheckbox);
    viewPanel.add(coloringWholeRowCheckbox);

    JPanel detailsPanel = new JPanel(new GridLayout(3, 1));
    detailsPanel.setBorder(
        new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Details View"));
    detailsPanel.add(showFullCallstackCheckbox);
    detailsPanel.add(showStackTraceCheckbox);
    detailsPanel.add(usingWrappedExceptionStyleCheckbox);

    lookAndFeelCombo.setBorder(
        new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Look & Feel"));
    defaultConditionCombo.setBorder(
        new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Default search condition"));

    JPanel globalPanel = new JPanel(new GridLayout(4, 1));
    globalPanel.setBorder(
        new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Global settings"));
    globalPanel.add(globalLoggingEnabledCheckbox);
    globalPanel.add(loggingStatsEnabledCheckbox);
    globalPanel.add(trayActiveCheckbox);
    globalPanel.add(hidingOnCloseCheckbox);

    setLayout(new GridBagLayout());

    {
      GridBagConstraints gbc = new GridBagConstraints();

      gbc.gridwidth = 1;
      gbc.weightx = 1;
      gbc.anchor = GridBagConstraints.FIRST_LINE_START;
      gbc.fill = GridBagConstraints.HORIZONTAL;

      gbc.gridx = 0;
      gbc.gridy = 0;
      add(viewPanel, gbc);

      gbc.gridy = 1;
      add(detailsPanel, gbc);

      gbc.gridy = 2;
      add(lookAndFeelCombo, gbc);

      gbc.gridy = 3;
      add(defaultConditionCombo, gbc);

      gbc.gridy = 4;
      add(appPathPanel, gbc);

      gbc.gridy = 5;
      gbc.weighty = 1;
      add(globalPanel, gbc);
    }
  }
Ejemplo n.º 20
0
  /** Display the GUI */
  private void initGUI() {
    try {
      this.setTitle(PLUGIN_NAME + " - " + PLUGIN_VERSION);
      {
        jSplitPane1 = new JSplitPane();
        getContentPane().add(jSplitPane1, BorderLayout.CENTER);
        jSplitPane1.setPreferredSize(new java.awt.Dimension(500, 500));
        jSplitPane1.setDividerLocation(200);
        jSplitPane1.setResizeWeight(0.5);
        {
          jPanelRight = new JPanel();
          GridBagLayout jPanelRightLayout = new GridBagLayout();
          jPanelRightLayout.rowWeights = new double[] {0.0, 0.0, 0.5, 0.0};
          jPanelRightLayout.rowHeights = new int[] {7, 7, 7, 7};
          jPanelRightLayout.columnWeights = new double[] {0.0, 0.5, 0.0};
          jPanelRightLayout.columnWidths = new int[] {4, 7, 7};
          jSplitPane1.add(jPanelRight, JSplitPane.RIGHT);
          jPanelRight.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false));
          jPanelRight.setLayout(jPanelRightLayout);
          jPanelRight.setMinimumSize(new java.awt.Dimension(1, 1));
          {
            jButtonCancel = new JButton();
            jPanelRight.add(
                jButtonCancel,
                new GridBagConstraints(
                    0,
                    3,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.NONE,
                    new Insets(0, 10, 10, 0),
                    0,
                    0));
            jButtonCancel.setText("Quit");
            jButtonCancel.addActionListener(
                new ActionListener() {
                  // Close the GUI
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    quitGui();
                  }
                });
          }
          {
            jButtonOK = new JButton();
            jPanelRight.add(
                jButtonOK,
                new GridBagConstraints(
                    2,
                    3,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.NONE,
                    new Insets(0, 0, 10, 10),
                    0,
                    0));
            jButtonOK.setText("Parse");
            jButtonOK.setEnabled(false);
            jButtonOK.addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    boolean valid = checkValid();
                    if (valid) {
                      addCurrentExpressionToHistory();
                      launchCalculation();
                    }
                  }
                });
          }
          {
            jScrollPane1 = new JScrollPane();
            jPanelRight.add(
                jScrollPane1,
                new GridBagConstraints(
                    0,
                    2,
                    3,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH,
                    new Insets(10, 10, 10, 10),
                    0,
                    0));
            jScrollPane1.setOpaque(false);
            jScrollPane1.setBorder(null);
            jScrollPane1.getViewport().setOpaque(false);
            jScrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            {
              jTextAreaInfo = new JEditorPane();
              jTextAreaInfo.setBorder(null);
              jScrollPane1.setViewportView(jTextAreaInfo);
              jTextAreaInfo.setFont(new Font("Arial", Font.PLAIN, 10));
              jTextAreaInfo.setEditable(false);
              jTextAreaInfo.setOpaque(false);
              jTextAreaInfo.setContentType("text/html");
              jTextAreaInfo.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
            }
          }
        }
        {
          jPanelLeft = new JPanel();
          GridBagLayout jPanelLeftLayout = new GridBagLayout();
          jPanelLeftLayout.rowWeights = new double[] {0.0, 0.0, 1.0, 0.0};
          jPanelLeftLayout.rowHeights = new int[] {7, 7, -33, 50};
          jPanelLeftLayout.columnWeights = new double[] {0.1};
          jPanelLeftLayout.columnWidths = new int[] {7};
          jPanelLeft.setLayout(jPanelLeftLayout);
          jSplitPane1.add(jPanelLeft, JSplitPane.LEFT);
          jPanelLeft.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false));
          jPanelLeft.setPreferredSize(new java.awt.Dimension(198, 470));
          {
            jLabelExpression = new JLabel();
            jPanelLeft.add(
                jLabelExpression,
                new GridBagConstraints(
                    0,
                    0,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH,
                    new Insets(10, 10, 10, 0),
                    0,
                    0));
            jLabelExpression.setText("Expression:");
            jLabelExpression.setPreferredSize(new java.awt.Dimension(196, 16));
          }
          {
            expressionField = new JComboBox(expression_history);
            expressionField.setEditable(true);
            expressionField.setBorder(new LineBorder(new java.awt.Color(252, 117, 0), 1, false));
            expressionField.setSize(12, 18);
            jPanelLeft.add(
                expressionField,
                new GridBagConstraints(
                    0,
                    1,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH,
                    new Insets(10, 10, 10, 10),
                    0,
                    0));
            expressionField.addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    // Two action events are fired on edit: one for editing the textfield, one for
                    // changing
                    // the combo box selection. We only catch the edition.
                    if (e.getActionCommand().equalsIgnoreCase("comboBoxEdited")) {
                      boolean valid = checkValid();
                      if (valid) {
                        addCurrentExpressionToHistory();
                        launchCalculation();
                      }
                    }
                  }
                });
          }
          {
            jScrollPaneImages = new JScrollPane();
            jPanelLeft.add(
                jScrollPaneImages,
                new GridBagConstraints(
                    0,
                    2,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH,
                    new Insets(10, 0, 10, 0),
                    0,
                    0));
            jScrollPaneImages.setPreferredSize(new java.awt.Dimension(196, 267));
            jScrollPaneImages.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            jScrollPaneImages.getVerticalScrollBar().setUnitIncrement(20);
            {
              jPanelImages = new JPanel();
              jScrollPaneImages.setViewportView(jPanelImages);
              jPanelImages.setLayout(null);
              jPanelImages.setPreferredSize(new java.awt.Dimension(190, 45));
            }
          }
          {
            jPanelLeftButtons = new JPanel();
            jPanelLeft.add(
                jPanelLeftButtons,
                new GridBagConstraints(
                    0,
                    3,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH,
                    new Insets(10, 0, 10, 0),
                    0,
                    0));
            jPanelLeftButtons.setLayout(null);
            jPanelLeftButtons.setPreferredSize(new java.awt.Dimension(196, 35));
            jPanelLeftButtons.setSize(196, 35);
            {
              jButtonPlus = new JButton();
              jPanelLeftButtons.add(jButtonPlus);
              jButtonPlus.setText("+");
              jButtonPlus.setBounds(9, -2, 35, 35);
              jButtonPlus.setFont(new java.awt.Font("Times New Roman", 0, 18));
              jButtonPlus.setOpaque(true);
              jButtonPlus.addActionListener(
                  new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                      addImageBox();
                    }
                  });
            }
            {
              jButtonMinus = new JButton();
              jPanelLeftButtons.add(jButtonMinus);
              jButtonMinus.setText("—");
              jButtonMinus.setBounds(46, -2, 35, 35);
              jButtonMinus.setFont(new java.awt.Font("Arial", 0, 12));
              jButtonMinus.setOpaque(true);
              jButtonMinus.addActionListener(
                  new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                      removeImageBox();
                    }
                  });
            }
          }
          jPanelLeft.addComponentListener(
              new ComponentListener() {
                public void componentShown(ComponentEvent e) {}

                public void componentResized(ComponentEvent e) {
                  refreshImageBoxes();
                }

                public void componentMoved(ComponentEvent e) {}

                public void componentHidden(ComponentEvent e) {}
              });
        }
      }
      pack();
      setSize(500, 500);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 21
0
  public ParameterTablePanel(
      Project project, VariableData[] variableData, final PsiElement... scopeElements) {
    super(new BorderLayout());
    myProject = project;
    myVariableData = variableData;

    myTableModel = new MyTableModel();
    myTable = new JBTable(myTableModel);
    DefaultCellEditor defaultEditor = (DefaultCellEditor) myTable.getDefaultEditor(Object.class);
    defaultEditor.setClickCountToStart(1);

    myTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    myTable.setCellSelectionEnabled(true);
    TableColumn checkboxColumn = myTable.getColumnModel().getColumn(MyTableModel.CHECKMARK_COLUMN);
    TableUtil.setupCheckboxColumn(checkboxColumn);
    checkboxColumn.setCellRenderer(new CheckBoxTableCellRenderer());
    myTable
        .getColumnModel()
        .getColumn(MyTableModel.PARAMETER_NAME_COLUMN)
        .setCellRenderer(
            new DefaultTableCellRenderer() {
              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int column) {
                super.getTableCellRendererComponent(
                    table, value, isSelected, hasFocus, row, column);
                VariableData data = getVariableData()[row];
                setText(data.name);
                return this;
              }
            });

    myParameterTypeSelectors = new TypeSelector[getVariableData().length];
    for (int i = 0; i < myParameterTypeSelectors.length; i++) {
      final PsiVariable variable = getVariableData()[i].variable;
      final PsiExpression[] occurrences = findVariableOccurrences(scopeElements, variable);
      final TypeSelectorManager manager =
          new TypeSelectorManagerImpl(
              myProject, getVariableData()[i].type, occurrences, areTypesDirected()) {
            @Override
            protected boolean isUsedAfter() {
              return ParameterTablePanel.this.isUsedAfter(variable);
            }
          };
      myParameterTypeSelectors[i] = manager.getTypeSelector();
      getVariableData()[i].type = myParameterTypeSelectors[i].getSelectedType(); // reverse order
    }

    myTypeRendererCombo = new JComboBox(getVariableData());
    myTypeRendererCombo.setOpaque(true);
    myTypeRendererCombo.setBorder(null);
    myTypeRendererCombo.setRenderer(
        new ListCellRendererWrapper<VariableData>() {
          @Override
          public void customize(
              JList list, VariableData value, int index, boolean selected, boolean hasFocus) {
            if (value != null) {
              setText(value.type.getPresentableText());
            }
          }
        });

    final TableColumn typeColumn =
        myTable.getColumnModel().getColumn(MyTableModel.PARAMETER_TYPE_COLUMN);
    typeColumn.setCellEditor(
        new AbstractTableCellEditor() {
          TypeSelector myCurrentSelector;
          final JBComboBoxTableCellEditorComponent myEditorComponent =
              new JBComboBoxTableCellEditorComponent();

          @Nullable
          public Object getCellEditorValue() {
            return myEditorComponent.getEditorValue();
          }

          public Component getTableCellEditorComponent(
              final JTable table,
              final Object value,
              final boolean isSelected,
              final int row,
              final int column) {
            myEditorComponent.setCell(table, row, column);
            myEditorComponent.setOptions(myParameterTypeSelectors[row].getTypes());
            myEditorComponent.setDefaultValue(getVariableData()[row].type);
            myEditorComponent.setToString(
                new Function<Object, String>() {
                  @Override
                  public String fun(Object o) {
                    return ((PsiType) o).getPresentableText();
                  }
                });

            myCurrentSelector = myParameterTypeSelectors[row];
            return myEditorComponent;
          }
        });

    myTable
        .getColumnModel()
        .getColumn(MyTableModel.PARAMETER_TYPE_COLUMN)
        .setCellRenderer(
            new DefaultTableCellRenderer() {
              private JBComboBoxLabel myLabel = new JBComboBoxLabel();

              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int column) {
                myLabel.setText(String.valueOf(value));
                myLabel.setBackground(
                    isSelected ? table.getSelectionBackground() : table.getBackground());
                myLabel.setForeground(
                    isSelected ? table.getSelectionForeground() : table.getForeground());
                if (isSelected) {
                  myLabel.setSelectionIcon();
                } else {
                  myLabel.setRegularIcon();
                }
                return myLabel;
              }
            });

    myTable.setPreferredScrollableViewportSize(new Dimension(250, myTable.getRowHeight() * 5));
    myTable.setShowGrid(false);
    myTable.setIntercellSpacing(new Dimension(0, 0));
    @NonNls final InputMap inputMap = myTable.getInputMap();
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "enable_disable");
    @NonNls final ActionMap actionMap = myTable.getActionMap();
    actionMap.put(
        "enable_disable",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (myTable.isEditing()) return;
            int[] rows = myTable.getSelectedRows();
            if (rows.length > 0) {
              boolean valueToBeSet = false;
              for (int row : rows) {
                if (!getVariableData()[row].passAsParameter) {
                  valueToBeSet = true;
                  break;
                }
              }
              for (int row : rows) {
                getVariableData()[row].passAsParameter = valueToBeSet;
              }
              myTableModel.fireTableRowsUpdated(rows[0], rows[rows.length - 1]);
              TableUtil.selectRows(myTable, rows);
            }
          }
        });
    //// F2 should edit the name
    // inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "edit_parameter_name");
    // actionMap.put("edit_parameter_name", new AbstractAction() {
    //  public void actionPerformed(ActionEvent e) {
    //    if (!myTable.isEditing()) {
    //      int row = myTable.getSelectedRow();
    //      if (row >= 0 && row < myTableModel.getRowCount()) {
    //        TableUtil.editCellAt(myTable, row, MyTableModel.PARAMETER_NAME_COLUMN);
    //      }
    //    }
    //  }
    // });

    //// make ENTER work when the table has focus
    // inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "invokeImpl");
    // actionMap.put("invokeImpl", new AbstractAction() {
    //  public void actionPerformed(ActionEvent e) {
    //    TableCellEditor editor = myTable.getCellEditor();
    //    if (editor != null) {
    //      editor.stopCellEditing();
    //    }
    //    else {
    //      doEnterAction();
    //    }
    //  }
    // });

    // make ESCAPE work when the table has focus
    actionMap.put(
        "doCancel",
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            TableCellEditor editor = myTable.getCellEditor();
            if (editor != null) {
              editor.stopCellEditing();
            } else {
              doCancelAction();
            }
          }
        });

    JPanel listPanel =
        ToolbarDecorator.createDecorator(myTable)
            .disableAddAction()
            .disableRemoveAction()
            .createPanel();
    add(listPanel, BorderLayout.CENTER);

    if (getVariableData().length > 1) {
      myTable.getSelectionModel().setSelectionInterval(0, 0);
    }
  }
Ejemplo n.º 22
0
  public CommonPanel(JFrame ownerFrame, IFileSelector fileSelectionPanel) {
    //		try {
    //			FileHandler fh = new FileHandler("log.txt");
    //			Logger.getLogger(CommonPanel.class.getName()).addHandler(fh);
    //		}catch(IOException ex) {
    //			Logger.getLogger(CommonPanel.class.getName()).log(Level.SEVERE, null, ex);
    //		}catch(SecurityException ex) {
    //			Logger.getLogger(CommonPanel.class.getName()).log(Level.SEVERE, null, ex);
    //		}
    this.ownerFrame = ownerFrame;
    this.fileSelectionPanel = fileSelectionPanel;
    this.fontSizeTF = new JTextField(4);
    fontSizeTF.setToolTipText("Enter the font size, e.g. 12, 10.5, 22.7");
    fontSizeTF.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (!fontSizeSpecRB.isSelected()) fontSizeSpecRB.setSelected(true);
          }
        });
    fontSizeTF.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            super.mousePressed(e);
            if (!fontSizeSpecRB.isSelected()) fontSizeSpecRB.setSelected(true);
            System.out.println("fontSizeTF mousePressed");
          }

          @Override
          public void mouseExited(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    1,
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }

          @Override
          public void mouseEntered(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    1,
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }
        });
    String fontSizeRBToolTip =
        "<html>When this option is selected it enforces that"
            + "<br> the entered font size is used when creating the output file.";
    this.fontSizeSpecRB = new JRadioButton("Use the font size ");
    fontSizeSpecRB.setOpaque(false);
    fontSizeSpecRB.setToolTipText(fontSizeRBToolTip);
    JPanel fontSizeSpecPanel = new JPanel();
    fontSizeSpecPanel.setToolTipText(fontSizeRBToolTip);
    // pass events to radiobutton
    fontSizeSpecPanel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    1,
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    e.getClickCount(),
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    e.getClickCount(),
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }

          @Override
          public void mouseEntered(MouseEvent e) {
            MouseEvent event =
                new MouseEvent(
                    fontSizeSpecRB,
                    e.getID(),
                    e.getWhen(),
                    e.getModifiers(),
                    1,
                    1,
                    e.getClickCount(),
                    e.isPopupTrigger(),
                    e.getButton());
            fontSizeSpecRB.dispatchEvent(event);
          }
        });
    fontSizeSpecPanel.add(fontSizeSpecRB);
    fontSizeSpecPanel.add(fontSizeTF);
    fontSizeSpecPanel.setBorder(BorderFactory.createEtchedBorder());
    fontSizeSpecPanel.setOpaque(false);
    this.fitTextToWidthRB = new JRadioButton("Fit text to page width ");
    fitTextToWidthRB.setBorder(BorderFactory.createEtchedBorder());
    fitTextToWidthRB.setBorderPainted(true);
    fitTextToWidthRB.setOpaque(false);
    fitTextToWidthRB.setToolTipText(
        "<html>Don't care about the font size, but make sure"
            + "<br> the width of input file content will fit into "
            + "<br>a whole width of a 'pdf' page.");

    ButtonGroup fontBG = new ButtonGroup();
    fontBG.add(fontSizeSpecRB);
    fontBG.add(fitTextToWidthRB);
    fitTextToWidthRB.setSelected(true);

    double p = TableLayout.PREFERRED;
    TableLayout fontSelectPL =
        new TableLayout(new double[] {.5, p, p, p, .5}, new double[] {.5, p, .5});
    JPanel fontSelectP = new JPanel(fontSelectPL);
    fontSelectP.setOpaque(false);
    fontSelectP.add(fontSizeSpecPanel, "1,1,L,C");
    fontSelectP.add(new JLabel(" or "), "2,1,C,C");
    fontSelectP.add(fitTextToWidthRB, "3,1,R,F");

    String[] fonts = {
      BaseFont.COURIER,
      BaseFont.HELVETICA,
      BaseFont.SYMBOL,
      BaseFont.TIMES_ROMAN,
      BaseFont.ZAPFDINGBATS
    }; // , "fonts/lucon.ttf"};
    // load font files from the fonts folder
    String fontFolder = "fonts";
    String[] fontFileNames = new String[0];
    //		Logger.getLogger(CommonPanel.class.getName()).log(Level.INFO,
    //				"ownerFrame must be instanceof Txt2PDFConverterIN is it?="
    //				+(ownerFrame instanceof Txt2PDFConverterIN)
    //				+"; ownerFrame.getClass().getName()="+ownerFrame.getClass().getName());
    if (ownerFrame instanceof Txt2PDFConverterIN)
      try {
        fontFileNames = getResourceListing(this.getClass(), fontFolder + "/");
      } catch (Exception ex) {
        // ignore, it could happen when fonts folder doesn't exist, it does
        // happen when debugging since the folder doesn't exist.
        // But the folder always is packed in the compact(IN) version of the program.
      }
    else {
      fontFileNames = new File(fontFolder).list();
    }
    //		Logger.getLogger(CommonPanel.class.getName()).log(Level.INFO,
    //				"fontFileNames=" + Arrays.toString(fontFileNames));
    int initialFontsSize = fonts.length;
    if (fontFileNames.length > 0) {
      int newFontsSize = initialFontsSize + fontFileNames.length;
      fonts = Arrays.copyOf(fonts, newFontsSize);
      for (int i = initialFontsSize; i < newFontsSize; i++)
        fonts[i] = fontFolder + "/" + fontFileNames[i - initialFontsSize];
    }
    this.fontCB = new JComboBox(fonts);
    fontCB.setBorder(BorderFactory.createEtchedBorder());
    fontCB.setToolTipText("Select the font to use for output.");
    String[] encodings = {BaseFont.CP1252, BaseFont.CP1250, BaseFont.CP1257, BaseFont.MACROMAN};
    this.encodingCB = new JComboBox(encodings);
    encodingCB.setBorder(BorderFactory.createEtchedBorder());
    encodingCB.setToolTipText("Select encoding used by the input file.");
    this.portraitRB = new JRadioButton("Portrait ");
    portraitRB.setBorder(BorderFactory.createEtchedBorder());
    portraitRB.setBorderPainted(true);
    portraitRB.setOpaque(false);
    portraitRB.setToolTipText("The output file will have pages in portrait orientation.");
    this.landscapeRB = new JRadioButton("Landscape ");
    landscapeRB.setBorder(BorderFactory.createEtchedBorder());
    landscapeRB.setBorderPainted(true);
    landscapeRB.setOpaque(false);
    landscapeRB.setToolTipText("The output file will have pages in landscape orientation.");
    ButtonGroup pageOrientBG = new ButtonGroup();
    pageOrientBG.add(portraitRB);
    pageOrientBG.add(landscapeRB);
    portraitRB.setSelected(true);

    // panel with page orientation settings
    TableLayout pageOrientPL =
        new TableLayout(new double[] {5, p, p, p, 5}, new double[] {TableLayout.FILL});
    JPanel pageOrientP = new JPanel(pageOrientPL);
    pageOrientP.setOpaque(false);
    pageOrientP.add(portraitRB, "1,0,L,F");
    pageOrientP.add(new JLabel(" or "), "2,0,C,C");
    pageOrientP.add(landscapeRB, "3,0,R,F");
    pageOrientP.setBorder(BorderFactory.createEtchedBorder());

    TableLayout encodeOrientPL =
        new TableLayout(
            new double[] {10, p, 5, p, TableLayout.FILL, p, 10}, new double[] {.5, p, .5});
    JPanel fontEncodeOrientP = new JPanel(encodeOrientPL);
    fontEncodeOrientP.setOpaque(false);
    fontEncodeOrientP.add(fontCB, "1,1,L,F");
    fontEncodeOrientP.add(encodingCB, "3,1,L,F");
    fontEncodeOrientP.add(pageOrientP, "5,1,R,F");

    this.overwriteOutputFileChB = new JCheckBox("Overwrite output file ");
    overwriteOutputFileChB.setToolTipText(
        "When selected it will overwrite the output file if it exists.");
    overwriteOutputFileChB.setBorder(BorderFactory.createEtchedBorder());
    overwriteOutputFileChB.setBorderPainted(true);
    overwriteOutputFileChB.setOpaque(false);
    int bW = 80;
    int bH = 30;
    this.convertB = new JButton(copnvertAction);
    convertB.setPreferredSize(new Dimension(bW, bH));
    convertB.setToolTipText("Convert the input 'txt' file applying all the selected settings.");
    this.exitB = new JButton(exitAction);
    exitB.setPreferredSize(new Dimension(bW, bH));
    exitB.setToolTipText("Exit the program.");
    TableLayout buttonPL =
        new TableLayout(new double[] {.25, p, .5, p, .25}, new double[] {5, p, 5});
    JPanel buttonP = new JPanel(buttonPL);
    buttonP.setOpaque(false);
    buttonP.add(convertB, "1,1,C,C");
    buttonP.add(exitB, "3,1,C,C");

    JLabel infoL = new JLabel("<html><p>&nbsp Select conversion settings.</p>");
    TableLayout layout =
        new TableLayout(
            new double[] {.5, p, .5}, new double[] {.5, p, 5, p, 5, p, 5, p, 10, p, .5});
    setLayout(layout);
    add(infoL, "1,1,L,C");
    add(fontSelectP, "1,3,F,C");
    add(fontEncodeOrientP, "1,5,F,C");
    add(overwriteOutputFileChB, "1,7,C,F");
    add(buttonP, "1,9,F,C");
  }
  public void createDataEditPanelCourse(String CourseNo, String CourseName, String CourseCredit) {

    this.CourseNo = CourseNo;
    this.CourseName = CourseName;
    this.CourseCredit = CourseCredit;

    Credit = Float.parseFloat(CourseCredit);

    if (Credit == 0.75) CreditIndex = 0;
    else if (Credit == 1.50) CreditIndex = 1;
    else if (Credit == 3.00) CreditIndex = 2;
    else CreditIndex = 3;

    DEPC = new JDialog();
    DEPC.setTitle("Course Edit Dialog");

    Panel =
        new JPanel() {
          protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(
                new ImageIcon(getClass().getResource("/Icons/8.jpg")).getImage(),
                0,
                0,
                600,
                230,
                null);
            ButtonBorder.paintBorder(this, g, 172, 136, 130, 25);
          }
        };
    Panel.setForeground(Color.WHITE);
    Panel.setLayout(null);

    CourseNoLabel1 = new JLabel("Course No.          : ");
    CourseNoLabel1.setForeground(Color.WHITE);
    CourseNoLabel1.setFont(new Font("Rockwell Extra Bold", Font.PLAIN, 12));
    CourseNoLabel1.setBounds(77, 29, 139, 27);
    Panel.add(CourseNoLabel1);

    CourseNoLabel2 = new JLabel(this.CourseNo);
    CourseNoLabel2.setForeground(Color.WHITE);
    CourseNoLabel2.setFont(new Font("Rockwell Extra Bold", Font.BOLD, 12));
    CourseNoLabel2.setBounds(213, 29, 200, 27);
    Panel.add(CourseNoLabel2);

    CourseNameLabel = new JLabel("Course Title       :");
    CourseNameLabel.setForeground(Color.WHITE);
    CourseNameLabel.setFont(new Font("Rockwell Extra Bold", Font.PLAIN, 12));
    CourseNameLabel.setBounds(77, 56, 139, 26);
    Panel.add(CourseNameLabel);

    CourseNameField = new JTextField(this.CourseName);
    CourseNameField.setForeground(Color.WHITE);
    CourseNameField.setFont(new Font("Rockwell Extra Bold", Font.PLAIN, 10));
    CourseNameField.setBounds(213, 60, 200, 20);
    CourseNameField.setOpaque(false);
    CourseNameField.setHorizontalAlignment(SwingConstants.CENTER);
    Panel.add(CourseNameField);

    CourseCreditLabel = new JLabel("Course Credit   :");
    CourseCreditLabel.setForeground(Color.WHITE);
    CourseCreditLabel.setBounds(77, 87, 139, 26);
    CourseCreditLabel.setFont(new Font("Rockwell Extra Bold", Font.PLAIN, 12));
    Panel.add(CourseCreditLabel);

    CourseCreditBox = new JComboBox<String>();
    CourseCreditBox.setBackground(Color.GRAY);
    CourseCreditBox.setForeground(new Color(28, 0, 0));
    CourseCreditBox.setBounds(213, 91, 103, 20);
    CourseCreditBox.setBorder(ButtonBorder);
    CourseCreditBox.addItem("0.75");
    CourseCreditBox.addItem("1.50");
    CourseCreditBox.addItem("3.00");
    CourseCreditBox.addItem("4.00");
    CourseCreditBox.setMaximumRowCount(3);
    CourseCreditBox.setSelectedIndex(CreditIndex);
    Panel.add(CourseCreditBox);

    UpdateButton = new JButton("Update");
    UpdateButton.setForeground(Color.WHITE);
    UpdateButton.setFont(new Font("Rockwell Extra Bold", Font.BOLD, 10));
    UpdateButton.setBounds(173, 137, 128, 23);
    UpdateButton.setContentAreaFilled(false);
    UpdateButton.addActionListener(this);
    Panel.add(UpdateButton);

    DEPC.getContentPane().add(Panel);
    DEPC.setSize(500, 230);
    DEPC.setLocation(500, 200);
    DEPC.setResizable(false);
    DEPC.setVisible(true);
    DEPC.setModal(true);
  }
Ejemplo n.º 24
0
  public SceneLayoutApp() {
    super();
    new Pair();
    final JFrame frame = new JFrame("Scene Layout");

    final JPanel panel = new JPanel(new BorderLayout());
    frame.setContentPane(panel);
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setMaximumSize(screenSize);
    frame.setSize(screenSize);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JMenuBar mb = new JMenuBar();
    frame.setJMenuBar(mb);

    final JMenu jMenu = new JMenu("File");
    mb.add(jMenu);
    mb.add(new JMenu("Edit"));
    mb.add(new JMenu("Help"));
    JMenu menu = new JMenu("Look and Feel");

    //
    // Get all the available look and feel that we are going to use for
    // creating the JMenuItem and assign the action listener to handle
    // the selection of menu item to change the look and feel.
    //
    UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < lookAndFeelInfos.length; i++) {
      final UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i];
      JMenuItem item = new JMenuItem(lookAndFeelInfo.getName());
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                //
                // Set the look and feel for the frame and update the UI
                // to use a new selected look and feel.
                //
                UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
                SwingUtilities.updateComponentTreeUI(frame);
              } catch (ClassNotFoundException e1) {
                e1.printStackTrace();
              } catch (InstantiationException e1) {
                e1.printStackTrace();
              } catch (IllegalAccessException e1) {
                e1.printStackTrace();
              } catch (UnsupportedLookAndFeelException e1) {
                e1.printStackTrace();
              }
            }
          });
      menu.add(item);
    }

    mb.add(menu);
    jMenu.add(new JMenuItem(new scene.action.QuitAction()));

    panel.add(new JScrollPane(desktopPane), BorderLayout.CENTER);
    final JToolBar bar = new JToolBar();

    panel.add(bar, BorderLayout.NORTH);

    final JComboBox comboNewWindow =
        new JComboBox(
            new String[] {"320:180", "320:240", "640:360", "640:480", "1280:720", "1920:1080"});

    comboNewWindow.addActionListener(new CreateSceneWindowAction());

    comboNewWindow.setBorder(BorderFactory.createTitledBorder("Create New Window"));
    bar.add(comboNewWindow);
    bar.add(
        new AbstractAction("Progress Bars") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new ProgressBarAnimator();
          }
        });
    bar.add(
        new AbstractAction("Sliders") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new SliderBarAnimator();
          }
        });

    final JCheckBox permaViz = new JCheckBox();
    permaViz.setText("Show the dump window");
    permaViz.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    dumpWindow = new JInternalFrame("perma dump window");
    dumpWindow.setContentPane(new JScrollPane(permText));

    permaViz.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dumpWindow.setVisible(permaViz.isSelected());
          }
        });

    comboNewWindow.setMaximumSize(comboNewWindow.getPreferredSize());

    permaViz.setSelected(false);
    bar.add(new CreateWebViewV1Action());
    bar.add(new CreateWebViewV2Action());
    bar.add(permaViz);
    desktopPane.add(dumpWindow);
    dumpWindow.setSize(400, 400);
    dumpWindow.setResizable(true);
    dumpWindow.setClosable(false);
    dumpWindow.setIconifiable(false);
    final JMenuBar m = new JMenuBar();
    final JMenu cmenu = new JMenu("Create");
    m.add(cmenu);
    final JMenuItem menuItem =
        new JMenuItem(
            new AbstractAction("new") {
              @Override
              public void actionPerformed(ActionEvent e) {
                Runnable runnable =
                    new Runnable() {
                      public void run() {
                        Object[] in = (Object[]) XSTREAM.fromXML(permText.getText());

                        final JInternalFrame ff = new JInternalFrame();

                        final ScenePanel c = new ScenePanel();
                        ff.setContentPane(c);
                        desktopPane.add(ff);
                        final Dimension d = (Dimension) in[0];
                        c.setMaximumSize(d);
                        c.setPreferredSize(d);

                        ff.setSize(d.width + 50, d.height + 50);
                        ScenePanel.panes.put(c, (List<Pair<Point, ArrayList<URL>>>) in[1]);

                        c.invalidate();
                        c.repaint();

                        ff.pack();
                        ff.setClosable(true);

                        ff.setMaximizable(false);
                        ff.setIconifiable(false);
                        ff.setResizable(false);
                        ff.show();
                      }
                    };

                SwingUtilities.invokeLater(runnable);
              }
            });
    cmenu.add(menuItem);
    //        JMenuBar menuBar = new JMenuBar();

    //        getContentPane().add(menuBar);

    dumpWindow.setJMenuBar(m);
    frame.setVisible(true);
  }
Ejemplo n.º 25
0
  /** Create the frame. */
  @SuppressWarnings({"unchecked", "rawtypes"})
  public MembersManagement() {
    connection = DBConnector.dbConnector();
    setIconImage(
        Toolkit.getDefaultToolkit()
            .getImage(
                MembersManagement.class.getResource(
                    "/Resources/Custo.Man.Christmas.Folder.Library.ico.png")));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 1366, 768);
    contentPane = new JPanel();
    contentPane.setBackground(Color.DARK_GRAY);
    contentPane.setBorder(new LineBorder(Color.BLUE, 1, true));
    setContentPane(contentPane);
    StartPosition.centerOnScreen(this);

    String[] MemberType = new String[] {"Students", "Teachers"};

    JButton button = new JButton("_");
    button.setBounds(1234, 1, 44, 23);
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            MinFrame();
          }
        });
    contentPane.setLayout(null);
    button.setForeground(Color.WHITE);
    button.setFocusable(false);
    button.setBackground(Color.DARK_GRAY);
    contentPane.add(button);

    JButton button_1 = new JButton("");
    button_1.setBounds(1277, 1, 44, 23);
    button_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            MaxFrame();
          }
        });
    button_1.setIcon(new ImageIcon(MembersManagement.class.getResource("/Resources/Maximize.png")));
    button_1.setForeground(Color.WHITE);
    button_1.setFocusable(false);
    button_1.setBackground(Color.DARK_GRAY);
    contentPane.add(button_1);

    JButton button_2 = new JButton("X");
    button_2.setBounds(1321, 1, 44, 23);
    button_2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            CloseFrame();
          }
        });
    button_2.setForeground(Color.WHITE);
    button_2.setFont(new Font("Ubuntu", Font.BOLD, 8));
    button_2.setFocusable(false);
    button_2.setBackground(Color.RED);
    contentPane.add(button_2);

    Border emptyBorder = BorderFactory.createEmptyBorder();

    JLabel lblStudentsManagement = new JLabel("Members Management");
    lblStudentsManagement.setBounds(403, 34, 543, 78);
    lblStudentsManagement.setHorizontalAlignment(SwingConstants.CENTER);
    lblStudentsManagement.setForeground(new Color(255, 255, 255));
    lblStudentsManagement.setFont(new Font("Ubuntu", Font.BOLD, 36));
    contentPane.add(lblStudentsManagement);

    String[] searchCriteria = new String[] {"Name", "Registration Number"};

    JPanel panel3 = new JPanel();
    panel3.setBackground(Color.DARK_GRAY);
    panel3.setBorder(new LineBorder(Color.BLUE));
    panel3.setBounds(14, 187, 1340, 568);
    contentPane.add(panel3);
    panel3.setLayout(null);
    panel3.setVisible(false);

    JLabel lblSelectSearchCriteria = new JLabel("Select Search Criteria");
    lblSelectSearchCriteria.setForeground(Color.WHITE);
    lblSelectSearchCriteria.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    lblSelectSearchCriteria.setBounds(487, 39, 149, 21);
    panel3.add(lblSelectSearchCriteria);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(10, 99, 1320, 402);
    panel3.add(scrollPane_1);

    table_1 = new JTable();
    table_1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    table_1.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    scrollPane_1.setViewportView(table_1);

    JLabel lblCriteria = new JLabel("Name");
    lblCriteria.setForeground(Color.WHITE);
    lblCriteria.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    lblCriteria.setBounds(952, 39, 149, 21);
    panel3.add(lblCriteria);

    JComboBox cmbSearchCriteria = new JComboBox(searchCriteria);
    cmbSearchCriteria.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (cmbSearchCriteria.getSelectedItem().toString() == "Name") {
              lblCriteria.setText("Name");
              txtSearch.setBounds(1001, 37, 160, 25);
            } else if (cmbSearchCriteria.getSelectedItem().toString() == "Registration Number") {
              lblCriteria.setText("Registration Number");
              txtSearch.setBounds(1100, 37, 160, 25);
            }
          }
        });
    cmbSearchCriteria.setForeground(Color.WHITE);
    cmbSearchCriteria.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    cmbSearchCriteria.setBorder(emptyBorder);
    cmbSearchCriteria.setBackground(Color.DARK_GRAY);
    cmbSearchCriteria.setBounds(646, 39, 160, 20);
    panel3.add(cmbSearchCriteria);

    JComboBox cmbType = new JComboBox(MemberType);
    cmbType.setForeground(Color.WHITE);
    cmbType.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    cmbType.setBackground(Color.DARK_GRAY);
    cmbType.setBounds(246, 39, 160, 20);
    panel3.add(cmbType);

    JLabel lblSearchBy = new JLabel("Search By");
    lblSearchBy.setForeground(Color.WHITE);
    lblSearchBy.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    lblSearchBy.setBounds(885, 39, 75, 21);
    panel3.add(lblSearchBy);

    txtSearch = new JTextField();
    txtSearch.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyTyped(KeyEvent e) {
            String type = cmbType.getSelectedItem().toString();
            String sCriteria = cmbSearchCriteria.getSelectedItem().toString();
            if (type == "Students") {
              if (sCriteria == "Name") {
                try {
                  LibMemberDM bDM = new LibMemberDM();
                  table_1.setModel(
                      DbUtils.resultSetToTableModel(bDM.searchByNameS(txtSearch.getText())));
                } catch (Exception ex) {
                  JOptionPane.showMessageDialog(null, ex.getMessage());
                }
              } else if (sCriteria == "Registration Number") {
                try {
                  LibMemberDM bDM = new LibMemberDM();
                  table_1.setModel(
                      DbUtils.resultSetToTableModel(bDM.searchByRegNoS(txtSearch.getText())));
                } catch (Exception ex) {
                  JOptionPane.showMessageDialog(null, ex.getMessage());
                }
              }
            } else if (type == "Teachers") {
              if (sCriteria == "Name") {
                try {
                  LibMemberDM bDM = new LibMemberDM();
                  table_1.setModel(
                      DbUtils.resultSetToTableModel(bDM.searchByNameT(txtSearch.getText())));
                } catch (Exception ex) {
                  JOptionPane.showMessageDialog(null, ex.getMessage());
                }
              } else if (sCriteria == "Registration Number") {
                try {
                  LibMemberDM bDM = new LibMemberDM();
                  table_1.setModel(
                      DbUtils.resultSetToTableModel(bDM.searchByRegNoT(txtSearch.getText())));
                } catch (Exception ex) {
                  JOptionPane.showMessageDialog(null, ex.getMessage());
                }
              }
            }
          }
        });
    txtSearch.setForeground(Color.WHITE);
    txtSearch.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    txtSearch.setBorder(emptyBorder);
    txtSearch.setBackground(Color.GRAY);
    txtSearch.setBounds(1001, 37, 200, 25);
    panel3.add(txtSearch);
    txtSearch.setColumns(10);

    JButton btnUpdate = new JButton("Update");
    btnUpdate.setFont(new Font("Ubuntu", Font.PLAIN, 12));
    btnUpdate.setBackground(Color.DARK_GRAY);
    btnUpdate.setForeground(Color.WHITE);
    btnUpdate.setBounds(518, 523, 89, 23);
    panel3.add(btnUpdate);

    JButton btnRemove = new JButton("Remove");
    btnRemove.setFont(new Font("Ubuntu", Font.PLAIN, 12));
    btnRemove.setBackground(Color.DARK_GRAY);
    btnRemove.setForeground(Color.WHITE);
    btnRemove.setBounds(676, 523, 89, 23);
    panel3.add(btnRemove);

    JLabel lblSelectMemberType = new JLabel("Select Member Type");
    lblSelectMemberType.setForeground(Color.WHITE);
    lblSelectMemberType.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    lblSelectMemberType.setBounds(97, 39, 149, 21);
    panel3.add(lblSelectMemberType);

    JPanel panel1 = new JPanel();
    panel1.setBorder(new LineBorder(Color.BLUE));
    panel1.setBackground(Color.DARK_GRAY);
    panel1.setBounds(14, 187, 1340, 568);
    contentPane.add(panel1);
    panel1.setVisible(true);
    panel1.setLayout(null);

    JComboBox cmbMemType = new JComboBox(MemberType);
    cmbMemType.setForeground(Color.WHITE);
    cmbMemType.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    cmbMemType.setBorder(emptyBorder);
    cmbMemType.setBackground(Color.DARK_GRAY);
    cmbMemType.setBounds(449, 39, 146, 25);
    panel1.add(cmbMemType);

    JButton btnView = new JButton("View Members");
    btnView.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            String Type = cmbMemType.getSelectedItem().toString();
            try {
              if (Type == "Students") {
                String Query =
                    "select t2.MemID, t1.FullName, t1.Address, t1.DOB, t1.NIC, t1.Sex, t1.ContactNo, t1.CurrentGrade, t1.CurrentClass from StudentsMF t1, LibMem t2 where t1.RegNo = t2.RegNoS";
                PreparedStatement pst = connection.prepareStatement(Query);
                ResultSet rs = pst.executeQuery();
                table.setModel(DbUtils.resultSetToTableModel(rs));

                rs.close();
                pst.close();
              } else if (Type == "Teachers") {
                String Query =
                    "select t2.MemID, t1.Name, t1.Adress, t1.DOB, t1.NIC, t1.Sex, t1.ContactNo, t1.TGrade, t1.Type from TeachersMF t1, LibMem t2 where t1.RegNo = t2.RegNoT";
                PreparedStatement pst = connection.prepareStatement(Query);
                ResultSet rs = pst.executeQuery();
                table.setModel(DbUtils.resultSetToTableModel(rs));

                rs.close();
                pst.close();
              }
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });
    btnView.setForeground(Color.WHITE);
    btnView.setBackground(Color.DARK_GRAY);
    btnView.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    btnView.setBounds(736, 36, 131, 30);
    panel1.add(btnView);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 99, 1320, 458);
    panel1.add(scrollPane);

    table = new JTable();
    table.setGridColor(Color.GRAY);
    table.setFont(new Font("Ubuntu", Font.PLAIN, 11));
    table.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    table.setBackground(Color.WHITE);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    scrollPane.setViewportView(table);

    JPanel panel2 = new JPanel();
    panel2.setBorder(new LineBorder(Color.BLUE));
    panel2.setBackground(Color.DARK_GRAY);
    panel2.setBounds(14, 187, 1340, 568);
    contentPane.add(panel2);
    panel2.setLayout(null);

    JLabel lblISBN = new JLabel("Registration Number");
    lblISBN.setForeground(Color.WHITE);
    lblISBN.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    lblISBN.setBounds(232, 183, 142, 22);
    panel2.add(lblISBN);

    txtRegNo = new JTextField();
    txtRegNo.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    txtRegNo.setBackground(Color.GRAY);
    txtRegNo.setForeground(Color.WHITE);
    txtRegNo.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    txtRegNo.setBounds(413, 182, 208, 24);
    txtRegNo.setBorder(emptyBorder);
    panel2.add(txtRegNo);
    txtRegNo.setColumns(10);

    txtPassword = new JTextField();
    txtPassword.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    txtPassword.setForeground(Color.WHITE);
    txtPassword.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    txtPassword.setBorder(emptyBorder);
    txtPassword.setColumns(10);
    txtPassword.setBackground(Color.GRAY);
    txtPassword.setBounds(413, 214, 208, 24);
    panel2.add(txtPassword);

    JLabel lblName = new JLabel("Password");
    lblName.setForeground(Color.WHITE);
    lblName.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    lblName.setBounds(232, 215, 142, 22);
    panel2.add(lblName);

    JLabel lblNicNumber = new JLabel("Re-Enter Password");
    lblNicNumber.setForeground(Color.WHITE);
    lblNicNumber.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    lblNicNumber.setBounds(232, 248, 142, 22);
    panel2.add(lblNicNumber);

    txtRPassword = new JTextField();
    txtRPassword.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    txtRPassword.setForeground(Color.WHITE);
    txtRPassword.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    txtRPassword.setBorder(emptyBorder);
    txtRPassword.setColumns(10);
    txtRPassword.setBackground(Color.GRAY);
    txtRPassword.setBounds(413, 247, 208, 24);
    panel2.add(txtRPassword);

    JButton btnClear = new JButton("Clear");
    btnClear.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            clearFeilds();
          }
        });
    btnClear.setForeground(Color.WHITE);
    btnClear.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    btnClear.setBackground(Color.DARK_GRAY);
    btnClear.setBounds(474, 344, 110, 32);
    panel2.add(btnClear);

    JButton btnAddMember = new JButton("Add Member");
    btnAddMember.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (!txtRPassword.getText().equals("")
                || !txtPassword.getText().equals("")
                || !txtRegNo.getText().equals("")) {
              if (txtPassword.getText().equals(txtRPassword.getText())) {
                try {
                  LibMemberDM mDM = new LibMemberDM();
                  LibMember member = new LibMember();
                  member.setMemID(txtRegNo.getText());
                  member.setPassword(txtPassword.getText());

                  // checking whether RegNo exist in the database {
                  String query1 = "select RegNo from TeachersMF where RegNo=?";
                  String query2 = "select RegNo from StudentsMF where RegNo=?";
                  PreparedStatement pst1 = connection.prepareStatement(query1);
                  pst1.setString(1, member.getMemID());
                  PreparedStatement pst2 = connection.prepareStatement(query2);
                  pst2.setString(1, member.getMemID());
                  ResultSet rs1 = pst1.executeQuery();
                  ResultSet rs2 = pst2.executeQuery();

                  int count1 = 0, count2 = 0;
                  while (rs1.next()) count1++;
                  while (rs2.next()) count2++;

                  if (count1 == 0 && count2 == 0)
                    JOptionPane.showMessageDialog(
                        null,
                        "Registration Number does not exist!",
                        "Error",
                        JOptionPane.WARNING_MESSAGE);
                  else if (count1 == 1 && count2 == 0) {
                    String query3 =
                        "select MemID from LibMem where MemID='" + member.getMemID() + "'";
                    PreparedStatement pst3 = connection.prepareStatement(query3);
                    ResultSet rs3 = pst3.executeQuery();
                    int count3 = 0;
                    while (rs3.next()) count3++;
                    if (count3 != 0) JOptionPane.showMessageDialog(null, "User Already Exist!");
                    else if (count3 == 0) {
                      if (mDM.insertMemberT(member)) {
                        JOptionPane.showMessageDialog(null, "Successful");
                        clearFeilds();
                      } else JOptionPane.showMessageDialog(null, "Failed");
                      rs3.close();
                      pst3.close();
                    }
                  } else if (count1 == 0 && count2 == 1) {
                    String query6 = "select * from LibMem where MemID='" + member.getMemID() + "'";
                    PreparedStatement pst5 = connection.prepareStatement(query6);
                    ResultSet rs4 = pst5.executeQuery();
                    int count3 = 0;
                    while (rs4.next()) count3++;
                    if (count3 != 0) JOptionPane.showMessageDialog(null, "User Already Exist!");
                    else if (count3 == 0) {
                      if (mDM.insertMemberS(member)) {
                        JOptionPane.showMessageDialog(null, "Successful");
                        clearFeilds();
                      } else JOptionPane.showMessageDialog(null, "Failed");

                      rs4.close();
                      pst5.close();
                    }
                  }

                  rs1.close();
                  rs2.close();
                  pst1.close();
                  pst2.close();

                } catch (Exception x) {
                  JOptionPane.showMessageDialog(null, x);
                  System.out.println(x);
                }
              } else JOptionPane.showMessageDialog(null, "Passwords do not Match");
            } else JOptionPane.showMessageDialog(null, "Fill in All the Details");
          }
        });
    btnAddMember.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    btnAddMember.setBackground(Color.DARK_GRAY);
    btnAddMember.setForeground(Color.WHITE);
    btnAddMember.setBounds(265, 344, 125, 32);
    panel2.add(btnAddMember);

    JLabel label = new JLabel("");
    label.setIcon(
        new ImageIcon(MembersManagement.class.getResource("/Resources/sign-up-icon.png")));
    label.setBounds(856, 140, 256, 226);
    panel2.add(label);
    panel2.setVisible(false);

    // Creating Tab Buttons of Tabs Pane
    JButton btnEditStudentDetails = new JButton("Edit Member Details");
    JButton btnAddStudents = new JButton("Add Members");
    JButton btnViewStudents = new JButton("View Members");

    btnViewStudents.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    btnViewStudents.setForeground(Color.WHITE);
    btnViewStudents.setBackground(Color.BLUE);
    btnViewStudents.setBounds(14, 164, 124, 23);
    contentPane.add(btnViewStudents);

    btnAddStudents.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            if (btnAddStudents.hasFocus()) {
              btnAddStudents.setBackground(Color.BLUE);
              btnAddStudents.setForeground(Color.WHITE);
              btnViewStudents.setBackground(Color.DARK_GRAY);
              btnViewStudents.setForeground(Color.WHITE);
              btnEditStudentDetails.setBackground(Color.DARK_GRAY);
              btnEditStudentDetails.setForeground(Color.WHITE);
            }

            if (panel2.isVisible() == false) {
              panel2.setVisible(true);
              panel1.setVisible(false);
              panel3.setVisible(false);
            }
          }
        });
    btnAddStudents.setForeground(Color.WHITE);
    btnAddStudents.setBorder(BorderFactory.createLineBorder(Color.BLUE));
    btnAddStudents.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    btnAddStudents.setBackground(Color.DARK_GRAY);
    btnAddStudents.setBounds(137, 164, 144, 23);
    contentPane.add(btnAddStudents);

    btnEditStudentDetails.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            if (btnEditStudentDetails.hasFocus()) {
              btnEditStudentDetails.setBackground(Color.BLUE);
              btnEditStudentDetails.setForeground(Color.WHITE);
              btnAddStudents.setBackground(Color.DARK_GRAY);
              btnAddStudents.setForeground(Color.WHITE);
              btnViewStudents.setBackground(Color.DARK_GRAY);
              btnViewStudents.setForeground(Color.WHITE);
            }

            if (panel3.isVisible() == false) {
              panel3.setVisible(true);
              panel1.setVisible(false);
              panel2.setVisible(false);
            }
          }
        });
    btnEditStudentDetails.setForeground(Color.WHITE);
    btnEditStudentDetails.setBorder(BorderFactory.createLineBorder(Color.BLUE));
    btnEditStudentDetails.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    btnEditStudentDetails.setBackground(Color.DARK_GRAY);
    btnEditStudentDetails.setBounds(280, 164, 169, 23);
    contentPane.add(btnEditStudentDetails);

    btnViewStudents.setBorder(BorderFactory.createLineBorder(Color.BLUE));
    btnViewStudents.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            if (btnViewStudents.hasFocus()) {
              btnViewStudents.setBackground(Color.BLUE);
              btnViewStudents.setForeground(Color.WHITE);
              btnAddStudents.setBackground(Color.DARK_GRAY);
              btnAddStudents.setForeground(Color.WHITE);
              btnEditStudentDetails.setBackground(Color.DARK_GRAY);
              btnEditStudentDetails.setForeground(Color.WHITE);
            }

            if (panel1.isVisible() == false) {
              panel1.setVisible(true);
              panel2.setVisible(false);
              panel3.setVisible(false);
            }
          }
        });
  }
Ejemplo n.º 26
0
  public SpriteDebugerUI() {
    super("Mugen StateControler Debugger");
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setLayout(new BorderLayout());
    JPanel pnlContenpane = (JPanel) getContentPane();

    // Left
    JPanel pnlLeft = new JPanel();
    pnlLeft.setLayout(new BoxLayout(pnlLeft, BoxLayout.PAGE_AXIS));

    JPanel pnlForSprChooser = new JPanel();
    pnlForSprChooser.setLayout(new BoxLayout(pnlForSprChooser, BoxLayout.LINE_AXIS));

    lblForCbxSprChooser = new JLabel("Click Here After Sprite Load");

    lblForCbxSprChooser.setPreferredSize(new Dimension(70, 25));

    Collection<Sprite> sprites = GameFight.getInstance().getSprites();
    List<String> spriteIdList = new ArrayList<String>();
    for (Sprite s : sprites) spriteIdList.add(s.getSpriteId());

    cbxSprChooser = new JComboBox(spriteIdList.toArray());
    cbxSprChooser.setPreferredSize(new Dimension(100, 25));
    cbxSprChooser.setMaximumSize(new Dimension(100, 25));
    cbxSprChooser.setMinimumSize(new Dimension(100, 25));
    cbxSprChooser.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    pnlForSprChooser.add(lblForCbxSprChooser);
    pnlForSprChooser.add(cbxSprChooser);

    lblForCbxSprChooser.addMouseListener(
        new MouseAdapter() {

          public void mouseClicked(MouseEvent e) {
            Collection<Sprite> sprites = GameFight.getInstance().getSprites();
            DefaultComboBoxModel model = new DefaultComboBoxModel();
            for (Sprite s : sprites) model.addElement(s.getSpriteId());
            cbxSprChooser.setModel(model);
          }
        });

    pnlForSprChooser.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    pnlLeft.add(pnlForSprChooser);

    lstActions = new JList();
    lstActions.setModel(new DefaultListModel());

    JScrollPane scpActions = new JScrollPane(lstActions);
    scpActions.setPreferredSize(new Dimension(170, 600));
    scpActions.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    pnlLeft.add(scpActions);

    // Right
    JPanel pnlRight = new JPanel();
    pnlRight.setLayout(new BorderLayout());
    HighlightedDocument kit = new HighlightedDocument();
    txaStateCtrInfo = new JTextPane(kit);

    UndoManager manager = new UndoManager();
    txaStateCtrInfo.getDocument().addUndoableEditListener(manager);
    Action undoAction = new UndoAction(manager);
    Action redoAction = new RedoAction(manager);
    txaStateCtrInfo.registerKeyboardAction(
        undoAction,
        KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK),
        JComponent.WHEN_FOCUSED);
    txaStateCtrInfo.registerKeyboardAction(
        redoAction,
        KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK),
        JComponent.WHEN_FOCUSED);

    JScrollPane scpStateCtrl = new JScrollPane(txaStateCtrInfo);
    scpStateCtrl.setPreferredSize(new Dimension(400, 600));
    scpStateCtrl.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));

    pnlRight.add(scpStateCtrl);

    JButton btnSave = new JButton("Save");
    btnSave.setPreferredSize(new Dimension(150, 25));
    pnlRight.add(btnSave, BorderLayout.PAGE_END);

    // Add Both pnl
    pnlContenpane.add(pnlLeft, BorderLayout.LINE_START);
    pnlContenpane.add(pnlRight, BorderLayout.CENTER);

    // Listener
    ActionListener al =
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            String spriteId = (String) cbxSprChooser.getSelectedItem();
            if (spriteId != null) {
              DefaultListModel model = (DefaultListModel) lstActions.getModel();
              model.clear();
              txaStateCtrInfo.setText("");

              Sprite spr = GameFight.getInstance().getSpriteInstance(spriteId);
              List<StateDef> list = spr.getSpriteState().getAllStateDef();

              Collections.sort(
                  list,
                  new Comparator<StateDef>() {

                    public int compare(StateDef o1, StateDef o2) {
                      // TODO Auto-generated method stub
                      return o1.getIntId() - o2.getIntId();
                    }
                  });
              for (StateDef statedef : list) {
                //						String action = statedef.getId();
                model.addElement(statedef);
              }
            }
          }
        };
    cbxSprChooser.addActionListener(al);
    al.actionPerformed(null);

    lstActions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lstActions.addListSelectionListener(
        new ListSelectionListener() {

          public void valueChanged(ListSelectionEvent e) {
            StateDef sdef = (StateDef) lstActions.getSelectedValue();
            if (sdef == null) {
              txaStateCtrInfo.setText("");
              return;
            }
            String action = sdef.getId();
            if (action != null) {
              String spriteId = (String) cbxSprChooser.getSelectedItem();
              StringBuilder builder = new StringBuilder();
              if (Integer.parseInt(action) < 0) {
                for (StateDef state :
                    GameFight.getInstance()
                        .getSpriteInstance(spriteId)
                        .getSpriteState()
                        .getNegativeStateSef()) {
                  if (state.getId().equals(action)) {
                    for (GroupText grp : state.getGroups()) {
                      builder.append(grp.getSectionRaw() + "\n");
                      builder.append(grp.getText() + "\n");
                    }
                  }
                }

              } else {
                for (GroupText grp :
                    GameFight.getInstance()
                        .getSpriteInstance(spriteId)
                        .getSpriteState()
                        .getStateDef(action)
                        .getGroups()) {
                  builder.append(grp.getSectionRaw() + "\n");
                  builder.append(grp.getText() + "\n");
                }
              }
              txaStateCtrInfo.setText(builder.toString());
            }
          }
        });
    btnSave.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            String spriteId = (String) cbxSprChooser.getSelectedItem();
            StateDef sdef = (StateDef) lstActions.getSelectedValue();
            String action = sdef.getId();
            String raw = txaStateCtrInfo.getText();
            try {

              Sprite sprite = GameFight.getInstance().getSpriteInstance(spriteId);
              StateDef statedef = sprite.getSpriteState().getStateDef(action);
              statedef.getGroups().clear();
              List<GroupText> groups = Parser.getGroupTextMap(new StringReader(raw), true);
              statedef.getGroups().addAll(groups);
              statedef.recompile();

            } catch (Exception e1) {
              e1.printStackTrace();
            }
          }
        });
    pack();
  }
Ejemplo n.º 27
0
  public Viajes() {
    super.setBounds(181, 61, 700, 538); // (ancho,alto)
    super.setLayout(null);
    super.setOpaque(false);
    super.setVisible(false);

    try {
      UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    tbDatos = new JTable(dataModel);
    tbDatos.setEnabled(false);
    tbDatos.setAutoResizeMode(5);
    tbDatos.setCellSelectionEnabled(true);
    tbDatos.setForeground(Color.BLACK);
    pnDatos = new JScrollPane(tbDatos);
    pnDatos.setBounds(30, 30, 640, 478);
    pnDatos.setVisible(false);
    this.add(pnDatos);
    llenarDatos();

    jlbCodigo = new JLabel("*Código");
    jlbCodigo.setBounds(90, 100, 220, 25);
    jlbCodigo.setForeground(Color.BLACK);
    jlbCodigo.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbCodigo);

    jtxtCodigo = new JTextField("");
    jtxtCodigo.setBounds(90, 125, 520, 30);
    jtxtCodigo.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
    jtxtCodigo.addKeyListener(this);
    this.add(jtxtCodigo);

    jlbOrigen = new JLabel("*Origen");
    jlbOrigen.setBounds(90, 180, 150, 25);
    jlbOrigen.setForeground(Color.BLACK);
    jlbOrigen.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbOrigen);

    jcbOrigen = new JComboBox();
    jcbOrigen.setBorder(null);
    jcbOrigen.setBackground(Color.WHITE);
    jcbOrigen.addItem("Medellín");
    jcbOrigen.addItem("Bogotá");
    jcbOrigen.addItem("Barranquilla");
    jcbOrigen.setBounds(90, 205, 250, 30);
    this.add(jcbOrigen);

    jlbDestino = new JLabel("*Destino");
    jlbDestino.setBounds(360, 180, 150, 25);
    jlbDestino.setForeground(Color.BLACK);
    jlbDestino.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbDestino);

    jcbDestino = new JComboBox();
    jcbDestino.setBorder(null);
    jcbDestino.setBackground(Color.WHITE);
    jcbDestino.addItem("Bogotá");
    jcbDestino.addItem("Medellín");
    jcbDestino.addItem("Barranquilla");
    jcbDestino.setBounds(360, 205, 250, 30);
    this.add(jcbDestino);

    jlbPrecio = new JLabel("*Precio");
    jlbPrecio.setBounds(90, 260, 120, 25);
    jlbPrecio.setForeground(Color.BLACK);
    jlbPrecio.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbPrecio);

    jtxtPrecio = new JTextField("");
    jtxtPrecio.setBounds(90, 285, 520, 30);
    jtxtPrecio.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
    jtxtPrecio.addKeyListener(this);
    this.add(jtxtPrecio);

    jlbEstado = new JLabel("*Estado");
    jlbEstado.setBounds(90, 340, 150, 25);
    jlbEstado.setForeground(Color.BLACK);
    jlbEstado.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbEstado);

    jcbEstado = new JComboBox();
    jcbEstado.setBorder(null);
    jcbEstado.setBackground(Color.WHITE);
    jcbEstado.addItem("Activo");
    jcbEstado.addItem("Inactivo");
    jcbEstado.setBounds(90, 365, 520, 30);
    this.add(jcbEstado);

    jbtnListar = new JButton(" Lista");
    jbtnListar.setBounds(0, 0, 233, 60);
    jbtnListar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/List-26.png")));
    jbtnListar.setBorder(null);
    jbtnListar.setBackground(new Color(0, 154, 225));
    jbtnListar.setForeground(Color.WHITE);
    jbtnListar.setFont(new Font("Segoe UI", Font.PLAIN, 20));
    jbtnListar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnListar.addMouseListener(this);
    jbtnListar.addActionListener(this);
    jbtnListar.setFocusPainted(false);
    this.add(jbtnListar);

    jbtnBuscar = new JButton(" Buscar");
    jbtnBuscar.setBounds(233, 0, 234, 60);
    jbtnBuscar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/Search-26.png")));
    jbtnBuscar.setBorder(null);
    jbtnBuscar.setBackground(new Color(0, 154, 225));
    jbtnBuscar.setForeground(Color.WHITE);
    jbtnBuscar.setFont(new Font("Segoe UI", Font.PLAIN, 20));
    jbtnBuscar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnBuscar.addMouseListener(this);
    jbtnBuscar.addActionListener(this);
    jbtnBuscar.setFocusPainted(false);
    this.add(jbtnBuscar);

    jbtnActualizar = new JButton(" Actualizar");
    jbtnActualizar.setBounds(233, 0, 234, 60);
    jbtnActualizar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/Edit-26.png")));
    jbtnActualizar.setBorder(null);
    jbtnActualizar.setBackground(new Color(0, 154, 225));
    jbtnActualizar.setForeground(Color.WHITE);
    jbtnActualizar.setFont(new Font("Segoe UI", Font.PLAIN, 20));
    jbtnActualizar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnActualizar.addMouseListener(this);
    jbtnActualizar.setVisible(false);
    jbtnActualizar.addActionListener(this);
    jbtnActualizar.setFocusPainted(false);
    this.add(jbtnActualizar);

    jbtnLimpiar = new JButton(" Limpiar");
    jbtnLimpiar.setBounds(467, 0, 233, 60);
    jbtnLimpiar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/Clean-26.png")));
    jbtnLimpiar.setBorder(null);
    jbtnLimpiar.setBackground(new Color(0, 154, 225));
    jbtnLimpiar.setForeground(Color.WHITE);
    jbtnLimpiar.setFont(new Font("Segoe UI", Font.PLAIN, 20));
    jbtnLimpiar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnLimpiar.addMouseListener(this);
    jbtnLimpiar.addActionListener(this);
    jbtnLimpiar.setFocusPainted(false);
    this.add(jbtnLimpiar);

    jpBotones = new JPanel();
    jpBotones.setBackground(new Color(0, 123, 183));
    jpBotones.add(jbtnListar);
    jpBotones.add(jbtnBuscar);
    jpBotones.add(jbtnActualizar);
    jpBotones.add(jbtnLimpiar);
    jpBotones.setLayout(null);
    jpBotones.setBounds(0, 478, 700, 60);
    this.add(jpBotones);

    jlbValidar = new JLabel("Los campos con (*) son obligatorios");
    jlbValidar.setForeground(Color.WHITE);
    jlbValidar.setBounds(80, 8, 300, 27);
    jlbValidar.setFont(new Font("Segoe UI", Font.PLAIN, 17));
    this.add(jlbValidar);

    jpError = new JPanel();
    jpError.add(jlbValidar);
    jpError.setLayout(null);
    jpError.setBackground(new Color(0, 123, 183));
    jpError.setBounds(0, 0, 700, 45);
    this.add(jpError);

    this.repaint();
  }
Ejemplo n.º 28
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