public BooleanPMListCellRenderer() {
   cb.setHorizontalAlignment(SwingConstants.CENTER);
   cb.setBorderPainted(false);
   cb.setOpaque(false);
   this.setLayout(new BorderLayout());
   this.add(this.cb, BorderLayout.CENTER);
 }
    public MyJObject(int i) {
      CourseCheckBox = new JCheckBox(DataTransfer.Courses.elementAt(i));
      CourseCheckBox.setForeground(Color.WHITE);
      CourseCheckBox.setFont(new Font("SERRIF", Font.BOLD + Font.ITALIC, 13));
      CourseCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
      CourseCheckBox.setOpaque(false);
      CourseCheckBox.setSelected(true);

      TotalMarks =
          new JLabel(
              Float.toString(
                  Float.valueOf(
                      TwoDecimal.format(Float.parseFloat(DataTransfer.Total.elementAt(i))))),
              SwingConstants.CENTER);
      TotalMarks.setForeground(Color.WHITE);
      TotalMarks.setFont(new Font("SERRIF", Font.BOLD + Font.ITALIC, 13));

      GradePoint = new JLabel(DataTransfer.GradePoint.elementAt(i), SwingConstants.LEFT);
      GradePoint.setForeground(Color.WHITE);
      GradePoint.setFont(new Font("SERRIF", Font.ITALIC, 13));

      LetterGrade = new JLabel(DataTransfer.LetterGrade.elementAt(i), SwingConstants.LEFT);
      LetterGrade.setForeground(Color.WHITE);
      LetterGrade.setFont(new Font("SERRIF", Font.PLAIN, 13));

      CreditLabel = new JLabel(Credit.elementAt(i), SwingConstants.LEFT);
      CreditLabel.setForeground(Color.WHITE);
      CreditLabel.setFont(new Font("SERRIF", Font.PLAIN, 13));

      ExamTypeLabel = new JLabel(DataTransfer.ExamType.elementAt(i), SwingConstants.LEFT);
      ExamTypeLabel.setForeground(Color.WHITE);
      ExamTypeLabel.setFont(new Font("SERRIF", Font.PLAIN, 12));
    }
  public Component getTableCellRendererComponent(
      JTable tabl, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

    // if(value==null)return new JLabel("EMPTY");
    // if(tabl==null)return new JLabel("EMPTY2");
    // if(super==null)return new JLabel("EMPTY3");
    Component c =
        super.getTableCellRendererComponent(
            tabl, value.toString(), isSelected, hasFocus, row, column);

    if (value instanceof Component) {
      return (Component) value;
    }

    if (value instanceof Boolean) {
      JCheckBox jc = new JCheckBox();
      jc.setEnabled((Boolean) value);
      jc.setHorizontalAlignment(SwingConstants.CENTER);
      jc.setBackground(c.getBackground());
      return jc;
    }

    return super.getTableCellRendererComponent(
        tabl, value.toString(), isSelected, hasFocus, row, column);
  }
Exemplo n.º 4
0
 private JCheckBox createCheckBox(String s, boolean b, int y) {
   JCheckBox cb = new JCheckBox(s, b);
   cb.setFont(font);
   cb.setHorizontalAlignment(JCheckBox.LEFT);
   cb.addItemListener(this);
   Java2Demo.addToGridBag(this, cb, 0, y, 1, 1, 1.0, 1.0);
   return cb;
 }
 /** Configures a checkbox with the properties of tree cell renderes. */
 private static JCheckBox configureCheckBox(JCheckBox checkBox) {
   checkBox.setHorizontalAlignment(JCheckBox.LEFT);
   checkBox.setFont(UIManager.getFont("Tree.font"));
   checkBox.setBorderPainted(false);
   checkBox.setFocusPainted(false);
   checkBox.setFocusable(false);
   checkBox.setOpaque(false);
   return checkBox;
 }
Exemplo n.º 6
0
  /**
   * <i>Description:</i>
   *
   * <p>see <a href=https://en.wikipedia.org/wiki/Hostname>https://en.wikipedia.org
   * /wiki/Hostname</a> for valid hostname
   *
   * @return
   */
  @SuppressWarnings("unchecked")
  protected JPanel getHostEntryPanel() {
    if (pnlHostEntry == null) {
      pnlHostEntry = new JPanel(new BorderLayout(5, 5));
      pnlHostEntry.setOpaque(false);

      JPanel panel = new JPanel(new GridLayout(1, 2, 10, 5));
      panel.setOpaque(false);
      String hostNameChars = UIConstants.DIGITS + UIConstants.LETTERS + "-.";
      txtFldHostName = new SafeTextField(false, 253);
      ((SafeTextField) txtFldHostName).setValidChars(hostNameChars);
      for (DocumentListener listener : hostInfoListener.getDocumentListeners()) {
        txtFldHostName.getDocument().addDocumentListener(listener);
      }
      FieldPair<JFormattedTextField> fp =
          new FieldPair<JFormattedTextField>(STLConstants.K0051_HOST.getValue(), txtFldHostName);
      panel.add(fp);

      txtFldPortNum =
          new SafeNumberField<Integer>(new DecimalFormat("###"), 0, false, 65535, false);
      // only positive integer
      ((SafeNumberField<Integer>) txtFldPortNum).setValidChars(UIConstants.DIGITS);
      for (DocumentListener listener : hostInfoListener.getDocumentListeners()) {
        txtFldPortNum.getDocument().addDocumentListener(listener);
      }
      txtFldPortNum.setText(STLConstants.K3015_DEFAULT_PORT.getValue());
      fp =
          new FieldPair<JFormattedTextField>(
              STLConstants.K1035_CONFIGURATION_PORT.getValue(), txtFldPortNum);
      panel.add(fp);
      pnlHostEntry.add(panel, BorderLayout.CENTER);

      chkboxSecureConnect =
          ComponentFactory.getIntelCheckBox(STLConstants.K2003_SECURE_CONNECT.getValue());
      chkboxSecureConnect.setFont(UIConstants.H5_FONT.deriveFont(Font.BOLD));
      chkboxSecureConnect.setForeground(UIConstants.INTEL_DARK_GRAY);
      chkboxSecureConnect.setHorizontalAlignment(JLabel.TRAILING);
      chkboxSecureConnect.setSelected(false);
      chkboxSecureConnect.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
              hostInfoListener.setDirty();
              boolean isSecureConnect = chkboxSecureConnect.isSelected();
              enableCerts(isSecureConnect);
            }
          });
      pnlHostEntry.add(chkboxSecureConnect, BorderLayout.EAST);
    }
    return pnlHostEntry;
  }
  public ModpackUpdateDialog(LaunchFrame instance, boolean modal) {
    super(instance, modal);

    setIconImage(
        Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));
    setTitle("Mod Pack Update Available");
    setBounds(300, 300, 300, 140);
    setResizable(false);

    panel.setLayout(null);
    panel.setBounds(0, 0, 300, 140);
    setContentPane(panel);

    textOne.setBounds(0, 0, 300, 30);
    textOne.setHorizontalAlignment(SwingConstants.CENTER);
    panel.add(textOne);

    textTwo.setBounds(0, 20, 300, 30);
    textTwo.setHorizontalAlignment(SwingConstants.CENTER);
    panel.add(textTwo);

    yesButton.setBounds(65, 80, 80, 25);
    yesButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            ModManager.update = true;
            ModManager.backup = backup.isSelected();
            setVisible(false);
          }
        });
    panel.add(yesButton);

    noButton.setBounds(155, 80, 80, 25);
    noButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            ModManager.update = false;
            setVisible(false);
          }
        });
    panel.add(noButton);

    backup.setBounds(0, 45, 300, 30);
    backup.setHorizontalAlignment(SwingConstants.CENTER);
    panel.add(backup);
  }
Exemplo n.º 8
0
  public CheckBoxMessage(String message, String cbText, boolean defaultValue) {
    cb = new JCheckBox(cbText, defaultValue);
    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);
    GridBagConstraints con = new GridBagConstraints();
    con.gridwidth = GridBagConstraints.REMAINDER;

    JLabel lab = new JLabel(message + '\n');
    cb.setHorizontalAlignment(SwingConstants.LEFT);
    gbl.setConstraints(lab, con);
    add(lab);
    con.anchor = GridBagConstraints.WEST;
    con.insets = new Insets(10, 0, 0, 0);
    gbl.setConstraints(cb, con);
    add(cb);
  }
  @Override
  public Component getTableCellEditorComponent(
      JTable table, Object value, boolean isSelected, int row, int column) {

    editGeo = (GeoBoolean) value;
    delegate.setValue(editGeo.getBoolean());
    editing = true;
    checkBox.setBackground(table.getBackground());
    checkBox.setHorizontalAlignment(SwingConstants.CENTER);

    // enabled == isIndependent
    checkBox.setEnabled(editGeo.isIndependent());

    if (editGeo.isLabelVisible()) {
      // checkBox.setText(editGeo.getCaption());
    }
    return editorComponent;
  }
  @Override
  public void addWithConfigOption(JPanel panel) {
    JPanel mainPanel = generateEmptyRightPanel();

    JCheckBox check = new JCheckBox(name);
    check.setSelected(value);
    check.setHorizontalAlignment(JCheckBox.CENTER);
    check.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            JCheckBox checkBox = (JCheckBox) e.getSource();
            value = checkBox.isSelected();
            MainFrame.treeUpdated();
          }
        });

    mainPanel.add(check);
    panel.add(mainPanel, BorderLayout.CENTER);
  }
