Example #1
0
  public MeioMaskField(
      String id,
      MaskType mask,
      String options,
      IModel<T> model,
      boolean valueContainsLiteralCharacters,
      Class<T> type) {
    super(id, model, type);
    this.maskType = mask;
    LOGGER.debug("Initializing maskfield with id {} ...", id);
    LOGGER.debug("  Mask name: {}, mask: {}", mask.getMaskName(), mask.getMask());
    LOGGER.debug("  Options: {}", options);
    LOGGER.debug("  Type: {}", type);
    LOGGER.debug("  ValueContainsLiteralCharacters: {}", valueContainsLiteralCharacters);
    try {
      maskFormatter.setMask(mask.getMask());
      maskFormatter.setValueClass(String.class);
      maskFormatter.setAllowsInvalid(true);
      maskFormatter.setValueContainsLiteralCharacters(valueContainsLiteralCharacters);
    } catch (ParseException parseException) {
      throw new WicketRuntimeException(parseException);
    }

    add(new MeioMaskBehavior(mask, options));
    setOutputMarkupId(true);

    LOGGER.debug("Maskfield {} initialized.", id);
  }
 public String print(String object, Locale locale) {
   try {
     return delegate.valueToString(object);
   } catch (ParseException e) {
     throw new IllegalArgumentException("Unable to print using mask " + delegate.getMask(), e);
   }
 }
  /** @see Editor#addEditorForm() */
  @Override
  public void addEditorForm() {
    if (initiallyNull) {
      model = new JTextField();
    } else {
      model = new JTextField(item.model);
      model.setEnabled(false);
    }

    model.setPreferredSize(fieldSize);

    addField(TABLE_BUS_MODEL, model);

    try {
      MaskFormatter formatter = new MaskFormatter("####");
      formatter.setPlaceholderCharacter('Y');
      year = new JFormattedTextField(formatter);
      if (!initiallyNull) {
        ((JFormattedTextField) year).setText(item.year);
        year.setEnabled(false);
      }

      year.setPreferredSize(fieldSize);
      addField(TABLE_BUS_YEAR, year);
    } catch (ParseException e) {
    }
  }
  public MaskFormatter Mascara(String Mascara) {

    MaskFormatter F_Mascara = new MaskFormatter();
    try {
      F_Mascara.setMask(Mascara); // Atribui a mascara
      F_Mascara.setPlaceholderCharacter(' '); // Caracter para preencimento
    } catch (Exception excecao) {
      excecao.printStackTrace();
    }
    return F_Mascara;
  }
Example #5
0
  public RelatorioMes() {
    initComponents();
    setLocationRelativeTo(null); // coloca janela no centro da pagina
    setVisible(true);

    try {
      mMesAno.setMask("##/####"); // mascara para mesAno
      mMesAno.setPlaceholderCharacter('_'); // caracter que fica ocupando o espaço
    } catch (ParseException e) {
      e.printStackTrace();
    }
  }
  protected MaskFormatter createFormatter(String s, boolean mostrarMascara) {
    MaskFormatter formatter = null;
    try {
      formatter = new MaskFormatter(s);

      if (mostrarMascara) {
        formatter.setPlaceholderCharacter('_');
      }
    } catch (java.text.ParseException exc) {
      System.err.println("formatter is bad: " + exc.getMessage());
      System.exit(-1);
    }
    return formatter;
  }
Example #7
0
  public final void setOptions() {
    try {
      MaskFormatter msf = new MaskFormatter("##:##:##");
      msf.setPlaceholderCharacter('_');
      msf.setAllowsInvalid(false);
      msf.setValueContainsLiteralCharacters(false);
      inputDatejFormattedTextField.setFormatterFactory(new DefaultFormatterFactory(msf));

    } catch (ParseException ex) {
      Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
    }
    df.applyPattern("HH:mm:ss");
    clockjLabel.setText(df.format(cal.getTime()));
  }
  public RelatorioComissaoRepres() {
    initComponents();
    setLocationRelativeTo(null);

    MaskFormatter maskData;
    MaskFormatter maskData1;
    try {
      maskData = new MaskFormatter("##/##/####");
      maskData1 = new MaskFormatter("##/##/####");
      maskData.install(jtfDataEmissaoIni);
      maskData1.install(jtfDataEmissaoFim);
    } catch (ParseException ex) {
      MostraErro.pMostraErro("Ocorreu um erro ao setar a máscara de datas.", "Erro");
    }
  }
Example #9
0
  @Override
  public String getInput() {
    String input = super.getInput();

    if (input.trim().length() == 0 || isUnMaskableTypes(getType(), this.maskType)) {
      // Do nothing
      return input;
    } else if (isNumberFormat(getType())) { // Remove special characters
      DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols(getLocale());
      StringBuilder builder = new StringBuilder();
      for (int i = 0; i < input.length(); i++) {
        if (input.charAt(i) != formatSymbols.getGroupingSeparator()) {
          builder.append(input.charAt(i));
        }
      }
      return builder.toString();
    } else { // Unmask values
      try {
        LOGGER.debug("Value to Converter {}", input);
        return (String) maskFormatter.stringToValue(input);
      } catch (ParseException ex) {
        throw newConversionException(input, ex);
      }
    }
  }
