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 Home extends JFrame {
private JPanel contentPane;
private static Login log;
private BaseDatos bd ;
private Partida partida;
private JTextArea textArea;
private List list;
private int iPartidas=1;
private JProgressBar progressBar;
private SevidorPacman servidor;
/**
* 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 Home(Login l) {
setIconImage(Toolkit.getDefaultToolkit().getImage(Home.class.getResource("/Imagenes/p6.png")));
setTitle("Ventana Home - Administrator");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 657, 498);
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, 434, 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) {
iniciarPartida();
}
});
btnIniciarP.setBounds(15, 78, 111, 33);
contentPane.add(btnIniciarP);
JButton btnCrearP = new JButton("Crear Partida");
btnCrearP.setFont(new Font("Century", Font.PLAIN, 10));
btnCrearP.setForeground(Color.WHITE);
btnCrearP.setBackground(SystemColor.activeCaption);
btnCrearP.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
crearPartida();
}
});
btnCrearP.setBounds(15, 122, 111, 33);
contentPane.add(btnCrearP);
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, 416, 111, 33);
contentPane.add(btnCSesion);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(165, 181, 434, 268);
contentPane.add(scrollPane);
textArea = new JTextArea();
textArea.setFont(new Font("Monospaced", Font.PLAIN, 11));
textArea.setForeground(Color.ORANGE);
textArea.setBackground(Color.BLACK);
scrollPane.setViewportView(textArea);
list = new List();
list.setForeground(Color.ORANGE);
list.setFont(new Font("Lucida Console", Font.PLAIN, 14));
list.setBackground(Color.BLACK);
list.setBounds(165, 78, 434, 91);
contentPane.add(list);
JLabel lblNewLabel_1 = new JLabel("PARTIDAS EN CURSO");
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 12));
lblNewLabel_1.setForeground(Color.ORANGE);
lblNewLabel_1.setBackground(Color.BLACK);
lblNewLabel_1.setBounds(165, 49, 434, 23);
contentPane.add(lblNewLabel_1);
progressBar = new JProgressBar();
progressBar.setForeground(Color.ORANGE);
progressBar.setBounds(165, 167, 434, 14);
contentPane.add(progressBar);
servidor = new SevidorPacman(textArea);
JButton btnPpartida = new JButton("Frenar Partida");
btnPpartida.setVisible(false);
btnPpartida.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
servidor.stopServer();
iPartidas = 0;
list.removeAll();
textArea.setText(null);
}
});
btnPpartida.setForeground(SystemColor.text);
btnPpartida.setFont(new Font("Century", Font.PLAIN, 10));
btnPpartida.setBackground(SystemColor.inactiveCaptionText);
btnPpartida.setBounds(15, 166, 111, 33);
contentPane.add(btnPpartida);
}
private void crearPartida() {
progressBar.setValue(0);
//Modo dialog = new Modo(this);
//dialog.setLocationRelativeTo(this);
//dialog.setVisible(true);
servidor.startServer();
String auxiliar = ("Partida N° " + iPartidas + ": " + log.getUser().toUpperCase());
iPartidas++;
list.add(auxiliar);
progressBar.setValue(100);
}
private void iniciarPartida(){
servidor.iniciarPartidaServidor();
}
}
No hay comentarios:
Publicar un comentario