Exemplo n.º 11
0
  private JComponent getButtonPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    choiceType = new JComboBox<PersonTypeItem>();
    choiceType.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceType.getPreferredSize().getHeight()));
    DefaultComboBoxModel<PersonTypeItem> personTypeModel = new DefaultComboBoxModel<>();
    personTypeModel.addElement(
        new PersonTypeItem(resourceMap.getString("primaryRole.choice.text"), null)); // $NON-NLS-1$
    for (int i = 1; i < Person.T_NUM; ++i) {
      personTypeModel.addElement(
          new PersonTypeItem(Person.getRoleDesc(i, campaign.getFaction().isClan()), i));
    }
    personTypeModel.addElement(
        new PersonTypeItem(Person.getRoleDesc(0, campaign.getFaction().isClan()), 0));
    // Add "none" for generic AsTechs
    choiceType.setModel(personTypeModel);
    choiceType.setSelectedIndex(0);
    choiceType.addActionListener(
        e -> {
          personnelFilter.setPrimaryRole(((PersonTypeItem) choiceType.getSelectedItem()).id);
          updatePersonnelTable();
        });
    panel.add(choiceType);

    choiceExp = new JComboBox<PersonTypeItem>();
    choiceExp.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceType.getPreferredSize().getHeight()));
    DefaultComboBoxModel<PersonTypeItem> personExpModel = new DefaultComboBoxModel<>();
    personExpModel.addElement(
        new PersonTypeItem(resourceMap.getString("experience.choice.text"), null)); // $NON-NLS-1$
    for (int i = 0; i < 5; ++i) {
      personExpModel.addElement(new PersonTypeItem(SkillType.getExperienceLevelName(i), i));
    }
    choiceExp.setModel(personExpModel);
    choiceExp.setSelectedIndex(0);
    choiceExp.addActionListener(
        e -> {
          personnelFilter.setExpLevel(((PersonTypeItem) choiceExp.getSelectedItem()).id);
          updatePersonnelTable();
        });
    panel.add(choiceExp);

    choiceSkill = new JComboBox<String>();
    choiceSkill.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceSkill.getPreferredSize().getHeight()));
    DefaultComboBoxModel<String> personSkillModel = new DefaultComboBoxModel<>();
    personSkillModel.addElement(choiceNoSkill);
    for (String skill : SkillType.getSkillList()) {
      personSkillModel.addElement(skill);
    }
    choiceSkill.setModel(personSkillModel);
    choiceSkill.setSelectedIndex(0);
    choiceSkill.addActionListener(
        e -> {
          if (choiceNoSkill.equals(choiceSkill.getSelectedItem())) {
            personnelFilter.setSkill(null);
            ((SpinnerNumberModel) skillLevel.getModel()).setMaximum(10);
            buttonSpendXP.setEnabled(false);
          } else {
            String skillName = (String) choiceSkill.getSelectedItem();
            personnelFilter.setSkill(skillName);
            int maxSkillLevel = SkillType.getType(skillName).getMaxLevel();
            int currentLevel = (Integer) skillLevel.getModel().getValue();
            ((SpinnerNumberModel) skillLevel.getModel()).setMaximum(maxSkillLevel);
            if (currentLevel > maxSkillLevel) {
              skillLevel.getModel().setValue(Integer.valueOf(maxSkillLevel));
            }
            buttonSpendXP.setEnabled(true);
          }
          updatePersonnelTable();
        });
    panel.add(choiceSkill);

    panel.add(Box.createRigidArea(new Dimension(10, 10)));
    panel.add(new JLabel(resourceMap.getString("targetSkillLevel.text"))); // $NON-NLS-1$

    skillLevel = new JSpinner(new SpinnerNumberModel(10, 0, 10, 1));
    skillLevel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) skillLevel.getPreferredSize().getHeight()));
    skillLevel.addChangeListener(
        e -> {
          personnelFilter.setMaxSkillLevel((Integer) skillLevel.getModel().getValue());
          updatePersonnelTable();
        });
    panel.add(skillLevel);

    allowPrisoners = new JCheckBox(resourceMap.getString("allowPrisoners.text")); // $NON-NLS-1$
    allowPrisoners.setHorizontalAlignment(SwingConstants.LEFT);
    allowPrisoners.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) allowPrisoners.getPreferredSize().getHeight()));
    allowPrisoners.addChangeListener(
        e -> {
          personnelFilter.setAllowPrisoners(allowPrisoners.isSelected());
          updatePersonnelTable();
        });
    JPanel allowPrisonersPanel = new JPanel(new GridLayout(1, 1));
    allowPrisonersPanel.setAlignmentY(JComponent.LEFT_ALIGNMENT);
    allowPrisonersPanel.add(allowPrisoners);
    allowPrisonersPanel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) allowPrisonersPanel.getPreferredSize().getHeight()));
    panel.add(allowPrisonersPanel);

    panel.add(Box.createVerticalGlue());

    matchedPersonnelLabel = new JLabel(""); // $NON-NLS-1$
    matchedPersonnelLabel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) matchedPersonnelLabel.getPreferredSize().getHeight()));
    panel.add(matchedPersonnelLabel);

    JPanel buttons = new JPanel(new FlowLayout());
    buttons.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) buttons.getPreferredSize().getHeight()));

    buttonSpendXP = new JButton(resourceMap.getString("spendXP.text")); // $NON-NLS-1$
    buttonSpendXP.setEnabled(false);
    buttonSpendXP.addActionListener(e -> spendXP());
    buttons.add(buttonSpendXP);

    JButton button = new JButton(resourceMap.getString("close.text")); // $NON-NLS-1$
    button.addActionListener(e -> setVisible(false));
    buttons.add(button);

    panel.add(buttons);

    panel.setMaximumSize(new Dimension((int) panel.getPreferredSize().getWidth(), Short.MAX_VALUE));
    panel.setMinimumSize(new Dimension((int) panel.getPreferredSize().getWidth(), 300));

    return panel;
  }
Exemplo n.º 12
0
  public PanelEpisodioDownload(Episodio e) {
    ep = e;
    setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    setSize(375, 95);
    setLayout(new BorderLayout(0, 0));

    JPanel panel = new JPanel();
    add(panel, BorderLayout.NORTH);
    panel.setLayout(new BorderLayout(0, 0));

    JPanel panel_5 = new JPanel();
    panel.add(panel_5, BorderLayout.WEST);

    chckbxnomeserie = new JCheckBox("<html><b>" + ep.getSerieTV().getNomeSerie() + "</b></html>");
    panel_5.add(chckbxnomeserie);
    chckbxnomeserie.setHorizontalAlignment(SwingConstants.CENTER);
    chckbxnomeserie.setSelected(true);

    JPanel panel_6 = new JPanel();
    panel.add(panel_6, BorderLayout.EAST);

    btnX = new JButton("");
    btnX.setIcon(new ImageIcon(PanelEpisodioDownload.class.getResource("/GUI/res/Xclose.png")));
    btnX.setPreferredSize(buttonSize);
    panel_6.add(btnX);

    JPanel panel_1 = new JPanel();
    add(panel_1, BorderLayout.SOUTH);
    panel_1.setLayout(new BorderLayout(0, 0));

    JPanel panel_3 = new JPanel();
    panel_1.add(panel_3, BorderLayout.EAST);

    btnInfo = new JButton("");
    btnInfo.setIcon(new ImageIcon(PanelEpisodioDownload.class.getResource("/GUI/res/info.png")));
    // TODO abilitare quando verrà creata la classe per TheTVDB
    btnInfo.setPreferredSize(buttonSize);
    btnInfo.setEnabled(false);
    panel_3.add(btnInfo);

    JPanel panel_2 = new JPanel();
    panel_1.add(panel_2, BorderLayout.CENTER);

    btnHd = new JButton("HD");
    btnHd.setEnabled(false);
    Torrent t_hd = ep.getLinkHD();
    if (t_hd != null) {
      if (t_hd.getScaricato() == Torrent.SCARICARE) btnHd.setEnabled(true);
    }
    panel_2.add(btnHd);

    btnSd = new JButton("SD");
    Torrent t_sd = ep.getLinkNormale();
    btnSd.setEnabled(false);
    if (t_sd != null) {
      if (t_sd.getScaricato() == Torrent.SCARICARE) btnSd.setEnabled(true);
    }
    panel_2.add(btnSd);

    btnPreair = new JButton("PreAir");
    btnPreair.setEnabled(false);
    Torrent t_pre = ep.getLinkPreair();
    if (t_pre != null) {
      if (t_pre.getScaricato() == Torrent.SCARICARE) btnPreair.setEnabled(true);
    }
    panel_2.add(btnPreair);

    JPanel panel_4 = new JPanel();
    add(panel_4, BorderLayout.WEST);

    JLabel lblStagione = new JLabel("<html>Stagione: </html>");
    panel_4.add(lblStagione);

    JLabel lblSeason = new JLabel("<html><b>" + ep.getStagione() + "</b></html>");
    panel_4.add(lblSeason);

    JLabel lblEpisodio = new JLabel("<html>Episodio:</html>");
    panel_4.add(lblEpisodio);

    JLabel lblEpisode = new JLabel("<html><b>" + ep.getEpisodio() + "</html></b>");
    panel_4.add(lblEpisode);

    addListener();
  }
Exemplo n.º 13
0
  /**
   * Initializes and draws the dialog.
   *
   * @param parent the parent frame for this dialog.
   * @param sKey the property string associated with this message - used to set FormatProperties
   *     when user ticks box.
   */
  public UIHintDialog(JFrame parent, int nType) {

    super(parent, true);
    setTitle("Hint");

    this.nType = nType;

    if (nType == PASTE_HINT) {
      this.sMessage =
          LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UIHintDialog.pasteHint1")
              + "\n\n"
              + LanguageProperties.getString(
                  LanguageProperties.DIALOGS_BUNDLE, "UIHintDialog.pasteHint2")
              + "\n\n"
              + LanguageProperties.getString(
                  LanguageProperties.DIALOGS_BUNDLE, "UIHintDialog.pasteHint3");
    }

    oContentPane = getContentPane();
    oContentPane.setLayout(new BorderLayout());

    oDetailsPanel = new JPanel(new BorderLayout());

    JPanel imagePanel = new JPanel();
    imagePanel.setBorder(new EmptyBorder(10, 10, 10, 0));

    oImage = UIImages.getNodeImage(ICoreConstants.POSITION);
    oImageLabel = new JLabel(oImage);
    oImageLabel.setVerticalAlignment(SwingConstants.TOP);
    imagePanel.add(oImageLabel);

    oDetailsPanel.add(imagePanel, BorderLayout.WEST);

    oTextArea = new JTextArea(sMessage);
    oTextArea.setEditable(false);
    oTextArea.setFont(new Font("Dialog", Font.PLAIN, 12)); // $NON-NLS-1$
    oTextArea.setBackground(oDetailsPanel.getBackground());
    oTextArea.setColumns(35);
    oTextArea.setLineWrap(true);
    oTextArea.setWrapStyleWord(true);
    oTextArea.setSize(oTextArea.getPreferredSize());

    JPanel textPanel = new JPanel();
    textPanel.setBorder(new EmptyBorder(10, 10, 20, 10));
    textPanel.setBorder(new EmptyBorder(10, 10, 20, 10));
    textPanel.add(oTextArea);

    JPanel oCheckBoxPanel = new JPanel();
    cbShowPasteHint = new JCheckBox();
    cbShowPasteHint.setText(
        LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UIHintDialog.hideHint"));
    cbShowPasteHint.setSelected(false);
    cbShowPasteHint.setHorizontalAlignment(SwingConstants.LEFT);
    oCheckBoxPanel.add(cbShowPasteHint);

    oDetailsPanel.add(textPanel, BorderLayout.CENTER);
    oDetailsPanel.add(oCheckBoxPanel, BorderLayout.SOUTH);

    oButtonPanel = new UIButtonPanel();
    pbClose =
        new UIButton(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE, "UIHintDialog.closeButton")); // $NON-NLS-1$
    pbClose.setMnemonic(
        LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE, "UIHintDialog.closeButtonMnemonic")
            .charAt(0));
    pbClose.addActionListener(this);
    oButtonPanel.addButton(pbClose);

    oContentPane.add(oDetailsPanel, BorderLayout.CENTER);
    oContentPane.add(oButtonPanel, BorderLayout.SOUTH);

    pack();
    setResizable(false);
  }
Exemplo n.º 14
0
 public CheckBoxEditor() {
   super(new JCheckBox());
   JCheckBox checkBox = (JCheckBox) editorComponent;
   checkBox.setHorizontalAlignment(JCheckBox.CENTER);
 }
  public AttributesEditionPanel(
      final Component parent,
      final DiagramManager diagramManager,
      final ClassElement classElement,
      final Classifier element) {
    this.diagramManager = diagramManager;
    this.classElement = classElement;
    this.element = element;
    this.parent = parent;

    attributesTableModel = new AttributeTableModel(element);

    panel = new JPanel();
    panel.setBorder(BorderFactory.createTitledBorder(""));

    GroupLayout groupLayout = new GroupLayout(this);
    groupLayout.setHorizontalGroup(
        groupLayout
            .createParallelGroup(Alignment.LEADING)
            .addComponent(panel, GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE));
    groupLayout.setVerticalGroup(
        groupLayout
            .createParallelGroup(Alignment.LEADING)
            .addComponent(panel, GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE));

    scrollpane = new JScrollPane();
    scrollpane.setMinimumSize(new Dimension(0, 0));
    scrollpane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollpane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));

    table = new JTable();
    scrollpane.setViewportView(table);
    table.setModel(attributesTableModel);

    table.setBorder(new EmptyBorder(0, 0, 0, 0));
    table.setFillsViewportHeight(true);
    table.setGridColor(Color.LIGHT_GRAY);
    table.setSelectionBackground(ColorPalette.getInstance().getColor(ThemeColor.GREEN_MEDIUM));
    table.setSelectionForeground(Color.BLACK);
    table.setFocusable(false);
    table.setRowHeight(23);

    btnCreate = new JButton("");
    btnCreate.setFocusable(false);
    btnCreate.setToolTipText("Add new attribute to this class");
    btnCreate.setIcon(
        new ImageIcon(AttributesEditionPanel.class.getResource("/resources/icons/x16/new.png")));
    btnCreate.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            addAttribute(arg0);
          }
        });

    btnDelete = new JButton("");
    btnDelete.setFocusable(false);
    btnDelete.setToolTipText("Delete selected attribute");
    btnDelete.setIcon(
        new ImageIcon(AttributesEditionPanel.class.getResource("/resources/icons/x16/cross.png")));
    btnDelete.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            deleteAttribute(arg0);
          }
        });

    btnUp = new JButton("");
    btnUp.setFocusable(false);
    btnUp.setToolTipText("Move up selected attribute");
    btnUp.setIcon(
        new ImageIcon(
            AttributesEditionPanel.class.getResource("/resources/icons/x16/arrow_up.png")));
    btnUp.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            moveUpAttribute();
          }
        });

    btnDown = new JButton("");
    btnDown.setFocusable(false);
    btnDown.setToolTipText("Move down selected attribute");
    btnDown.setIcon(
        new ImageIcon(
            AttributesEditionPanel.class.getResource("/resources/icons/x16/arrow_down.png")));
    btnDown.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            moveDownAttribute();
          }
        });

    btnEdit = new JButton("");
    btnEdit.setEnabled(true);
    btnEdit.setFocusable(false);
    btnEdit.setToolTipText("Edit selected attribute");
    btnEdit.setIcon(
        new ImageIcon(AttributesEditionPanel.class.getResource("/resources/icons/x16/pencil.png")));
    btnEdit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            int row = table.getSelectedRow();
            if (row >= 0) {
              Property p = attributesTableModel.getEntry(row);
              if (parent instanceof JFrame) {
                AttributeDialog dialog =
                    new AttributeDialog(
                        (JFrame) parent, diagramManager, classElement, element, p, false);
                dialog.setLocationRelativeTo(parent);
                dialog.setVisible(true);
              } else if (parent instanceof JDialog) {
                AttributeDialog dialog =
                    new AttributeDialog(
                        (JDialog) parent, diagramManager, classElement, element, p, false);
                dialog.setLocationRelativeTo(parent);
                dialog.setVisible(true);
              }
            }
          }
        });

    cbxVisible = new JCheckBox("Turn attributes visible");
    cbxVisible.setPreferredSize(new Dimension(140, 20));
    cbxVisible.setHorizontalAlignment(SwingConstants.LEFT);

    GroupLayout gl_panel = new GroupLayout(panel);
    gl_panel.setHorizontalGroup(
        gl_panel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                Alignment.TRAILING,
                gl_panel
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        gl_panel
                            .createParallelGroup(Alignment.TRAILING)
                            .addComponent(
                                scrollpane,
                                Alignment.LEADING,
                                GroupLayout.DEFAULT_SIZE,
                                426,
                                Short.MAX_VALUE)
                            .addGroup(
                                gl_panel
                                    .createSequentialGroup()
                                    .addComponent(
                                        btnUp,
                                        GroupLayout.PREFERRED_SIZE,
                                        32,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(
                                        btnDown,
                                        GroupLayout.PREFERRED_SIZE,
                                        32,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(
                                        cbxVisible, GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
                                    .addGap(10)
                                    .addComponent(
                                        btnCreate,
                                        GroupLayout.PREFERRED_SIZE,
                                        32,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(
                                        btnDelete,
                                        GroupLayout.PREFERRED_SIZE,
                                        32,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(
                                        btnEdit,
                                        GroupLayout.PREFERRED_SIZE,
                                        32,
                                        GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap()));
    gl_panel.setVerticalGroup(
        gl_panel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                gl_panel
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        gl_panel
                            .createParallelGroup(Alignment.LEADING)
                            .addComponent(
                                btnDown, GroupLayout.PREFERRED_SIZE, 32, GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                btnUp, GroupLayout.PREFERRED_SIZE, 32, GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                cbxVisible,
                                GroupLayout.PREFERRED_SIZE,
                                32,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                btnCreate,
                                GroupLayout.PREFERRED_SIZE,
                                32,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                btnDelete,
                                GroupLayout.PREFERRED_SIZE,
                                32,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                btnEdit,
                                GroupLayout.PREFERRED_SIZE,
                                32,
                                GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(scrollpane, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                    .addGap(10)));
    panel.setLayout(gl_panel);
    this.setLayout(groupLayout);

    setSize(450, 221);

    if (classElement != null) {
      cbxVisible.setSelected(classElement.showAttributes());
      cbxVisible.setEnabled(true);
    } else {
      cbxVisible.setSelected(false);
      cbxVisible.setEnabled(false);
    }

    myPostInit();
  }
Exemplo n.º 16
0
  private void createLayout() {
    fromModuleScrollPane = new JScrollPane();
    fromModuleScrollPane.setBorder(new TitledBorder(dataControl.translate("FromModuleTreeTitle")));

    toModuleScrollPane = new JScrollPane();
    toModuleScrollPane.setBorder(new TitledBorder(dataControl.translate("ToModuleTreeTitle")));

    dependencyScrollPane = new JScrollPane();
    dependencyScrollPane.setBorder(new TitledBorder(dataControl.translate("DependencyTableTitle")));

    this.filterPanel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) filterPanel.getLayout();
    flowLayout.setAlignment(FlowLayout.LEFT);
    filterPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    filterPanel.setBorder(new TitledBorder(dataControl.translate("AnalyseDependencyFilter")));

    theLayout = new GroupLayout(this);
    theLayout.setHorizontalGroup(
        theLayout
            .createParallelGroup(Alignment.TRAILING)
            .addGroup(
                theLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        theLayout
                            .createParallelGroup(Alignment.TRAILING)
                            .addComponent(
                                dependencyScrollPane,
                                Alignment.LEADING,
                                GroupLayout.DEFAULT_SIZE,
                                497,
                                Short.MAX_VALUE)
                            .addComponent(
                                filterPanel,
                                Alignment.LEADING,
                                GroupLayout.DEFAULT_SIZE,
                                497,
                                Short.MAX_VALUE)
                            .addGroup(
                                theLayout
                                    .createSequentialGroup()
                                    .addComponent(
                                        fromModuleScrollPane,
                                        GroupLayout.DEFAULT_SIZE,
                                        234,
                                        Short.MAX_VALUE)
                                    .addGap(18)
                                    .addComponent(
                                        toModuleScrollPane,
                                        GroupLayout.DEFAULT_SIZE,
                                        245,
                                        Short.MAX_VALUE)))
                    .addContainerGap()));
    theLayout.setVerticalGroup(
        theLayout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                theLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        theLayout
                            .createParallelGroup(Alignment.LEADING)
                            .addComponent(
                                fromModuleScrollPane,
                                GroupLayout.DEFAULT_SIZE,
                                235,
                                Short.MAX_VALUE)
                            .addComponent(
                                toModuleScrollPane, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(
                        filterPanel,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(
                        dependencyScrollPane, GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addContainerGap()));

    indirectFilterBox.setSelected(true);
    indirectFilterBox.setHorizontalAlignment(SwingConstants.LEFT);
    filterPanel.add(indirectFilterBox);
    fromModuleScrollPane.setBackground(PANELBACKGROUND);
    toModuleScrollPane.setBackground(PANELBACKGROUND);
    dependencyScrollPane.setBackground(UIManager.getColor("Panel.background"));
  }
Exemplo n.º 17
0
  /** Create the frame. */
  public MRKFrame() {
    TotalReceived = 0;

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // setBounds(100, 100, 450, 300);

    mrkaddtodb = MRKaddtodb.getInstance();

    mrkaddtodb.LoadPreferences();

    setTitle("MarkList Collector");
    setSize(600, 409);
    setLocationRelativeTo(null);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    GridBagLayout gbl_contentPane = new GridBagLayout();
    gbl_contentPane.columnWidths = new int[] {102, 53, 102, 0, 0, 0, 0, 0, 0};
    gbl_contentPane.rowHeights = new int[] {0, 0, 0, 0, 28, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    gbl_contentPane.columnWeights =
        new double[] {0.0, 0.0, 0.0, 0.3, 1.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
    gbl_contentPane.rowWeights =
        new double[] {
          0.0,
          0.0,
          0.0,
          0.0,
          1.0,
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          Double.MIN_VALUE
        };
    contentPane.setLayout(gbl_contentPane);

    final DefaultTableModel model =
        new DefaultTableModel(data, col) {
          private static final long serialVersionUID = 1L;

          @Override
          public boolean isCellEditable(int row, int column) {
            // all cells false
            return false;
          }
        };

    CreateFolder();

    table = new JTable(model);
    TableColumn column0 = table.getTableHeader().getColumnModel().getColumn(0);
    column0.setHeaderValue("Pg Total");

    SetReceivedCount();
    // (DefaultTableCellRenderer)table.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(JLabel.RIGHT);
    TableCellRenderer rendererFromHeader = table.getTableHeader().getDefaultRenderer();
    JLabel headerLabel = (JLabel) rendererFromHeader;
    headerLabel.setHorizontalAlignment(JLabel.LEFT); // Here you can set the alignment you want.

    table.getColumnModel().getColumn(0).setMaxWidth(60);
    table.getColumnModel().getColumn(1).setPreferredWidth(202);
    scrollPane = new JScrollPane(table);

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    // table.setRowHeight(30);
    // table.setIntercellSpacing(new Dimension(8,8));
    table.getTableHeader().setResizingAllowed(false);

    btnStart = new JButton("Start");
    btnStart.setToolTipText("Start Process of Accepting Marklists");
    btnStart.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            fileindex = 0;
            GetAllFiles();
            TotalFiles = listOfFiles.length;
            ProcessLists();
          }
        });
    GridBagConstraints gbc_btnStart = new GridBagConstraints();
    gbc_btnStart.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnStart.insets = new Insets(0, 0, 5, 5);
    gbc_btnStart.gridx = 0;
    gbc_btnStart.gridy = 2;
    contentPane.add(btnStart, gbc_btnStart);

    Submitted = new JLabel("Submitted By");
    GridBagConstraints gbc_Submitted = new GridBagConstraints();
    gbc_Submitted.insets = new Insets(0, 0, 5, 5);
    gbc_Submitted.gridx = 2;
    gbc_Submitted.gridy = 2;
    contentPane.add(Submitted, gbc_Submitted);

    lblDivision = new JLabel("Division");
    GridBagConstraints gbc_lblDivision = new GridBagConstraints();
    gbc_lblDivision.insets = new Insets(0, 0, 5, 5);
    gbc_lblDivision.gridx = 0;
    gbc_lblDivision.gridy = 3;
    contentPane.add(lblDivision, gbc_lblDivision);

    DivField = new JTextField();
    GridBagConstraints gbc_DivField = new GridBagConstraints();
    gbc_DivField.insets = new Insets(0, 0, 5, 5);
    gbc_DivField.fill = GridBagConstraints.HORIZONTAL;
    gbc_DivField.gridx = 2;
    gbc_DivField.gridy = 3;
    contentPane.add(DivField, gbc_DivField);
    DivField.setColumns(5);
    DivField.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent e) {
            char keyChar = e.getKeyChar();
            if (Character.isLowerCase(keyChar)) {
              e.setKeyChar(Character.toUpperCase(keyChar));
            }
          }
        });
    table.setFont(new Font("COURIER", Font.PLAIN, 12));

    table.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    GridBagConstraints gbc_Entries = new GridBagConstraints();
    gbc_Entries.gridheight = 14;
    gbc_Entries.gridwidth = 8;
    gbc_Entries.fill = GridBagConstraints.BOTH;
    gbc_Entries.gridx = 4;
    gbc_Entries.gridy = 2;
    contentPane.add(scrollPane, gbc_Entries);

    lblExamination = new JLabel("Examination");
    GridBagConstraints gbc_lblExamination = new GridBagConstraints();
    gbc_lblExamination.insets = new Insets(0, 0, 5, 5);
    gbc_lblExamination.gridx = 0;
    gbc_lblExamination.gridy = 5;
    contentPane.add(lblExamination, gbc_lblExamination);

    ExamField = new JTextField();
    ExamField.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent e) {
            char keyChar = e.getKeyChar();
            if (Character.isLowerCase(keyChar)) {
              e.setKeyChar(Character.toUpperCase(keyChar));
            }
          }
        });

    GridBagConstraints gbc_ExamField = new GridBagConstraints();
    gbc_ExamField.insets = new Insets(0, 0, 5, 5);
    gbc_ExamField.fill = GridBagConstraints.HORIZONTAL;
    gbc_ExamField.gridx = 2;
    gbc_ExamField.gridy = 5;
    contentPane.add(ExamField, gbc_ExamField);
    ExamField.setColumns(8);

    lblSubject = new JLabel("Subject");
    GridBagConstraints gbc_lblSubject = new GridBagConstraints();
    gbc_lblSubject.insets = new Insets(0, 0, 5, 5);
    gbc_lblSubject.gridx = 0;
    gbc_lblSubject.gridy = 6;
    contentPane.add(lblSubject, gbc_lblSubject);

    SubField = new JTextField();
    SubField.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent e) {
            char keyChar = e.getKeyChar();
            if (Character.isLowerCase(keyChar)) {
              e.setKeyChar(Character.toUpperCase(keyChar));
            }
          }
        });

    GridBagConstraints gbc_SubField = new GridBagConstraints();
    gbc_SubField.insets = new Insets(0, 0, 5, 5);
    gbc_SubField.fill = GridBagConstraints.HORIZONTAL;
    gbc_SubField.gridx = 2;
    gbc_SubField.gridy = 6;
    contentPane.add(SubField, gbc_SubField);
    SubField.setColumns(8);

    btnAccept = new JButton("Accept");
    btnAccept.setToolTipText("Accept Current Marklist");
    btnAccept.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) { // while (mrkaddtodb.printing) return;
            if (chckbxNewCheckBox.isSelected()) {
              Thread t =
                  new Thread() {
                    public void run() {
                      mrkaddtodb.PrintMarkSheet();
                      //  System.out.println("text");
                      // other complex code
                    }
                  };
              t.start();
              try {
                t.join();
              } catch (InterruptedException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }
            }

            String subcode =
                DivField.getText() + "=" + ExamField.getText() + "=" + SubField.getText();
            int success = MRKaddtodb.FillMainList(subcode);

            if (success == 0) {
              if (fileindex > TotalFiles) {
                show("Error 01");
                return;
              }

              int option = ReplaceDialog();
              if (option == 0) {
                MoveToRejected();
                ProcessLists();
              }
              if (option == 1) {

                if (TotalReceived == 1) {
                  MRKaddtodb.subLine = ""; // special case only one marklist
                  MRKaddtodb.rollArray.removeAll(MRKaddtodb.rollArray);
                  int nodupnow = MRKaddtodb.FillMainList(subcode);
                  if (nodupnow == 0) show("Error in Replace Routine");
                  MRKaddtodb.CalculatePageTotal();
                  MoveToAccepted();
                  ProcessLists();
                  return;
                }
                MRKaddtodb.Remove(subcode);
                int nodupnow = MRKaddtodb.FillMainList(subcode);
                if (nodupnow == 0) show("Error in Replace Routine");
                MRKaddtodb.CalculatePageTotal();
                MoveToAccepted();
                ProcessLists();
              }
              if (option == 2) {
                show("Replace Empty Only routine not added");
                MoveToRejected();
                fileindex++;
                ProcessLists();
              }
            } else //// Not Duplicate, so add to database
            {

              SetData(subcode, TotalReceived, 1);

              TotalReceived++;

              MoveToAccepted();

              if (TotalReceived > 5) { // table.setRowSelectionInterval(curRow,curRow);
                Rectangle vr = table.getVisibleRect();
                // int first = table.rowAtPoint(vr.getLocation());
                vr.translate(0, vr.height);
                int last = table.rowAtPoint(vr.getLocation());
                // int visibleRows = last - first;
                // int mid=visibleRows/2;

                if (last > TotalReceived)
                  table.scrollRectToVisible(table.getCellRect(TotalReceived - 5, 0, true));
                else table.scrollRectToVisible(table.getCellRect(TotalReceived + 5, 0, true));
                ScrollToLine(scrollPane, table);
              }

              AddRow();
              MRKaddtodb.CalculatePageTotal();
              SetReceivedCount();
              ProcessLists();
            }
          }
        });
    GridBagConstraints gbc_btnAccept = new GridBagConstraints();
    gbc_btnAccept.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnAccept.insets = new Insets(0, 0, 5, 5);
    gbc_btnAccept.gridx = 0;
    gbc_btnAccept.gridy = 7;
    contentPane.add(btnAccept, gbc_btnAccept);

    chckbxNewCheckBox = new JCheckBox(" Print ");
    chckbxNewCheckBox.setToolTipText("Tick Check Box to Print Marklists as you accept");
    chckbxNewCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
    GridBagConstraints gbc_chckbxNewCheckBox = new GridBagConstraints();
    gbc_chckbxNewCheckBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_chckbxNewCheckBox.anchor = GridBagConstraints.WEST;
    gbc_chckbxNewCheckBox.insets = new Insets(0, 0, 5, 5);
    gbc_chckbxNewCheckBox.gridx = 2;
    gbc_chckbxNewCheckBox.gridy = 7;
    contentPane.add(chckbxNewCheckBox, gbc_chckbxNewCheckBox);
    chckbxNewCheckBox.setText(" Print (" + mrkaddtodb.PrinterName + ")");

    ////////////////////// BUTTON SELECT	PRINTER//////////////////////////////

    btnSelectPrinter = new JButton("Set Printer");
    btnSelectPrinter.setToolTipText("Select Default Printer");
    btnSelectPrinter.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            mrkaddtodb.SelectPrinter();
            chckbxNewCheckBox.setText(" Print (" + mrkaddtodb.PrinterName + ")");
          }
        });

    btnReject = new JButton("Reject");
    btnReject.setToolTipText("Reject Current Marklist");
    btnReject.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {

            //	MoveToRejected();
            //    ProcessLists();
          }
        });
    GridBagConstraints gbc_btnReject = new GridBagConstraints();
    gbc_btnReject.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnReject.insets = new Insets(0, 0, 5, 5);
    gbc_btnReject.gridx = 0;
    gbc_btnReject.gridy = 8;
    contentPane.add(btnReject, gbc_btnReject);

    GridBagConstraints gbc_btnSelectPrinter = new GridBagConstraints();
    gbc_btnSelectPrinter.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnSelectPrinter.insets = new Insets(0, 0, 5, 5);
    gbc_btnSelectPrinter.gridx = 2;
    gbc_btnSelectPrinter.gridy = 8;
    contentPane.add(btnSelectPrinter, gbc_btnSelectPrinter);

    /////////////////////// END OF SELECT PRINTER///////////////////

    ///////////////////// BUTTON DELETE ///////////////////////

    btnDelete = new JButton("   Delete   ");
    btnDelete.setToolTipText("Delete Selected Marklist");
    btnDelete.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            int temprow = table.getSelectedRow();
            if (temprow < 0 || temprow >= TotalReceived) {
              show("No Marklist Selected");
              return;
            }

            if (TotalReceived == 1) {
              MRKaddtodb.subLine = ""; // /temprow must be 0 here
              ((DefaultTableModel) table.getModel()).removeRow(temprow);
              TotalReceived = 0;
              MRKaddtodb.rollArray.removeAll(MRKaddtodb.rollArray);
              MRKaddtodb.CalculatePageTotal();
              SetReceivedCount();
              return;
            }

            String temp = (String) GetData(table, temprow, 1);

            if (temprow < TotalReceived) {
              String temp1;
              if (temprow == 0) temp1 = temp + "#";
              else temp1 = "#" + temp;
              MRKaddtodb.subLine = MRKaddtodb.subLine.replaceAll(temp1, "");
              MRKaddtodb.Remove(temp);

              ((DefaultTableModel) table.getModel()).removeRow(temprow);
              TotalReceived--;
              MRKaddtodb.CalculatePageTotal();
              SetReceivedCount();

              show("Removed : " + temp);
            }
          }
        });

    btnLoad = new JButton("Load"); // /jump temporary
    btnLoad.setToolTipText("Load Last Saved Session");
    btnLoad.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {

            MRKaddtodb.LoadList();
            String temp[];
            temp = MRKaddtodb.subLine.split("#");
            TotalReceived = temp.length;
            // TotalReceived=mrkaddtodb.TotalReceived;
            for (int i = 0; i < TotalReceived; i++) {
              SetData(temp[i], i, 1);
              AddRow();
            }

            MRKaddtodb.CalculatePageTotal();
            SetReceivedCount();
          }
        });
    GridBagConstraints gbc_btnLoad = new GridBagConstraints();
    gbc_btnLoad.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnLoad.insets = new Insets(0, 0, 5, 5);
    gbc_btnLoad.gridx = 0;
    gbc_btnLoad.gridy = 9;
    contentPane.add(btnLoad, gbc_btnLoad);
    GridBagConstraints gbc_btnDelete = new GridBagConstraints();
    gbc_btnDelete.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnDelete.insets = new Insets(0, 0, 5, 5);
    gbc_btnDelete.gridx = 2;
    gbc_btnDelete.gridy = 9;
    contentPane.add(btnDelete, gbc_btnDelete);

    btnSave = new JButton("Save");
    btnSave.setToolTipText("Save this Session");
    btnSave.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            MRKaddtodb.WriteToDisk();
          }
        });

    /////////////////////// END OF CREATE DB///////////////

    GridBagConstraints gbc_btnSave = new GridBagConstraints();
    gbc_btnSave.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnSave.insets = new Insets(0, 0, 5, 5);
    gbc_btnSave.gridx = 0;
    gbc_btnSave.gridy = 10;
    contentPane.add(btnSave, gbc_btnSave);
    //////////////////////// END OF BUTTON DELETE////////////////////////

    ////////////////////// BUTTON SORT//////////////////////////////

    btnSort = new JButton("Sort");
    btnSort.setToolTipText("Sorts Marklists in Ascending Order");
    btnSort.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            if (TotalReceived == 0) {
              show("No Mark Lists To Sort");
              return;
            }
            mrkaddtodb.TableSort(TotalReceived);
            // mrkaddtodb.SortList(TotalReceived);
          }
        });

    GridBagConstraints gbc_btnSort = new GridBagConstraints();
    gbc_btnSort.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnSort.insets = new Insets(0, 0, 5, 5);
    gbc_btnSort.gridx = 2;
    gbc_btnSort.gridy = 10;
    contentPane.add(btnSort, gbc_btnSort);

    btnUpdatePT = new JButton("Rectify");
    btnUpdatePT.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {

            // MRKaddtodb.CalculatePageTotal();

            if (TotalReceived <= 0) {
              show("No Marklist");
              return;
            }
            SpinnerNumberModel sModel = new SpinnerNumberModel(1, 1, 100, 1);
            JSpinner spinner = new JSpinner(sModel);

            int option =
                JOptionPane.showOptionDialog(
                    null,
                    spinner,
                    "No. of Subjects To Rectify",
                    JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    null,
                    null,
                    null);
            if (option == JOptionPane.CANCEL_OPTION) {
              // user hit cancel
            } else if (option == JOptionPane.OK_OPTION) {
              int sub = (Integer) spinner.getValue();
              MRKaddtodb.Rectify(sub + 1);
              MRKaddtodb.CalculatePageTotal();
            }
          }
        });
    GridBagConstraints gbc_btnUpdatePT = new GridBagConstraints();
    gbc_btnUpdatePT.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnUpdatePT.insets = new Insets(0, 0, 5, 5);
    gbc_btnUpdatePT.gridx = 0;
    gbc_btnUpdatePT.gridy = 11;
    contentPane.add(btnUpdatePT, gbc_btnUpdatePT);

    /////////////////////// END OF BUTTON SORT///////////////////

    ////////////////////// CREATE DB	//////////////////////////////

    btnCreateDb = new JButton("MySql DB");
    btnCreateDb.setToolTipText("Create MySql Database (In Local MySql Server)");
    btnCreateDb.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            try {
              MRKaddtodb.CreateMysqlDB();
            } catch (ClassNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });

    GridBagConstraints gbc_btnCreateDb = new GridBagConstraints();
    gbc_btnCreateDb.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnCreateDb.insets = new Insets(0, 0, 5, 5);
    gbc_btnCreateDb.gridx = 2;
    gbc_btnCreateDb.gridy = 11;
    contentPane.add(btnCreateDb, gbc_btnCreateDb);

    btnSaveReport = new JButton("Save Report");
    btnSaveReport.setToolTipText("Print Report of All Marklists With Page Total");
    btnSaveReport.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            mrkaddtodb.SetReceivedCount(TotalReceived);
            //	mrkaddtodb.PrintReport();
            mrkaddtodb.SaveReport();
          }
        });
    GridBagConstraints gbc_btnSaveReport = new GridBagConstraints();
    gbc_btnSaveReport.insets = new Insets(0, 0, 5, 5);
    gbc_btnSaveReport.gridx = 0;
    gbc_btnSaveReport.gridy = 12;
    contentPane.add(btnSaveReport, gbc_btnSaveReport);

    btnPrintMrk = new JButton("Print MRK");
    btnPrintMrk.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            int temprow = table.getSelectedRow();
            if (temprow < 0 || temprow >= TotalReceived) {
              show("No Marklist Selected");
              return;
            }
            String temp = (String) GetData(table, temprow, 1);
            String temp1 = (String) GetData(table, temprow, 0);
            mrkaddtodb.SetSubjectCodeTriplet(temp, temp1);
            // mrkaddtodb.RecreateAndPrintMarkSheet();
            mrkaddtodb.PickAndPrintML();
          }
        });
    btnPrintMrk.setToolTipText("Print Selected Marklist");
    GridBagConstraints gbc_btnPrintMrk = new GridBagConstraints();
    gbc_btnPrintMrk.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnPrintMrk.insets = new Insets(0, 0, 5, 5);
    gbc_btnPrintMrk.gridx = 2;
    gbc_btnPrintMrk.gridy = 12;
    contentPane.add(btnPrintMrk, gbc_btnPrintMrk);

    btnSqliteDB = new JButton("Sqlite DB");
    btnSqliteDB.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            show("Sqlite DB routine to be added");
          }
        });
    btnSqliteDB.setToolTipText("Create Sqlite DB file");
    GridBagConstraints gbc_btnSqliteDB = new GridBagConstraints();
    gbc_btnSqliteDB.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnSqliteDB.insets = new Insets(0, 0, 5, 5);
    gbc_btnSqliteDB.gridx = 0;
    gbc_btnSqliteDB.gridy = 13;
    contentPane.add(btnSqliteDB, gbc_btnSqliteDB);
    ////////////////////////// END OF SQLITE DB///////////////

    ///////////////////////// START OF GET NAMES///////////////////////
    btnNames = new JButton("Get Names");
    btnNames.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            mrkaddtodb.GetNames();
          }
        });
    btnNames.setToolTipText("Get Names From Text File in Roll#Name Format");
    GridBagConstraints gbc_btnNames = new GridBagConstraints();
    gbc_btnNames.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnNames.insets = new Insets(0, 0, 5, 5);
    gbc_btnNames.gridx = 0;
    gbc_btnNames.gridy = 14;
    contentPane.add(btnNames, gbc_btnNames);
    ////////////////////// END OF GET NAMES //////////////////

    ///////////////////////// START RMOVE NAMES///////////////////////
    btnRemNems = new JButton("Del Names");
    btnRemNems.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            MRKaddtodb.DeleteNames();
            MRKaddtodb.CalculatePageTotal();
          }
        });
    btnRemNems.setToolTipText("Delete All Names");
    GridBagConstraints gbc_btnRemNems = new GridBagConstraints();
    gbc_btnRemNems.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnRemNems.insets = new Insets(0, 0, 5, 5);
    gbc_btnRemNems.gridx = 2;
    gbc_btnRemNems.gridy = 14;
    contentPane.add(btnRemNems, gbc_btnRemNems);
    ////////////////////// END OF GET RemNems //////////////////

    ///////////////////////// START OF GET Res02///////////////////////
    btnRes02 = new JButton("res02");
    btnRes02.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            show("Getres02 routine to be added");
          }
        });
    btnRes02.setToolTipText("Reserved button Res02");
    GridBagConstraints gbc_btnres02 = new GridBagConstraints();
    gbc_btnres02.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnres02.insets = new Insets(0, 0, 5, 5);
    gbc_btnres02.gridx = 0;
    gbc_btnres02.gridy = 15;
    contentPane.add(btnRes02, gbc_btnres02);
    ////////////////////// END OF GET RES02 //////////////////

    ///////////////////////// START OF GET Res03///////////////////////
    btnRes03 = new JButton("Res03");
    btnRes03.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            show("GetRes03 routine to be added");
          }
        });
    btnRes03.setToolTipText("Reserved button Res03");
    GridBagConstraints gbc_btnRes03 = new GridBagConstraints();
    gbc_btnRes03.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnRes03.insets = new Insets(0, 0, 5, 5);
    gbc_btnRes03.gridx = 2;
    gbc_btnRes03.gridy = 15;
    contentPane.add(btnRes03, gbc_btnRes03);
    ////////////////////// END OF GET RES03 //////////////////

    btnHelp = new JButton("Help !");
    btnHelp.setToolTipText("Display Help Screen");
    btnHelp.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            String multiLineMsg[] = {
              "This free and open source application collects marklists created from Mobile App 'MarkList'",
              "which is available on playstore. It compiles them in to one simple text file - Result.rlt. You can ",
              "create MySql database, provided XAMPP or WAMP MySql Local Server installed and is running.",
              " ",
              " 1. Keep all your .mrk files in the same folder where MRKcollector.jar is kept.",
              " 2. Run the MRKcollector. Press [Start] once. This prepares set of all available marklists.",
              " 3. Now keep on accepting marklists by pressing [Accept] repeatedly till all the lists are over.",
              " 4. Save the compilation in the default file Result.rlt. It will overwrite earlier compilation.",
              " 5. In the next session [Load] the compilation from default Result.rlt and repeat the process.",
              " 6. Set the default printer and Tick the print checkbox, to print mark lists on-the-fly.",
              " 7. Delete the marklist from the compilation if you want by selecting list and pressing [Delete].",
              " 8. Accepted Mark Lists will be moved to Accepted folder and Rejected will go to Rejected folder.",
              " 9. Folders will be created automatically on first run if they do not exists.",
              "10. Press [sort] to sort list of files in order to locate them easily or before you print a report.",
              "11. Your IT department can prepare result directly from Result.rlt or by using mySql or Sqlite Database",
              "12. You can make single sqlite db file if you want to use Sqlite databse for result processing.",
              "13. A report of all collected marklists can be printed,with page total, for verification purpose.",
              "14. MySql database can be used to uload marks on your School/College website for students and parents.",
              "15. We recommend BOSS, 'Bharat Operating System Solution', India's Linux, if your institution is in India.",
              "16. For free assistance or suggestions, please email us at [email protected] or [email protected].",
              "17. The sourcecode of this application is available at http://sourceforge.net/projects/marklist/",
              "18. Do not use pirated software, always use free and open source software. We are always there to help.",
              " "
            };
            JOptionPane.showMessageDialog(null, multiLineMsg, "Help", JOptionPane.PLAIN_MESSAGE);
          }
        });
    GridBagConstraints gbc_btnHelp = new GridBagConstraints();
    gbc_btnHelp.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnHelp.insets = new Insets(0, 0, 5, 5);
    gbc_btnHelp.gridx = 2;
    gbc_btnHelp.gridy = 13;
    contentPane.add(btnHelp, gbc_btnHelp);
  }
  void jbInit() throws Exception {
    this.setResizable(false);
    // Build headerPanel
    headerPanel.setBackground(Color.WHITE);
    headerPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    header.setFont(new java.awt.Font("Dialog", 0, 20));
    header.setForeground(new Color(0, 0, 124));
    header.setText(Local.getString("Event"));
    header.setIcon(
        new ImageIcon(
            net.sf.memoranda.ui.EventDialog.class.getResource("resources/icons/event48.png")));
    headerPanel.add(header);

    // Build eventPanel
    lblTime.setText(Local.getString("Time"));
    lblTime.setMinimumSize(new Dimension(60, 24));
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets = new Insets(10, 10, 5, 10);
    gbc.anchor = GridBagConstraints.WEST;
    eventPanel.add(lblTime, gbc);
    timeSpin.setPreferredSize(new Dimension(60, 24));
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.insets = new Insets(10, 0, 5, 5);
    gbc.anchor = GridBagConstraints.WEST;
    eventPanel.add(timeSpin, gbc);
    lblText.setText(Local.getString("Text"));
    lblText.setMinimumSize(new Dimension(120, 24));
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridwidth = 3;
    gbc.insets = new Insets(5, 10, 5, 10);
    gbc.anchor = GridBagConstraints.WEST;
    eventPanel.add(lblText, gbc);
    textField.setMinimumSize(new Dimension(375, 24));
    textField.setPreferredSize(new Dimension(375, 24));
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.gridwidth = 6;
    gbc.insets = new Insets(5, 10, 10, 10);
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    eventPanel.add(textField, gbc);

    // Build RepeatPanel
    repeatBorder =
        new TitledBorder(BorderFactory.createLineBorder(Color.gray, 1), Local.getString("Repeat"));

    // Added by (jcscoobyrs) on 12-Nov-2003 at 15:34:27 PM
    // ---------------------------------------------------
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT);

    // Build ButtonsPanel
    okB.setMaximumSize(new Dimension(100, 26));
    okB.setMinimumSize(new Dimension(100, 26));
    okB.setPreferredSize(new Dimension(100, 26));
    okB.setText(Local.getString("Ok"));
    okB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            okB_actionPerformed(e);
          }
        });
    this.getRootPane().setDefaultButton(okB);
    cancelB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cancelB_actionPerformed(e);
          }
        });
    cancelB.setText(Local.getString("Cancel"));
    cancelB.setPreferredSize(new Dimension(100, 26));
    cancelB.setMinimumSize(new Dimension(100, 26));
    cancelB.setMaximumSize(new Dimension(100, 26));
    buttonsPanel.add(okB);
    buttonsPanel.add(cancelB);

    // Finally build the Dialog
    topPanel.add(headerPanel, BorderLayout.NORTH);
    topPanel.add(eventPanel, BorderLayout.SOUTH);
    GridBagConstraints gbc_repeatPanel = new GridBagConstraints();
    gbc_repeatPanel.insets = new Insets(0, 0, 0, 5);
    gbc_repeatPanel.gridx = 1;
    gbc_repeatPanel.gridy = 3;
    eventPanel.add(repeatPanel, gbc_repeatPanel);
    repeatPanel.setBorder(repeatBorder);
    noRepeatRB.setMaximumSize(new Dimension(80, 35));
    noRepeatRB.setSelected(true);
    noRepeatRB.setText(Local.getString("No repeat"));
    noRepeatRB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            noRepeatRB_actionPerformed(e);
          }
        });
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 4;
    gbc.insets = new Insets(5, 5, 5, 0);
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    repeatPanel.add(noRepeatRB, gbc);
    dailyRepeatRB.setActionCommand("daily");
    dailyRepeatRB.setText(Local.getString("Every"));
    dailyRepeatRB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dailyRepeatRB_actionPerformed(e);
          }
        });
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.insets = new Insets(5, 5, 5, 0);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(dailyRepeatRB, gbc);
    daySpin.setPreferredSize(new Dimension(50, 24));
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.insets = new Insets(5, 5, 5, 0);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(daySpin, gbc);
    lblDays.setText(Local.getString("day(s)"));
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 1;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(5, 5, 5, 40);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(lblDays, gbc);
    lblSince.setText(Local.getString("Since"));
    lblSince.setMinimumSize(new Dimension(70, 16));
    gbc = new GridBagConstraints();
    gbc.gridx = 4;
    gbc.gridy = 1;
    gbc.insets = new Insets(5, 0, 5, 5);
    gbc.anchor = GridBagConstraints.EAST;
    repeatPanel.add(lblSince, gbc);
    startDate.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (ignoreStartChanged) return;
            ignoreStartChanged = true;
            Date sd = (Date) startDate.getModel().getValue();
            Date ed = (Date) endDate.getModel().getValue();
            // Commented out, value was resetted to endDate !!!
            if (sd.after(ed)) {
              endDate.getModel().setValue(sd);
              ed = sd;
            }
            startCalFrame.cal.set(new CalendarDate(sd));
            ignoreStartChanged = false;
          }
        });
    startDate.setPreferredSize(new Dimension(80, 24));
    startDate.setEditor(new JSpinner.DateEditor(startDate, sdf.toPattern()));
    // ---------------------------------------------------
    gbc = new GridBagConstraints();
    gbc.gridx = 5;
    gbc.gridy = 1;
    gbc.insets = new Insets(5, 0, 5, 5);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(startDate, gbc);
    setStartDateB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setStartDateB_actionPerformed(e);
          }
        });
    setStartDateB.setIcon(
        new ImageIcon(
            net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/calendar.png")));
    setStartDateB.setText("");
    setStartDateB.setPreferredSize(new Dimension(24, 24));

    gbc = new GridBagConstraints();
    gbc.gridx = 6;
    gbc.gridy = 1;
    gbc.insets = new Insets(5, 0, 5, 5);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(setStartDateB, gbc);
    weeklyRepeatRB.setActionCommand("weekly");
    weeklyRepeatRB.setText(Local.getString("Every"));
    weeklyRepeatRB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            weeklyRepeatRB_actionPerformed(e);
          }
        });
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(weeklyRepeatRB, gbc);
    weekdaysCB.setPreferredSize(new Dimension(100, 25));
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(5, 0, 5, 40);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(weekdaysCB, gbc);
    enableEndDateCB.setHorizontalAlignment(SwingConstants.RIGHT);
    enableEndDateCB.setText(Local.getString("Till"));
    enableEndDateCB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            enableEndDateCB_actionPerformed(e);
          }
        });
    gbc = new GridBagConstraints();
    gbc.gridx = 4;
    gbc.gridy = 2;
    gbc.insets = new Insets(5, 0, 5, 5);
    gbc.anchor = GridBagConstraints.EAST;
    repeatPanel.add(enableEndDateCB, gbc);
    endDate.setPreferredSize(new Dimension(80, 24));
    // Added by (jcscoobyrs) on 12-Nov-2003 at 15:34:27 PM
    // ---------------------------------------------------
    endDate.setEditor(new JSpinner.DateEditor(endDate, sdf.toPattern()));
    // ---------------------------------------------------
    endDate.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (ignoreEndChanged) return;
            ignoreEndChanged = true;
            Date sd = (Date) startDate.getModel().getValue();
            Date ed = (Date) endDate.getModel().getValue();
            if (sd.after(ed)) {
              endDate.getModel().setValue(sd);
              ed = sd;
            }
            endCalFrame.cal.set(new CalendarDate(ed));
            ignoreEndChanged = false;
          }
        });
    // working days
    workingDaysOnlyCB.setText(Local.getString("Working days only"));
    workingDaysOnlyCB.setHorizontalAlignment(SwingConstants.RIGHT);
    gbc = new GridBagConstraints();
    gbc.gridx = 4;
    gbc.gridy = 3;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(5, 0, 5, 5);
    gbc.anchor = GridBagConstraints.EAST;
    repeatPanel.add(workingDaysOnlyCB, gbc);
    // -------------------------------------
    gbc = new GridBagConstraints();
    gbc.gridx = 5;
    gbc.gridy = 2;
    gbc.insets = new Insets(5, 0, 5, 5);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(endDate, gbc);
    setEndDateB.setMinimumSize(new Dimension(24, 24));
    setEndDateB.setPreferredSize(new Dimension(24, 24));
    setEndDateB.setText("");
    setEndDateB.setIcon(
        new ImageIcon(
            net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/calendar.png")));
    setEndDateB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setEndDateB_actionPerformed(e);
          }
        });
    gbc = new GridBagConstraints();
    gbc.gridx = 6;
    gbc.gridy = 2;
    gbc.insets = new Insets(5, 0, 5, 5);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(setEndDateB, gbc);
    monthlyRepeatRB.setActionCommand("daily");
    monthlyRepeatRB.setText(Local.getString("Every"));
    monthlyRepeatRB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            monthlyRepeatRB_actionPerformed(e);
          }
        });
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(monthlyRepeatRB, gbc);
    dayOfMonthSpin.setPreferredSize(new Dimension(50, 24));
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 3;
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(dayOfMonthSpin, gbc);
    lblDoM.setText(Local.getString("day of month"));
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 3;
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(lblDoM, gbc);
    yearlyRepeatRB.setActionCommand("yearly");
    yearlyRepeatRB.setText(Local.getString("Yearly"));
    yearlyRepeatRB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            yearlyRepeatRB_actionPerformed(e);
          }
        });
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.gridwidth = 5;
    gbc.insets = new Insets(5, 5, 5, 10);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(yearlyRepeatRB, gbc);

    // Exception label
    lblExceptions.setText("Specific days to not recur on (exceptions)");
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(5, 5, 5, 10);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(lblExceptions, gbc);

    // Exception text field
    exceptionDate.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (ignoreExceptionChanged) return;
            ignoreExceptionChanged = true;
            Date exd = (Date) exceptionDate.getModel().getValue();

            exceptionCalFrame.cal.set(new CalendarDate(exd));
            ignoreExceptionChanged = false;
          }
        });
    exceptionDate.setPreferredSize(new Dimension(80, 24));
    exceptionDate.setEditor(new JSpinner.DateEditor(exceptionDate, sdf.toPattern()));
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 6;
    gbc.insets = new Insets(5, 5, 5, 4);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(exceptionDate, gbc);

    // Exception Calendar Button
    setExceptionDateB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setExceptionDateB_actionPerformed(e);
          }
        });
    setExceptionDateB.setIcon(
        new ImageIcon(
            net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/calendar.png")));
    setExceptionDateB.setText("");
    setExceptionDateB.setPreferredSize(new Dimension(24, 24));

    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.insets = new Insets(5, 0, 5, 4);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(setExceptionDateB, gbc);

    // Exception date add button
    addExceptionDate.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addExceptionDate_actionPerformed(e);
          }
        });
    addExceptionDate.setText("Add");
    addExceptionDate.setPreferredSize(new Dimension(80, 24));
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.insets = new Insets(2, 36, 5, 2);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(addExceptionDate, gbc);

    // Exception List
    exceptionPane.setPreferredSize(new Dimension(136, 96));
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 6;
    gbc.gridwidth = 4;
    gbc.gridheight = 4;
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(exceptionPane, gbc);

    // Exception date remove button
    removeExceptionDate.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            removeExceptionDate_actionPerformed(e);
          }
        });
    removeExceptionDate.setText("Remove");
    removeExceptionDate.setPreferredSize(new Dimension(80, 24));
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 7;
    gbc.insets = new Insets(2, 36, 5, 2);
    gbc.anchor = GridBagConstraints.WEST;
    repeatPanel.add(removeExceptionDate, gbc);

    repeatRBGroup.add(noRepeatRB);
    repeatRBGroup.add(dailyRepeatRB);
    repeatRBGroup.add(weeklyRepeatRB);
    repeatRBGroup.add(monthlyRepeatRB);
    repeatRBGroup.add(yearlyRepeatRB);
    bottomPanel.add(buttonsPanel, BorderLayout.SOUTH);
    this.getContentPane().add(topPanel, BorderLayout.NORTH);
    this.getContentPane().add(bottomPanel, BorderLayout.SOUTH);

    // Do final things...
    startCalFrame.cal.addSelectionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (ignoreStartChanged) return;
            startDate.getModel().setValue(startCalFrame.cal.get().getCalendar().getTime());
          }
        });
    endCalFrame.cal.addSelectionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (ignoreEndChanged) return;
            endDate.getModel().setValue(endCalFrame.cal.get().getCalendar().getTime());
          }
        });
    exceptionCalFrame.cal.addSelectionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (ignoreExceptionChanged) return;
            exceptionDate.getModel().setValue(exceptionCalFrame.cal.get().getCalendar().getTime());
          }
        });
    disableElements();
    ((JSpinner.DateEditor) timeSpin.getEditor()).getFormat().applyPattern("HH:mm");
    enableEndDateCB_actionPerformed(null);
  }
