import java.sql.*;
import java.net.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
public class L extends JFrame
{
public L()
{
addWindowListener ( new WindowAdapter()
{
public void windowClosing ( WindowEvent e )
{
System.exit( 0 );
}
} );
initComponents();
}
JPanel panePrincipal = new JPanel();
JPanel paneBotoes = new JPanel();
private void initComponents()
{
Container c = getContentPane();
setTitle ( "L o g i n" );
c.setLayout( null );
c.add ( panePrincipal );
panePrincipal.setBounds ( 1,1,303,20 );
panePrincipal.setBackground ( new Color ( 0,255,153 ) );
c.add ( paneBotoes );
paneBotoes.setBackground ( new Color ( 0,255,153 ) );
paneBotoes.setBounds ( 1,166,303,30 );
JLabel usuarioLabel;
JLabel senhaLabel;
JLabel dataLabel;
JLabel filialLabel;
fimButton = new JButton();
okButton = new JButton();
setDefaultCloseOperation ( WindowConstants.EXIT_ON_CLOSE );
c.setBackground ( new Color ( 255, 255, 255 ) );
//labels --inicio--
usuarioLabel = new JLabel ( "Usuario" );
c.add ( usuarioLabel );
usuarioLabel.setBounds ( 40, 30, 50, 20 );
senhaLabel = new JLabel ( "Senha" );
c.add ( senhaLabel );
senhaLabel.setBounds ( 40, 60, 50, 20 );
dataLabel = new JLabel ( "Data" );
c.add ( dataLabel );
dataLabel.setBounds ( 40, 90, 50, 20 );
filialLabel = new JLabel ( "Filial" );
c.add ( filialLabel );
filialLabel.setBounds ( 40, 120, 50, 20 );
//labels --fim--
//campos editaveis JTextField --inicio--
usuarioField = new JTextField();
usuarioField.addActionListener ( new ActionListener()
{ public void actionPerformed ( ActionEvent e )
{
usuarioFieldActionPerformed( e );
senhaField.requestFocus();
senhaField.setVisible(true);
}
} );
c.add ( usuarioField );
usuarioField.setBounds ( 90, 30, 160, 19 );
senhaField = new JPasswordField();
senhaField.addActionListener ( new ActionListener()
{ public void actionPerformed ( ActionEvent e )
{
senhaFieldActionPerformed( e );
dataField.requestFocus();
dataField.setVisible(true);
}
} );
c.add ( senhaField );
senhaField.setBounds ( 90, 60, 120, 19 );
try
{ javax.swing.text.MaskFormatter mdataField = new javax.swing.text.MaskFormatter("##/##/####");
dataField = new javax.swing.JFormattedTextField(mdataField);
} catch(Exception e){}
dataField.addActionListener ( new ActionListener()
{ public void actionPerformed ( ActionEvent e )
{
filialField.requestFocus();
filialField.setVisible(true);
}
} );
c.add ( dataField );
dataField.setBounds ( 90, 90, 100, 21 );
filialField = new JTextField("01");
filialField.setColumns(02);
filialField.addActionListener ( new ActionListener()
{ public void actionPerformed ( ActionEvent e )
{
okButton.requestFocus();
okButton.setVisible(true);
}
} );
c.add ( filialField );
filialField.setBounds (90, 120, 20, 19 );
//campos editaveis JTextField --fim--
//botoes de confirma e finaliza --inicio--
okButton.setText ( "Confirma" );
okButton.setMnemonic ( 'C' );
okButton.addActionListener ( new ActionListener() {
public void actionPerformed ( ActionEvent e ) {
okButtonActionPerformed ( e );
} } );
c.add ( okButton, paneBotoes );
okButton.setBounds ( 33, 170, 100, 23 );
fimButton.setText ( "Fim" );
fimButton.setMnemonic ( 'F' );
fimButton.addActionListener ( new ActionListener() {
public void actionPerformed ( ActionEvent e ) {
fimButtonActionPerformed ( e );
} } );
c.add ( fimButton, paneBotoes );
fimButton.setBounds ( 170, 170, 100, 23 );
//botoes de confirma e finaliza --fim--
pack();
setSize( 305, 220 ); //seta o tamanho do frame
setLocationRelativeTo(null); //posiciona o frame no centro da tela
}
private void usuarioFieldActionPerformed ( ActionEvent e )
{
if ( usuarioField.equals("") )
{
usuarioField.requestFocus();
}
}
private void senhaFieldActionPerformed ( ActionEvent e )
{
}
private void filialFieldActionPerformed ( ActionEvent e )
{
}
private void okButtonActionPerformed ( ActionEvent e )
{
Menu menu = new Menu();
}
private void fimButtonActionPerformed ( ActionEvent e )
{
System.exit( 0 );
}
public static void main ( String[] args )
{
javax.swing.SwingUtilities.invokeLater ( new Runnable()
{
public void run()
{
new L().setVisible( true );
}
} );
}
private JScrollPane textpane;
private JTextArea scrollArea;
private JTextArea output;
private String url, username, password;
private Connection connect;
private JFormattedTextField mdataField;
private JTextField usuarioField;
private JPasswordField senhaField;
private JTextField filialField;
private JFormattedTextField dataField;
private JButton okButton;
private JButton fimButton;
}
[size=“11”][color=“red”]* Editado: Lembre-se de utilizar BBCode em seus códigos - Reifel[/color][/size] :joia: