/* * The MIT License * * Copyright 2014, 2015, 2016 Rui Martinho (rmartinho@gmail.com), António Braz (antoniocbraz@gmail.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package org.poreid.dialogs.pindialogs.wrongpin; import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; import org.poreid.config.POReIDConfig; import org.poreid.dialogs.DialogEventListener; /** * * @author POReID */ public class WrongPinDialog extends javax.swing.JDialog { private final String pinLabel; private final int pinTriesLeft; private final DialogEventListener<Void> listener; private final ResourceBundle bundle; /** * Creates new Dialog WarnBlockedPin * @param pinLabel Descrição textual do pin * @param pinTriesLeft Tentativas até bloqueio do pin * @param locale Linguagem utilizada * @param listener Objecto a notificar */ public WrongPinDialog(String pinLabel, int pinTriesLeft, Locale locale, DialogEventListener<Void> listener) { super(); this.pinLabel = pinLabel; this.pinTriesLeft = pinTriesLeft; this.listener = listener; bundle = POReIDConfig.getBundle(WrongPinDialog.class.getSimpleName(),locale); initComponents(); this.setTitle(MessageFormat.format(bundle.getString("dialog.title"),pinLabel)); this.getAccessibleContext().setAccessibleDescription(MessageFormat.format(bundle.getString("dialog.description"), pinLabel)); } /** * 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() { jPanel3 = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); cancelBtn = new javax.swing.JButton(); retryBtn = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setAlwaysOnTop(true); setBackground(new java.awt.Color(228, 228, 228)); setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL); setResizable(false); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); jPanel3.setBackground(new java.awt.Color(228, 228, 228)); jLabel3.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jLabel3.setText(MessageFormat.format(bundle.getString("dialog.message"), pinLabel,pinTriesLeft)); jPanel1.setBackground(new java.awt.Color(228, 228, 228)); jPanel1.setLayout(new java.awt.GridLayout(0, 1)); jLabel1.setBackground(new java.awt.Color(228, 228, 228)); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource(POReIDConfig.IMAGE_WARNING_LOCATION))); jLabel1.setMaximumSize(new java.awt.Dimension(64, 64)); jLabel1.setMinimumSize(new java.awt.Dimension(64, 64)); jLabel1.setPreferredSize(new java.awt.Dimension(64, 64)); jPanel1.add(jLabel1); jPanel2.setBackground(new java.awt.Color(228, 228, 228)); jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 25, 2)); cancelBtn.setFont(cancelBtn.getFont().deriveFont(cancelBtn.getFont().getSize()-1f)); cancelBtn.setText(bundle.getString("cancel.button")); cancelBtn.getAccessibleContext().setAccessibleDescription(bundle.getString("cancel.button.description")); cancelBtn.setMaximumSize(new java.awt.Dimension(136, 30)); cancelBtn.setMinimumSize(new java.awt.Dimension(136, 30)); cancelBtn.setPreferredSize(new java.awt.Dimension(136, 30)); cancelBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelBtnActionPerformed(evt); } }); jPanel2.add(cancelBtn); retryBtn.setFont(retryBtn.getFont().deriveFont(retryBtn.getFont().getSize()-1f)); retryBtn.setText(bundle.getString("retry.button")); retryBtn.setMaximumSize(new java.awt.Dimension(136, 30)); retryBtn.setMinimumSize(new java.awt.Dimension(136, 30)); retryBtn.setPreferredSize(new java.awt.Dimension(136, 30)); retryBtn.getAccessibleContext().setAccessibleDescription(bundle.getString("retry.button.description")); retryBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { retryBtnActionPerformed(evt); } }); jPanel2.add(retryBtn); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap()) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(0, 0, 0) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(0, 0, 0)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(0, 0, 0) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(0, 0, 0)) ); pack(); setLocationRelativeTo(null); }// </editor-fold>//GEN-END:initComponents private void retryBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_retryBtnActionPerformed listener.onContinue(); dispose(); }//GEN-LAST:event_retryBtnActionPerformed private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed listener.onCancel(); dispose(); }//GEN-LAST:event_cancelBtnActionPerformed private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing listener.onDiagloclosed(); dispose(); }//GEN-LAST:event_formWindowClosing // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton cancelBtn; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel3; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JButton retryBtn; // End of variables declaration//GEN-END:variables }