Exemplo n.º 19
0
  private void setupGui() {
    setIconImage(
        Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));
    setTitle(I18N.getLocaleString("UPDATEMODPACK_TITLE"));
    setResizable(false);

    Container panel = getContentPane();
    SpringLayout layout = new SpringLayout();
    panel.setLayout(layout);

    messageLbl = new JLabel(I18N.getLocaleString("UPDATEMODPACK_ISAVALIBLE"));
    updateLbl = new JLabel(I18N.getLocaleString("UPDATE_WICHUPDATE"));
    backup = new JCheckBox(I18N.getLocaleString("UPDATEMODPACK_BACKUP"));
    update = new JButton(I18N.getLocaleString("MAIN_YES"));
    abort = new JButton(I18N.getLocaleString("MAIN_NO"));

    messageLbl.setHorizontalAlignment(SwingConstants.CENTER);
    updateLbl.setHorizontalAlignment(SwingConstants.CENTER);
    backup.setHorizontalAlignment(SwingConstants.CENTER);

    panel.add(messageLbl);
    panel.add(updateLbl);
    panel.add(backup);
    panel.add(update);
    panel.add(abort);

    Spring hSpring;
    Spring columnWidth;

    hSpring = Spring.constant(10);

    layout.putConstraint(SpringLayout.WEST, messageLbl, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, updateLbl, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, backup, hSpring, SpringLayout.WEST, panel);

    columnWidth = Spring.width(messageLbl);
    columnWidth = Spring.max(columnWidth, Spring.width(updateLbl));
    columnWidth = Spring.max(columnWidth, Spring.width(backup));

    hSpring = Spring.sum(hSpring, columnWidth);

    layout.putConstraint(SpringLayout.EAST, messageLbl, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.EAST, updateLbl, hSpring, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.EAST, backup, hSpring, SpringLayout.WEST, panel);

    hSpring = Spring.sum(hSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.EAST, panel, hSpring, SpringLayout.WEST, panel);

    layout.putConstraint(
        SpringLayout.HORIZONTAL_CENTER, backup, 0, SpringLayout.HORIZONTAL_CENTER, panel);
    layout.putConstraint(SpringLayout.EAST, update, -5, SpringLayout.HORIZONTAL_CENTER, panel);
    layout.putConstraint(SpringLayout.WEST, abort, 5, SpringLayout.HORIZONTAL_CENTER, panel);

    Spring vSpring;
    Spring rowHeight;

    vSpring = Spring.constant(10);

    layout.putConstraint(SpringLayout.NORTH, messageLbl, vSpring, SpringLayout.NORTH, panel);

    vSpring = Spring.sum(vSpring, Spring.height(messageLbl));
    vSpring = Spring.sum(vSpring, Spring.constant(5));

    layout.putConstraint(SpringLayout.NORTH, updateLbl, vSpring, SpringLayout.NORTH, panel);

    vSpring = Spring.sum(vSpring, Spring.height(updateLbl));
    vSpring = Spring.sum(vSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.NORTH, backup, vSpring, SpringLayout.NORTH, panel);

    vSpring = Spring.sum(vSpring, Spring.height(backup));
    vSpring = Spring.sum(vSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.NORTH, update, vSpring, SpringLayout.NORTH, panel);
    layout.putConstraint(SpringLayout.NORTH, abort, vSpring, SpringLayout.NORTH, panel);

    rowHeight = Spring.height(update);
    rowHeight = Spring.max(rowHeight, Spring.height(abort));

    vSpring = Spring.sum(vSpring, rowHeight);
    vSpring = Spring.sum(vSpring, Spring.constant(10));

    layout.putConstraint(SpringLayout.SOUTH, panel, vSpring, SpringLayout.NORTH, panel);

    pack();
    setLocationRelativeTo(getOwner());
  }