nordi 1 Denunciar post Postado Setembro 17, 2005 Codigo extraido da [internet] import javax.swing.*;import java.awt.*;import java.awt.event.*;import javax.swing.text.*;import java.text.*;public class CEP extends JFrame{ JFormattedTextField caixa; MaskFormatter cep; public CEP(){ super("Uso da classe JFormattedTextField"); Container tela = getContentPane(); FlowLayout layout = new FlowLayout(FlowLayout.LEFT); tela.setLayout(layout); try{ cep = new MaskFormatter("#####-###"); cep.setPlaceholderCharacter('_'); } catch(ParseException excp){ // caso alguma exceção ocorra } caixa = new JFormattedTextField(cep); caixa.setPreferredSize(new Dimension(80, 20)); JButton ok = new JButton("OK"); ok.addActionListener( new ActionListener(){ public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog(null, caixa.getText()); } } ); tela.add(new JLabel("Informe o CEP:")); tela.add(caixa); tela.add(ok); setSize(350, 100); setVisible(true); } public static void main(String args[]){ CEP app = new CEP(); app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }}At+ http://forum.imasters.com.br/public/style_emoticons/default/joia.gif Compartilhar este post Link para o post Compartilhar em outros sites