package org.project;
import java.awt.event.*;
import java.io.IOException;
import java.sql.SQLException;
import java.awt.*;
import javax.swing.*;
public class guiMenu {
private JFrame frame; //Sets the frame
private JPanel panel; //Sets the panel
private JLabel picture; //Sets the label
private JButton btnReadFile, btnReadDatabase, btnOpenMatchResults; //Sets the buttons
static Font a = new Font ("Verdana", Font.BOLD, 11); //Sets a new font
public static void main(String[]args){
new guiMenu();
}
/**
* @param args
*/
public guiMenu()
{
// TODO Auto-generated method stub
frame = new JFrame("The Football League Championship (2008 - 2009)"); //Sets the form name and size
frame.setSize(600, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel = new JPanel(); //Sets the panel
panel.setLayout(null);
panel.setBackground(Color.white);
panel.add(new TextArea(), BorderLayout.CENTER);
btnOpenMatchResults = new JButton("Match Results", new ImageIcon("open.gif"));; //Adds button to the panel, settings its size, co-ordinates and font
btnOpenMatchResults.setBounds(355, 103, 200, 40);
btnOpenMatchResults.setFont(a);
btnOpenMatchResults.addActionListener(new ViewMatchResults()); //Adds action listener to the button
panel.add(btnOpenMatchResults);
btnReadFile = new JButton("Update League Table", new ImageIcon("update.gif"));
btnReadFile.setBounds(355, 166, 200, 40);
btnReadFile.setFont(a);
btnReadFile.addActionListener(new ReadMatchFile()); //Adds action listener to the button
panel.add(btnReadFile);
btnReadDatabase = new JButton("League Table", new ImageIcon("open.gif"));; //Adds button to the panel, settings its size, co-ordinates and font
btnReadDatabase.setBounds(355, 232, 200, 40);
btnReadDatabase.setFont(a);
btnReadDatabase.addActionListener(new ReadTheDatabase()); //Adds action listener to the button
panel.add(btnReadDatabase);
ImageIcon image = new ImageIcon ("football.gif"); //Adds an image to the panel, setting its size and co-ordinates
picture = new JLabel (image);
picture.setBounds (0,0,600,400);
panel.add(picture);
frame.getContentPane().add(panel);
frame.setVisible(true);
}
class ReadMatchFile implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
//Object source = event.getSource();
System.out.println("Results have been updates in the League Table");
readFile fileIn = new readFile();
try
{
fileIn.readIn();
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
class ReadTheDatabase implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
//Object source = event.getSource();
readDatabase ReadIn = null;
try {
ReadIn = new readDatabase();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try
{
ReadIn.readData();
}
catch (SQLException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
class ViewMatchResults implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
//Object source = event.getSource();
openResults fileIn = new openResults();
try
{
fileIn.readMatch();
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}