📄 jpassworddialog.java
字号:
// Tina POS is a point of sales application designed for touch screens.// Copyright (C) 2005 Adrian Romero Corchado.// http://sourceforge.net/projects/tinapos//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USApackage net.adrianromero.beans;import java.awt.*;import javax.swing.*;import java.util.*;public class JPasswordDialog extends javax.swing.JDialog { private static ResourceBundle m_Intl; private String m_sPassword; /** Creates new form JCalendarDialog */ public JPasswordDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); // Recursos del sistema if (m_Intl == null) { m_Intl = ResourceBundle.getBundle("net.adrianromero.beans.IntlCalendar"); } } /** Creates new form JCalendarDialog */ public JPasswordDialog(java.awt.Dialog parent, boolean modal) { super(parent, modal); // Recursos del sistema if (m_Intl == null) { m_Intl = ResourceBundle.getBundle("net.adrianromero.beans.IntlCalendar"); } } private static Window getWindow(Component parent) { if (parent == null) { return new JFrame(); } else if (parent instanceof Frame || parent instanceof Dialog) { return (Window) parent; } else { return getWindow(parent.getParent()); } } public static String showEditPassword(Component parent, String sTitle) { return showEditPassword(parent, sTitle, null, null); } public static String showEditPassword(Component parent, String sTitle, String sMessage) { return showEditPassword(parent, sTitle, sMessage, null); } public static String showEditPassword(Component parent, String sTitle, String sMessage, Icon icon) { Window window = getWindow(parent); JPasswordDialog myMsg; if (window instanceof Frame) { myMsg = new JPasswordDialog((Frame) window, true); } else { myMsg = new JPasswordDialog((Dialog) window, true); } myMsg.initComponents(); myMsg.getRootPane().setDefaultButton(myMsg.jcmdOK); myMsg.m_jpassword.addEditorKeys(myMsg.m_jKeys); myMsg.m_jpassword.reset(); myMsg.m_jpassword.activate(); myMsg.setTitle(sTitle); myMsg.m_lblMessage.setText(sMessage); myMsg.m_lblMessage.setIcon(icon); myMsg.m_jPanelTitle.setBorder(RoundedBorder.createGradientBorder()); myMsg.m_sPassword = null; myMsg.setVisible(true); return myMsg.m_sPassword; } /** 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. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); jcmdOK = new javax.swing.JButton(); jcmdCancel = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); jPanelGrid = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); m_jKeys = new net.adrianromero.editor.JEditorKeys(); jPanel4 = new javax.swing.JPanel(); m_jpassword = new net.adrianromero.editor.JEditorPassword(); m_jPanelTitle = new javax.swing.JPanel(); m_lblMessage = new javax.swing.JLabel(); setResizable(false); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { closeWindow(evt); } }); jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/adrianromero/images/button_ok.png"))); jcmdOK.setText(m_Intl.getString("button.ok")); jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); jcmdOK.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jcmdOKActionPerformed(evt); } }); jPanel1.add(jcmdOK); jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/adrianromero/images/button_cancel.png"))); jcmdCancel.setText(m_Intl.getString("button.cancel")); jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); jcmdCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jcmdCancelActionPerformed(evt); } }); jPanel1.add(jcmdCancel); getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH); jPanel2.setLayout(new java.awt.BorderLayout()); jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS)); jPanel3.add(m_jKeys); jPanel4.setLayout(new java.awt.BorderLayout()); jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); jPanel4.add(m_jpassword, java.awt.BorderLayout.CENTER); jPanel3.add(jPanel4); jPanelGrid.add(jPanel3); jPanel2.add(jPanelGrid, java.awt.BorderLayout.CENTER); getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER); m_jPanelTitle.setLayout(new java.awt.BorderLayout()); m_lblMessage.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, java.awt.Color.darkGray), javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5))); m_jPanelTitle.add(m_lblMessage, java.awt.BorderLayout.CENTER); getContentPane().add(m_jPanelTitle, java.awt.BorderLayout.NORTH); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); setBounds((screenSize.width-258)/2, (screenSize.height-435)/2, 258, 435); }// </editor-fold>//GEN-END:initComponents private void jNumberKeys21KeyPerformed(net.adrianromero.beans.JNumberEvent evt) {//GEN-FIRST:event_jNumberKeys21KeyPerformed }//GEN-LAST:event_jNumberKeys21KeyPerformed private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed m_sPassword = m_jpassword.getPassword(); setVisible(false); dispose(); }//GEN-LAST:event_jcmdOKActionPerformed private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed setVisible(false); dispose(); }//GEN-LAST:event_jcmdCancelActionPerformed private void closeWindow(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeWindow setVisible(false); dispose(); }//GEN-LAST:event_closeWindow // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanelGrid; private javax.swing.JButton jcmdCancel; private javax.swing.JButton jcmdOK; private net.adrianromero.editor.JEditorKeys m_jKeys; private javax.swing.JPanel m_jPanelTitle; private net.adrianromero.editor.JEditorPassword m_jpassword; private javax.swing.JLabel m_lblMessage; // End of variables declaration//GEN-END:variables }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -