miércoles, 25 de noviembre de 2015

Clase HomeCliente

package pacman;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.TextArea;

import javax.swing.SwingConstants;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Toolkit;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.border.BevelBorder;
import javax.swing.border.TitledBorder;
import java.awt.List;
import javax.swing.DropMode;
import java.awt.SystemColor;
import javax.swing.UIManager;
import javax.swing.ImageIcon;
import javax.swing.JProgressBar;

public class HomeCliente extends JFrame {

private JPanel contentPane;
private static LoginCliente log;
private BaseDatos bd ;
private Partida partida;
private JTextArea textArea;
private int iPartidas=1;
private ClientePacman cliente;
private boolean IniciarPartida=true;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
//Home frame = new Home(log);
//frame.setUndecorated(true);
//frame.setLocationRelativeTo(frame);
//frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public HomeCliente(LoginCliente l) {
setIconImage(Toolkit.getDefaultToolkit().getImage(Home.class.getResource("/Imagenes/p6.png")));
setTitle("Ventana Home - Cliente");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 600, 499);
contentPane = new Fondo("/Imagenes/p4.jpg");
contentPane.setBackground(new Color(255, 255, 255));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);

log=l;
JLabel lblNewLabel = new JLabel("Bienvenido : "+ l.getUser().toUpperCase());
lblNewLabel.setForeground(Color.WHITE);
lblNewLabel.setBackground(SystemColor.info);
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setBounds(165, 11, 398, 33);
lblNewLabel.setFont(new Font("Century", Font.PLAIN, 18));
contentPane.add(lblNewLabel);

JButton btnIniciarP = new JButton("Iniciar Partida");
btnIniciarP.setFont(new Font("Century", Font.PLAIN, 10));
btnIniciarP.setForeground(Color.WHITE);
btnIniciarP.setBackground(SystemColor.activeCaption);
btnIniciarP.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

if (IniciarPartida){
iniciarPartida();
}else{
JOptionPane.showMessageDialog(null, "No se puede iniciar una partida, Cierre Session y vuelva a Intentar.","Error", JOptionPane.ERROR_MESSAGE);
}

}
});
btnIniciarP.setBounds(15, 78, 111, 33);
contentPane.add(btnIniciarP);

JButton btnHistorial = new JButton("Historial");
btnHistorial.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// txtPanel.setText("No tiene Historial Registrado al Momento");
bd = new BaseDatos();
bd.consultarHistorial(textArea,log.getUser());

}
});
btnHistorial.setFont(new Font("Century", Font.PLAIN, 10));
btnHistorial.setForeground(SystemColor.info);
btnHistorial.setBackground(SystemColor.activeCaption);
btnHistorial.setBounds(15, 122, 111, 33);
contentPane.add(btnHistorial);

JButton btnCSesion = new JButton("Cerrar Sesión");
btnCSesion.setFont(new Font("Century", Font.PLAIN, 10));
btnCSesion.setForeground(Color.WHITE);
btnCSesion.setBackground(new Color(165, 42, 42));
btnCSesion.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
log.setVisible(true);
dispose();
}
});
btnCSesion.setBounds(15, 409, 111, 33);
contentPane.add(btnCSesion);

JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(165, 80, 398, 364);
contentPane.add(scrollPane);

textArea = new JTextArea();
textArea.setFont(new Font("Monospaced", Font.PLAIN, 14));
textArea.setForeground(Color.ORANGE);
textArea.setBackground(Color.BLACK);
scrollPane.setViewportView(textArea);
}

private void iniciarPartida(){

cliente = new ClientePacman(log.getSocket(),log.getSalidadato(),log.getEntradaDatos());
IniciarPartida=false;

}


}