Ver Comentarios

37 10-27-11 rpneosdió: Probando_Validar_JFormatedTextField.javapackage data.amayasystems.com;import java.awt.Dimension;import java.awt.Toolkit;import javax.swing.JOptionPane;/** * * @author Ing. Randy F. Amaya Guillen * UTH - Campus La Ceiba * Movil: +504 9565 4366 * Email: * * COMPUTRACHOS.COM * La Comunidad Donde el Conocimiento se Comparte. * * */public class Probando_Validar_JFormatedTextField extends javax.swing.JFrame { public Probando_Validar_JFormatedTextField() { initComponents(); Validar_Numeros_Double validar = new Validar_Numeros_Double(); validar.Validar_Numeros(importe,11); Dimension pantalla=Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation((pantalla.width-this.getPreferredSize().width)/2,(pantalla.height-this.getPreferredSize().height)/2); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { titulo = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); importe = new javax.swing.JFormattedTextField(); salir = new javax.swing.JButton(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); titulo.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N titulo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); titulo.setText("Probando Validar JFormatedTextField"); titulo.setName("titulo"); // NOI18N jLabel1.setText("Importe:"); jLabel1.setName("jLabel1"); // NOI18N importe.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00")))); importe.setName("importe"); // NOI18N importe.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { importeKeyTyped(evt); } }); salir.setText("Cerrar"); salir.setName("salir"); // NOI18N salir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { salirActionPerformed(evt); } }); jButton1.setText("Obtener"); jButton1.setName("jButton1"); // NOI18N jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(titulo, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGap(20, 20, 20) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(jButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(salir)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(importe, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE))))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(titulo, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(importe, javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(salir) .addComponent(jButton1)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void salirActionPerformed(java.awt.event.ActionEvent evt) { System.exit(0); } private void importeKeyTyped(java.awt.event.KeyEvent evt) { } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { JOptionPane.showMessageDialog(null,importe.getText()); } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Probando_Validar_JFormatedTextField().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JFormattedTextField importe; private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JButton salir; private javax.swing.JLabel titulo; // End of variables declaration}Validar_Numeros_Double.javapackage data.amayasystems.com;import java.awt.event.KeyAdapter;import java.awt.event.KeyEvent;import javax.swing.JFormattedTextField;public class Validar_Numeros_Double{ public Validar_Numeros_Double() { } public void Validar_Numeros(Object objeto, final int tamano) { final JFormattedTextField temp1=(JFormattedTextField) objeto; temp1.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent e) { if(Character.isDigit(e.getKeyChar())||e.getKeyChar()==´.´||e.getKeyChar()==e.VK_ENTER) { if(temp1.getText().length()>=tamano) { e.consume(); } } else { e.consume(); } } }); }} +1Fue útil la respuesta?

Autor: QUeFhODKsfwoEsrLvPM

necesito cbimaar la placa vieja de mi carropor favor indiqueme que debo hacer o adonde me dirijo vivo en sancristobal estado tachira

Autor: zAbOqkJIJCDgUtBOK

If I communcaited I could thank you enough for this, I´d be lying.

Autor: XBvdTfBgJkoVBAlAk

Great arictle, thank you again for writing.

Autor: uKiiRkLpXEBWVfw

This arictle keeps it real, no doubt.

Autor: UgHtGGUSoNYhuQsVKDd

I have been so bewlidered in the past but now it all makes sense!

Autor: EktHCfCuSRtATTHj

wh0cd875861 cialis mail order

Autor: PhyllisLop