Example #10
0
 /**
  * I don't know if this is a best place to convert mask (with String type), please if you find
  * other way... talk to me
  *
  * @param value
  * @return
  * @throws ConversionException
  */
 @Override
 protected T convertValue(String[] value) throws ConversionException {
   if (value != null && value.length > 0 && value[0].trim().length() > 0) {
     try {
       String valueToConverter = value[0];
       LOGGER.debug("Value to Converter {}", valueToConverter);
       value[0] = (String) maskFormatter.stringToValue(valueToConverter);
     } catch (ParseException ex) {
       throw newConversionException(value[0], ex);
     }
   }
   return super.convertValue(value);
 }
  public FormatTestFrame() {
    JPanel buttonPanel = new JPanel();
    okButton = new JButton("Ok");
    buttonPanel.add(okButton);
    add(buttonPanel, BorderLayout.SOUTH);

    mainPanel = new JPanel();
    mainPanel.setLayout(new GridLayout(0, 3));
    add(mainPanel, BorderLayout.CENTER);

    JFormattedTextField intField = new JFormattedTextField(NumberFormat.getIntegerInstance());
    intField.setValue(new Integer(100));
    addRow("Number:", intField);

    JFormattedTextField intField2 = new JFormattedTextField(NumberFormat.getIntegerInstance());
    intField2.setValue(new Integer(100));
    intField2.setFocusLostBehavior(JFormattedTextField.COMMIT);
    addRow("Number (Commit behavior):", intField2);

    JFormattedTextField intField3 =
        new JFormattedTextField(
            new InternationalFormatter(NumberFormat.getIntegerInstance()) {
              protected DocumentFilter getDocumentFilter() {
                return filter;
              }
            });
    intField3.setValue(new Integer(100));
    addRow("Filtered Number", intField3);

    JFormattedTextField intField4 = new JFormattedTextField(NumberFormat.getIntegerInstance());
    intField4.setValue(new Integer(100));
    intField4.setInputVerifier(
        new InputVerifier() {
          public boolean verify(JComponent component) {
            JFormattedTextField field = (JFormattedTextField) component;
            return field.isEditValid();
          }
        });
    addRow("Verified Number:", intField4);

    JFormattedTextField currencyField = new JFormattedTextField(NumberFormat.getCurrencyInstance());
    currencyField.setValue(new Double(10));
    addRow("Currency:", currencyField);

    JFormattedTextField dateField = new JFormattedTextField(DateFormat.getDateInstance());
    dateField.setValue(new Date());
    addRow("Date (default):", dateField);

    DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT);
    format.setLenient(false);
    JFormattedTextField dateField2 = new JFormattedTextField(format);
    dateField2.setValue(new Date());
    addRow("Date (short, not lenient):", dateField2);

    try {
      DefaultFormatter formatter = new DefaultFormatter();
      formatter.setOverwriteMode(false);
      JFormattedTextField urlField = new JFormattedTextField(formatter);
      urlField.setValue(new URL("http://java.sun.com"));
      addRow("URL:", urlField);
    } catch (MalformedURLException ex) {
      ex.printStackTrace();
    }

    try {
      MaskFormatter formatter = new MaskFormatter("###-##-####");
      formatter.setPlaceholderCharacter('0');
      JFormattedTextField ssnField = new JFormattedTextField(formatter);
      ssnField.setValue("078-05-1120");
      addRow("SSN Mask:", ssnField);
    } catch (ParseException ex) {
      ex.printStackTrace();
    }

    JFormattedTextField ipField = new JFormattedTextField(new IPAddressFormatter());
    ipField.setValue(new byte[] {(byte) 130, 65, 86, 66});
    addRow("IP Address:", ipField);
    pack();
  }
  /** Create the frame. */
  public ConsultarAdotanteFisicoCPFGUI() {
    setTitle("Consulta");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 645, 455);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel lblNewLabel = new JLabel("CPF:");
    lblNewLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12));
    lblNewLabel.setBounds(28, 202, 46, 14);
    contentPane.add(lblNewLabel);

    MaskFormatter mascaraCpf = null;
    try {
      mascaraCpf = new MaskFormatter("###.###.###-##");
      mascaraCpf.setPlaceholderCharacter('_');

    } catch (ParseException e1) {
      JOptionPane.showMessageDialog(null, "Digite um CPF válido!" + e1.getMessage(), "ERROR", 0);
    }
    JFormattedTextField jFormattedTextCpf = new JFormattedTextField(mascaraCpf);
    jFormattedTextCpf.setBounds(84, 200, 188, 20);
    contentPane.add(jFormattedTextCpf);

    JButton btnConsultarCpf = new JButton("Consultar");
    btnConsultarCpf.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            consultaAdotanteFisico(jFormattedTextCpf);
          }

          /**
           * EFETUA A CONSULTA DE UMA ADOTANTE FISICO ATRAVÉS DO CPF E SETA NA GUI
           *
           * @param jFormattedTextCpf
           */
          public void consultaAdotanteFisico(JFormattedTextField jFormattedTextCpf) {
            try {
              ConsultarAdotanteFisicoGUI consulta = new ConsultarAdotanteFisicoGUI();

              PessoaFisicaService pessoaFisicaService = new PessoaFisicaService();
              EnderecoService enderecoService = new EnderecoService();
              pessoaFisica =
                  pessoaFisicaService.consultarRepresentante(jFormattedTextCpf.getText());
              Pessoa pessoa = pessoaFisica.getPessoa();
              Endereco endereco = new Endereco();
              int idEndereco = pessoaFisica.getPessoa().getEndereco().getId();
              endereco = enderecoService.consultarEndereco(idEndereco);

              consulta.textNomeFisico.setText(pessoa.getNome());
              consulta.textEmail.setText(pessoa.getEmail());
              consulta.formattedTextFieldTelefoneFixo.setText(pessoa.getTelefoneFixo());
              consulta.jFormattedTextTeljFormattedTextCelular.setText(pessoa.getTelefoneCelular());

              consulta.comboGenero.setToolTipText(pessoaFisica.getGenero());
              consulta.jFormattedTextCPF.setText(pessoaFisica.getCpf());
              consulta.textRG.setText(pessoaFisica.getRg());

              consulta.textRua.setText(endereco.getRua());
              consulta.textBairro.setText(endereco.getBairro());
              consulta.textCidade.setText(endereco.getCidade());
              consulta.textEstado.setText(endereco.getEstado());
              consulta.jFormattedTextCep.setText(endereco.getCep());
              consulta.textNumero.setText(endereco.getNumero());
              pessoa.setEndereco(endereco);
              consulta.pf = pessoaFisica;
              consulta.setVisible(true);
              dispose();
            } catch (Exception ex) {
              JOptionPane.showMessageDialog(null, ex, "ERROR", 0);
            }
          }
        });
    btnConsultarCpf.setBounds(282, 199, 89, 23);
    contentPane.add(btnConsultarCpf);

    lblMostrarNome = new JLabel("");
    lblMostrarNome.setFont(new Font("Microsoft YaHei", Font.BOLD, 14));
    lblMostrarNome.setBounds(84, 238, 193, 23);
    contentPane.add(lblMostrarNome);

    JLabel lblAdooDePessoa = new JLabel("Consulta de Pessoa Fisica");
    lblAdooDePessoa.setFont(new Font("Microsoft YaHei", Font.BOLD, 14));
    lblAdooDePessoa.setBounds(28, 62, 193, 14);
    contentPane.add(lblAdooDePessoa);

    JButton btnVoltar = new JButton("Voltar");
    btnVoltar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ConsultarPessoaGUI consultaPessoa = new ConsultarPessoaGUI();
            consultaPessoa.setVisible(true);
            dispose();
            ;
          }
        });
    btnVoltar.setBounds(282, 382, 89, 23);
    contentPane.add(btnVoltar);

    JLabel label = new JLabel("");
    ImagensGUI.imagemAdocaoFisico(label);
    label.setBounds(384, 62, 235, 343);
    contentPane.add(label);
  }
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jScrollPane1 = new javax.swing.JScrollPane();
    lstProduits = new javax.swing.JList();
    txtNom = new javax.swing.JTextField();
    txtPoids = new javax.swing.JTextField();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    btnModifier = new javax.swing.JButton();
    btnEnregistrer = new javax.swing.JButton();
    btnEffacer = new javax.swing.JButton();
    btnAnnuler = new javax.swing.JButton();
    jSeparator1 = new javax.swing.JSeparator();
    btnPrevious = new javax.swing.JButton();
    btnNext = new javax.swing.JButton();
    jLabel6 = new javax.swing.JLabel();
    cbxSearch = new javax.swing.JComboBox();
    txtSearch = new javax.swing.JTextField();
    btnSearch = new javax.swing.JButton();
    jSeparator2 = new javax.swing.JSeparator();
    MaskFormatter mf = null;
    try {
      mf = new MaskFormatter("###×###×##");
      mf.setPlaceholderCharacter('_');
    } catch (ParseException p) {
      p.printStackTrace();
    }
    ftxtDimension = new javax.swing.JFormattedTextField(mf);
    txtSections = new javax.swing.JTextField();
    jLabel9 = new javax.swing.JLabel();
    lblDensité = new javax.swing.JLabel();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenu2 = new javax.swing.JMenu();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    addWindowListener(
        new java.awt.event.WindowAdapter() {
          public void windowOpened(java.awt.event.WindowEvent evt) {
            formWindowOpened(evt);
          }
        });

    lstProduits.addListSelectionListener(
        new javax.swing.event.ListSelectionListener() {
          public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            lstProduitsValueChanged(evt);
          }
        });
    jScrollPane1.setViewportView(lstProduits);

    jLabel1.setFont(new java.awt.Font("Colonna MT", 3, 24)); // NOI18N
    jLabel1.setText("Blocks");

    jLabel2.setText("Nom");

    jLabel3.setText("Poids");

    jLabel4.setText("Dimension");

    jLabel5.setText("Densité");

    btnModifier.setText("Modifier");
    btnModifier.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnModifierActionPerformed(evt);
          }
        });

    btnEnregistrer.setText("Enregistrer");
    btnEnregistrer.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnEnregistrerActionPerformed(evt);
          }
        });

    btnEffacer.setText("Effacer");
    btnEffacer.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnEffacerActionPerformed(evt);
          }
        });

    btnAnnuler.setText("Annuler");
    btnAnnuler.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAnnulerActionPerformed(evt);
          }
        });

    btnPrevious.setText("<");

    btnNext.setText(">");

    jLabel6.setText("Rechecher");

    cbxSearch.setModel(
        new javax.swing.DefaultComboBoxModel(
            new String[] {"Sélectionner critère", "Nom", "Densité"}));
    cbxSearch.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            cbxSearchActionPerformed(evt);
          }
        });

    btnSearch.setText("Chercher");
    btnSearch.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnSearchActionPerformed(evt);
          }
        });

    jLabel9.setText("Nombre de séctions");

    jMenu1.setText("File");
    jMenuBar1.add(jMenu1);

    jMenu2.setText("Edit");
    jMenuBar1.add(jMenu2);

    setJMenuBar(jMenuBar1);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                layout
                                    .createSequentialGroup()
                                    .addComponent(
                                        jScrollPane1,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        107,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement
                                                            .RELATED)
                                                    .addGroup(
                                                        layout
                                                            .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment
                                                                    .LEADING)
                                                            .addGroup(
                                                                layout
                                                                    .createSequentialGroup()
                                                                    .addGap(2, 2, 2)
                                                                    .addComponent(btnModifier)
                                                                    .addPreferredGap(
                                                                        javax.swing.LayoutStyle
                                                                            .ComponentPlacement
                                                                            .RELATED)
                                                                    .addComponent(btnEnregistrer)
                                                                    .addPreferredGap(
                                                                        javax.swing.LayoutStyle
                                                                            .ComponentPlacement
                                                                            .RELATED)
                                                                    .addComponent(btnEffacer)
                                                                    .addPreferredGap(
                                                                        javax.swing.LayoutStyle
                                                                            .ComponentPlacement
                                                                            .RELATED)
                                                                    .addComponent(btnAnnuler))
                                                            .addGroup(
                                                                layout
                                                                    .createSequentialGroup()
                                                                    .addGroup(
                                                                        layout
                                                                            .createParallelGroup(
                                                                                javax.swing
                                                                                    .GroupLayout
                                                                                    .Alignment
                                                                                    .LEADING)
                                                                            .addComponent(jLabel2)
                                                                            .addComponent(jLabel3)
                                                                            .addComponent(jLabel4)
                                                                            .addComponent(jLabel5))
                                                                    .addGap(33, 33, 33)
                                                                    .addGroup(
                                                                        layout
                                                                            .createParallelGroup(
                                                                                javax.swing
                                                                                    .GroupLayout
                                                                                    .Alignment
                                                                                    .TRAILING,
                                                                                false)
                                                                            .addComponent(
                                                                                lblDensité,
                                                                                javax.swing
                                                                                    .GroupLayout
                                                                                    .Alignment
                                                                                    .LEADING,
                                                                                javax.swing
                                                                                    .GroupLayout
                                                                                    .DEFAULT_SIZE,
                                                                                javax.swing
                                                                                    .GroupLayout
                                                                                    .DEFAULT_SIZE,
                                                                                Short.MAX_VALUE)
                                                                            .addComponent(
                                                                                txtNom,
                                                                                javax.swing
                                                                                    .GroupLayout
                                                                                    .Alignment
                                                                                    .LEADING)
                                                                            .addComponent(
                                                                                txtPoids,
                                                                                javax.swing
                                                                                    .GroupLayout
                                                                                    .Alignment
                                                                                    .LEADING)
                                                                            .addComponent(
                                                                                ftxtDimension,
                                                                                javax.swing
                                                                                    .GroupLayout
                                                                                    .Alignment
                                                                                    .LEADING,
                                                                                javax.swing
                                                                                    .GroupLayout
                                                                                    .DEFAULT_SIZE,
                                                                                86,
                                                                                Short.MAX_VALUE))
                                                                    .addPreferredGap(
                                                                        javax.swing.LayoutStyle
                                                                            .ComponentPlacement
                                                                            .RELATED)
                                                                    .addGroup(
                                                                        layout
                                                                            .createParallelGroup(
                                                                                javax.swing
                                                                                    .GroupLayout
                                                                                    .Alignment
                                                                                    .LEADING)
                                                                            .addGroup(
                                                                                layout
                                                                                    .createSequentialGroup()
                                                                                    .addGap(
                                                                                        10, 10, 10)
                                                                                    .addComponent(
                                                                                        txtSections,
                                                                                        javax.swing
                                                                                            .GroupLayout
                                                                                            .PREFERRED_SIZE,
                                                                                        57,
                                                                                        javax.swing
                                                                                            .GroupLayout
                                                                                            .PREFERRED_SIZE))
                                                                            .addGroup(
                                                                                layout
                                                                                    .createParallelGroup(
                                                                                        javax.swing
                                                                                            .GroupLayout
                                                                                            .Alignment
                                                                                            .LEADING)
                                                                                    .addComponent(
                                                                                        jLabel9)
                                                                                    .addGroup(
                                                                                        javax.swing
                                                                                            .GroupLayout
                                                                                            .Alignment
                                                                                            .TRAILING,
                                                                                        layout
                                                                                            .createSequentialGroup()
                                                                                            .addComponent(
                                                                                                btnPrevious)
                                                                                            .addPreferredGap(
                                                                                                javax
                                                                                                    .swing
                                                                                                    .LayoutStyle
                                                                                                    .ComponentPlacement
                                                                                                    .RELATED)
                                                                                            .addComponent(
                                                                                                btnNext)
                                                                                            .addGap(
                                                                                                6,
                                                                                                6,
                                                                                                6))))))
                                                    .addGap(18, 18, 18))
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addGap(147, 147, 147)
                                                    .addComponent(
                                                        jLabel1,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        316,
                                                        Short.MAX_VALUE))))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(jLabel6)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(
                                        cbxSearch,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(
                                        txtSearch,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        127,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(btnSearch)))
                    .addContainerGap())
            .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 590, Short.MAX_VALUE)
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 590, Short.MAX_VALUE));

    layout.linkSize(
        javax.swing.SwingConstants.HORIZONTAL,
        new java.awt.Component[] {btnAnnuler, btnEffacer, btnEnregistrer, btnModifier});

    layout.linkSize(
        javax.swing.SwingConstants.HORIZONTAL,
        new java.awt.Component[] {ftxtDimension, lblDensité, txtNom, txtPoids});

    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(jLabel1)
                                    .addGap(23, 23, 23)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(
                                                txtNom,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel2)
                                            .addComponent(btnPrevious)
                                            .addComponent(btnNext))
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(
                                                txtPoids,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel3))
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jLabel4)
                                            .addComponent(
                                                ftxtDimension,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel9))
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jLabel5)
                                            .addComponent(
                                                txtSections,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblDensité))
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(btnModifier)
                                            .addComponent(btnEnregistrer)
                                            .addComponent(btnEffacer)
                                            .addComponent(btnAnnuler)))
                            .addComponent(
                                jScrollPane1,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                180,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        jSeparator1,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        10,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(
                                cbxSearch,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                txtSearch,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnSearch))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        jSeparator2,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        10,
                        javax.swing.GroupLayout.PREFERRED_SIZE)));

    layout.linkSize(
        javax.swing.SwingConstants.VERTICAL,
        new java.awt.Component[] {ftxtDimension, lblDensité, txtNom, txtPoids});

    pack();
  } // </editor-fold>//GEN-END:initComponents
  /** Create the panel. */
  public TelaEnderecoEntregaPedido() {
    super();
    setBorder(
        new TitledBorder(
            null, "Endere\u00E7o de Entrega", TitledBorder.LEADING, TitledBorder.TOP, this.fonte));
    panel = this;

    setLayout(new MigLayout("", "[45.00][222.00,grow][63.00][grow]", "[][][][][][grow,bottom]"));

    try {
      mascaraCEP = new MaskFormatter("#####-###");
      mascaraCEP.setPlaceholderCharacter('_');
    } catch (ParseException e2) {
      showMensagemErro();
    }

    lblRua = new JLabel("Rua:");
    add(lblRua, "cell 0 0,alignx trailing");

    textFieldRua = new JTextField();
    add(textFieldRua, "cell 1 0,growx");
    textFieldRua.setColumns(10);

    lblNumero = new JLabel("N\u00FAmero:");
    add(lblNumero, "cell 2 0,alignx trailing");

    textFieldNumero = new JTextField();
    add(textFieldNumero, "cell 3 0,growx");
    textFieldNumero.setColumns(10);

    lblBairro = new JLabel("Bairro:");
    add(lblBairro, "cell 0 1,alignx trailing");

    textFieldBairro = new JTextField();
    add(textFieldBairro, "cell 1 1,growx");
    textFieldBairro.setColumns(10);

    lblCidade = new JLabel("Cidade:");
    add(lblCidade, "cell 0 2,alignx trailing");

    textFieldCidade = new JTextField();
    add(textFieldCidade, "cell 1 2,growx");
    textFieldCidade.setColumns(10);

    lblEstado = new JLabel("Estado:");
    add(lblEstado, "cell 2 2,alignx trailing");

    comboBoxEstado = new JComboBox<String>(this.estados);
    comboBoxEstado.setEnabled(true);
    add(comboBoxEstado, "cell 3 2,growx");

    lblPas = new JLabel("Pa\u00EDs:");
    add(lblPas, "cell 0 3,alignx trailing");

    textFieldPais = new JTextField();
    add(textFieldPais, "cell 1 3,growx");
    textFieldPais.setColumns(10);

    lblComplemento = new JLabel("Complemento:");
    add(lblComplemento, "cell 0 4,alignx trailing");

    textFieldComplemento = new JTextField();
    add(textFieldComplemento, "cell 1 4,growx");
    textFieldComplemento.setColumns(10);

    lblCep = new JLabel("CEP:");
    add(lblCep, "cell 2 4,alignx trailing");

    textFieldCep = new JFormattedTextField(mascaraCEP);
    add(textFieldCep, "cell 3 4,growx");
    textFieldCep.setColumns(10);

    btnOk = new JButton("OK");
    btnOk.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            String rua = textFieldRua.getText();
            String numero = textFieldNumero.getText();
            String bairro = textFieldBairro.getText();
            String complemento = textFieldComplemento.getText();
            String cidade = textFieldCidade.getText();
            String estado = (String) comboBoxEstado.getSelectedItem();
            String pais = textFieldPais.getText();
            String cep = (String) textFieldCep.getValue();
            try {
              e = new Endereco(rua, bairro, complemento, numero, cep, cidade, estado, pais);
              Container parent = panel.getParent();
              CardLayout cl = (CardLayout) parent.getLayout();
              cl.show(parent, "CadastrarPedido");
            } catch (ParametroException e1) {
              showMensagemErro(e1.getMessage());
            }
          }
        });
    add(btnOk, "cell 0 5 4 1,alignx right");
  }
 public String parse(String text, Locale locale) throws ParseException {
   return (String) delegate.stringToValue(text);
 }
Example #16
0
 private ConversionException newConversionException(String value, Throwable cause) {
   return new ConversionException(cause)
       .setResourceKey("PatternValidator")
       .setVariable("input", value)
       .setVariable("pattern", maskFormatter.getMask());
 }
  /** Create the frame. */
  public GIncidencia() {

    setIconImage(
        Toolkit.getDefaultToolkit()
            .getImage(
                GIncidencia.class.getResource("/javax/swing/plaf/basic/icons/JavaCup16.png")));
    setResizable(false);
    setTitle("  Ingresar Nueva GIncidencia");
    setBounds(100, 100, 887, 575);
    getContentPane().setLayout(null);

    lblMensListado2 = new JLabel("");
    lblMensListado2.setFont(new Font("Tahoma", Font.PLAIN, 13));
    lblMensListado2.setVisible(false);
    lblMensListado2.setBounds(349, 64, 346, 19);
    getContentPane().add(lblMensListado2);

    lblMensListado1 = new JLabel("");
    lblMensListado1.setVisible(false);
    lblMensListado1.setFont(new Font("Tahoma", Font.PLAIN, 13));
    lblMensListado1.setBounds(10, 64, 319, 19);
    getContentPane().add(lblMensListado1);

    panel = new JPanel();
    panel.setVisible(false);
    panel.setBounds(10, 11, 319, 515);
    panel.setBackground(new Color(51, 102, 153));
    panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    getContentPane().add(panel);
    panel.setLayout(null);

    btnListado = new JButton("LISTAR");
    btnListado.setVisible(false);
    btnListado.setBackground(SystemColor.controlShadow);
    btnListado.addActionListener(this);
    btnListado.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource("/com/sun/java/swing/plaf/motif/icons/Warn.gif")));

    Incidencia = new JScrollPane();
    Incidencia.setVisible(false);
    Incidencia.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
    Incidencia.setBounds(339, 103, 522, 388);
    getContentPane().add(Incidencia);

    txtIncidencia = new JTextArea();
    txtIncidencia.setFont(new Font("Arial", Font.PLAIN, 17));
    txtIncidencia.setToolTipText("");
    Incidencia.setViewportView(txtIncidencia);

    btnLimpiar = new JButton("LIMPIAR");
    btnLimpiar.setVisible(false);

    btnBuscar = new JButton("BUSCAR");
    btnBuscar.setVisible(false);

    btnNuevo = new JButton("NUEVO");
    btnNuevo.setVisible(false);
    btnNuevo.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource("/com/sun/java/swing/plaf/windows/icons/File.gif")));
    btnNuevo.setBackground(SystemColor.controlShadow);
    btnNuevo.setBounds(339, 11, 228, 33);
    getContentPane().add(btnNuevo);

    btnNuevo.addActionListener(this);
    btnBuscar.setBackground(SystemColor.controlShadow);
    btnBuscar.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource("/com/sun/java/swing/plaf/windows/icons/Directory.gif")));
    btnBuscar.setBounds(339, 11, 228, 33);
    getContentPane().add(btnBuscar);
    btnBuscar.addActionListener(this);
    btnLimpiar.setIcon(
        new ImageIcon(GIncidencia.class.getResource("/javax/swing/plaf/metal/icons/sortDown.png")));
    btnLimpiar.setBackground(SystemColor.controlShadow);
    btnLimpiar.setBounds(633, 11, 228, 33);
    getContentPane().add(btnLimpiar);
    btnLimpiar.addActionListener(this);

    btnRegistrar = new JButton("REGISTRAR");
    btnRegistrar.setVisible(false);
    btnRegistrar.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource(
                "/com/sun/javafx/webkit/prism/resources/mediaPlayDisabled.png")));
    btnRegistrar.setBackground(SystemColor.controlShadow);
    btnRegistrar.setBounds(339, 55, 522, 37);
    getContentPane().add(btnRegistrar);
    btnRegistrar.addActionListener(this);

    btnModificar = new JButton("MODIFICAR");
    btnModificar.setVisible(false);
    btnModificar.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource(
                "/com/sun/javafx/scene/control/skin/caspian/dialog-more-details.png")));
    btnModificar.setBackground(SystemColor.controlShadow);
    btnModificar.setBounds(339, 55, 522, 37);
    getContentPane().add(btnModificar);
    btnModificar.addActionListener(this);
    btnListado.setBounds(10, 11, 260, 37);
    getContentPane().add(btnListado);

    JSeparator separator = new JSeparator();
    separator.setBounds(10, 111, 299, 7);
    panel.add(separator);

    JSeparator separator_1 = new JSeparator();
    separator_1.setBounds(10, 294, 299, 14);
    panel.add(separator_1);

    JLabel lblNewLabel = new JLabel("CODIGO DE USUARIO:");
    lblNewLabel.setForeground(Color.WHITE);
    lblNewLabel.setBounds(10, 36, 172, 14);
    panel.add(lblNewLabel);

    JLabel lblCodigo = new JLabel("CODIGO DE INCIDENCIA: ");
    lblCodigo.setForeground(Color.WHITE);
    lblCodigo.setBounds(10, 11, 172, 14);
    panel.add(lblCodigo);

    txtCodigo = new JTextField();
    txtCodigo.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtCodigo.setHorizontalAlignment(SwingConstants.RIGHT);
    txtCodigo.setBackground(SystemColor.controlShadow);
    txtCodigo.setEditable(false);
    txtCodigo.setBounds(203, 9, 106, 17);
    panel.add(txtCodigo);
    txtCodigo.setColumns(10);

    txtCodUsu = new JTextField();
    txtCodUsu.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtCodUsu.setHorizontalAlignment(SwingConstants.RIGHT);
    txtCodUsu.setBackground(SystemColor.controlShadow);
    txtCodUsu.setEditable(false);
    txtCodUsu.setColumns(10);
    txtCodUsu.setBounds(203, 34, 106, 17);
    panel.add(txtCodUsu);

    JLabel lblCodigoDeEspecialista = new JLabel("CODIGO DE ESPECIALISTA:");
    lblCodigoDeEspecialista.setForeground(Color.WHITE);
    lblCodigoDeEspecialista.setBounds(10, 61, 172, 14);
    panel.add(lblCodigoDeEspecialista);

    JLabel lblCodigoDeTipo = new JLabel("CODIGO DE TIPO DE INCIDENCIA:");
    lblCodigoDeTipo.setForeground(Color.WHITE);
    lblCodigoDeTipo.setBounds(10, 86, 188, 14);
    panel.add(lblCodigoDeTipo);

    JLabel lblDescripcion = new JLabel("DESCRIPCION:");
    lblDescripcion.setForeground(Color.WHITE);
    lblDescripcion.setBounds(10, 115, 110, 14);
    panel.add(lblDescripcion);

    JLabel lblComentariosObservaciones = new JLabel("COMENTARIOS / OBSERVACIONES:");
    lblComentariosObservaciones.setForeground(Color.WHITE);
    lblComentariosObservaciones.setBounds(10, 198, 188, 28);
    panel.add(lblComentariosObservaciones);

    JLabel lblTiempoEstimadoDe = new JLabel("TIEMPO ESTIMADO DE SOLUCION:");
    lblTiempoEstimadoDe.setForeground(Color.WHITE);
    lblTiempoEstimadoDe.setBounds(10, 309, 203, 14);
    panel.add(lblTiempoEstimadoDe);

    txtTiempoEstimado = new JTextField();
    txtTiempoEstimado.addKeyListener(this);
    txtTiempoEstimado.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtTiempoEstimado.setHorizontalAlignment(SwingConstants.RIGHT);
    txtTiempoEstimado.setColumns(10);
    txtTiempoEstimado.setBounds(215, 306, 94, 17);
    panel.add(txtTiempoEstimado);

    JLabel lblTiempoRealDe = new JLabel("TIEMPO REAL DE SOLUCION:");
    lblTiempoRealDe.setForeground(Color.WHITE);
    lblTiempoRealDe.setBounds(10, 337, 172, 14);
    panel.add(lblTiempoRealDe);

    txtTiempoReal = new JTextField();
    txtTiempoReal.addKeyListener(this);
    txtTiempoReal.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtTiempoReal.setHorizontalAlignment(SwingConstants.RIGHT);
    txtTiempoReal.setColumns(10);
    txtTiempoReal.setBounds(215, 334, 94, 17);
    panel.add(txtTiempoReal);

    JLabel lblFechaDeRegistro = new JLabel("FECHA DE REGISTRO:");
    lblFechaDeRegistro.setForeground(Color.WHITE);
    lblFechaDeRegistro.setBounds(10, 365, 172, 14);
    panel.add(lblFechaDeRegistro);

    txtFecRegistro = new JTextField();
    txtFecRegistro.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtFecRegistro.setHorizontalAlignment(SwingConstants.RIGHT);
    txtFecRegistro.setBackground(SystemColor.controlShadow);
    txtFecRegistro.setEditable(false);
    txtFecRegistro.setColumns(10);
    txtFecRegistro.setBounds(181, 362, 128, 17);
    panel.add(txtFecRegistro);

    JLabel lblFechaDeInicio = new JLabel("FECHA DE INICIO DE ATENCION:");
    lblFechaDeInicio.setForeground(Color.WHITE);
    lblFechaDeInicio.setBounds(10, 393, 188, 14);
    panel.add(lblFechaDeInicio);

    try {
      MaskFormatter mascara = new MaskFormatter("##-##-####");
      mascara.setPlaceholderCharacter(' ');
      txtFecInicio = new JFormattedTextField(mascara);
      txtFecInicio.setHorizontalAlignment(SwingConstants.RIGHT);
      txtFecInicio.setFont(new Font("Tahoma", Font.PLAIN, 13));
      txtFecInicio.setBounds(215, 390, 100, 17);
      panel.add(txtFecInicio);
    } catch (Exception e) {
      e.printStackTrace();
    }

    JLabel lblFechaDeFin = new JLabel("FECHA FINAL DE ATENCION:");
    lblFechaDeFin.setForeground(Color.WHITE);
    lblFechaDeFin.setBounds(10, 421, 172, 14);
    panel.add(lblFechaDeFin);

    try {
      MaskFormatter mascara = new MaskFormatter("##-##-####");
      mascara.setPlaceholderCharacter(' ');
      txtFecFinal = new JFormattedTextField(mascara);
      txtFecFinal.setHorizontalAlignment(SwingConstants.RIGHT);
      txtFecFinal.setFont(new Font("Tahoma", Font.PLAIN, 13));
      txtFecFinal.setBounds(215, 418, 100, 17);
      panel.add(txtFecFinal);
    } catch (Exception e) {
      e.printStackTrace();
    }

    JLabel lblEstado = new JLabel("ESTADO:");
    lblEstado.setForeground(Color.WHITE);
    lblEstado.setBounds(10, 449, 86, 14);
    panel.add(lblEstado);

    cboEstado = new JComboBox();
    cboEstado.setFont(new Font("Tahoma", Font.PLAIN, 13));
    cboEstado.setBackground(UIManager.getColor("Button.background"));
    cboEstado.setModel(
        new DefaultComboBoxModel(new String[] {"Registrada", "Iniciada", "Cancelada", "Cerrada"}));
    cboEstado.setBounds(137, 446, 172, 20);
    panel.add(cboEstado);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(10, 129, 299, 69);
    panel.add(scrollPane_1);

    txtDescripcion = new JTextArea();
    txtDescripcion.addKeyListener(this);
    txtDescripcion.setFont(new Font("Arial", Font.PLAIN, 19));
    scrollPane_1.setViewportView(txtDescripcion);

    JScrollPane scrollPane_2 = new JScrollPane();
    scrollPane_2.setBounds(10, 220, 299, 69);
    panel.add(scrollPane_2);

    txtObservacion = new JTextArea();
    txtObservacion.addKeyListener(this);
    txtObservacion.setFont(new Font("Arial", Font.PLAIN, 19));
    scrollPane_2.setViewportView(txtObservacion);

    cboEspecialista = new JComboBox();
    cboEspecialista.setFont(new Font("Tahoma", Font.PLAIN, 13));
    cboEspecialista.setBounds(203, 58, 106, 20);
    cboEspecialista.addItem("");
    panel.add(cboEspecialista);

    cboTipoInc = new JComboBox();
    cboTipoInc.setFont(new Font("Tahoma", Font.PLAIN, 13));
    cboTipoInc.setBounds(203, 83, 106, 20);
    cboTipoInc.addItem("");
    panel.add(cboTipoInc);

    btnImprimir = new JButton("IMPRIMIR");
    btnImprimir.addActionListener(this);
    btnImprimir.setIcon(
        new ImageIcon(GIncidencia.class.getResource("/sun/print/resources/orientLandscape.png")));
    btnImprimir.setBounds(633, 493, 228, 33);
    getContentPane().add(btnImprimir);

    Listado = new JScrollPane(TablaIncidencias);
    Listado.setVisible(false);
    Listado.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
    JViewport viewport = new JViewport();
    Listado.setRowHeaderView(viewport);
    Listado.setBounds(10, 99, 861, 347);
    getContentPane().add(Listado);

    TablaIncidencias = new JTable();
    TablaIncidencias.setFont(new Font("Tahoma", Font.PLAIN, 13));
    TablaIncidencias.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    Listado.setViewportView(TablaIncidencias);
    columnas();
    tamañoColumnas();

    llenaCampos();
  }