import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Random;
import java.util.TimerTask;
//import java.util.Timer;
import java.lang.ClassLoader;
import java.net.URL;
import javax.swing.*;
import javax.swing.Timer;
public class Simulator extends JFrame implements MouseListener{
int posX=0,posY=0;
//ImageIcon bBlueBuffIcon = new ImageIcon("Res/images/bgolem.png");
ImageIcon bBlueBuffIcon = new ImageIcon(getClass().getResource("/Res/images/bgolem.png"));
ImageIcon pBlueBuffIcon = new ImageIcon(getClass().getResource("/Res/images/pgolem.png"));
ImageIcon bRedBuffIcon = new ImageIcon(getClass().getResource("Res/images/bred.png"));
ImageIcon pRedBuffIcon = new ImageIcon(getClass().getResource("Res/images/pred.png"));
ImageIcon baronIcon = new ImageIcon(getClass().getResource("Res/images/baron.png"));
ImageIcon dragonBuffIcon = new ImageIcon(getClass().getResource("Res/images/dragon.png"));
private JButton bBlueBuff = new JButton(bBlueBuffIcon);
private JButton pBlueBuff = new JButton(pBlueBuffIcon);
private JButton bRedBuff = new JButton(bRedBuffIcon);
private JButton pRedBuff = new JButton(pRedBuffIcon);
private JButton dragon = new JButton(dragonBuffIcon);
private JButton baron = new JButton(baronIcon);
private JButton reset = new JButton("Reset");
private JButton resize = new JButton("Resize");
//ActionListener listener = new ActionListener();
//final Timer dragonTimer = new Timer(1000, listener);
private JPanel p1 = new JPanel();
private JPanel p2 = new JPanel();
private JPanel p3 = new JPanel();
private JPanel p4 = new JPanel();
private JPanel p5 = new JPanel();
private JPanel p6 = new JPanel();
private JPanel p0 = new JPanel();
private static JProgressBar bBlueBuffBar = new JProgressBar();
private JProgressBar pBlueBuffBar = new JProgressBar();
private JProgressBar bRedBuffBar = new JProgressBar();
private JProgressBar pRedBuffBar = new JProgressBar();
private JProgressBar baronBar = new JProgressBar();
private JProgressBar dragonBar = new JProgressBar();
//private JButton BBlueBuff = new JButton();
//private JButton BBlueBuff = new JButton();
public final static int ONE_SECOND = 1000;
public int toggle = 0;
public String sevenB = "";
public String eightB = "";
public String nineB = "";
public String tenB = "";
public String elevenB = "";
public String twelveB = "";
public int bouncer = 0;
public int bGolemi = 10;
public int bGolemj = 300;
public int bGolemk = 0;
//private static Action EnterAction = null;
//private static Action EnterAction2 = null;
private Timer timer;
public static void main(String[] args) {
Simulator gui = new Simulator();
gui.setVisible(true);
}
public Simulator() {
Font font = new Font("Arial", Font.PLAIN, 20);
GridLayout experimentLayout = new GridLayout(1,1);
GridLayout experimentLayout2 = new GridLayout(3,2);
this.setLayout(experimentLayout);
this.setUndecorated(true);
this.setDefaultLookAndFeelDecorated(false);
//this.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
this.setSize(250,50);
this.setLocation(50,50);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
//this.setResizable(false);
this.setAlwaysOnTop(true);
this.setTitle("League Timers");
this.add(p0);
//this.setIconImage();
p0.setLayout(experimentLayout2);
//p0.setBorder(BorderFactory.createRaisedSoftBevelBorder());
Container cont = getContentPane();
((JComponent) cont).setBorder(BorderFactory.createLineBorder(Color.black, 3));
//((JComponent) cont).setBackground(Color.black);
this.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
posX=e.getX();
posY=e.getY();
}
});
this.addMouseMotionListener(new MouseAdapter()
{
public void mouseDragged(MouseEvent evt)
{
//sets frame position when mouse dragged
setLocation (evt.getXOnScreen()-posX,evt.getYOnScreen()-posY);
}
});
p1.setLayout(experimentLayout);
p1.setVisible(true);
p1.setFocusable(false);
//p2.setLocation(0,0);
p2.setLayout(experimentLayout);
p2.setVisible(true);
p2.setFocusable(false);
//p3.setLocation(0,0);
p3.setLayout(experimentLayout);
p3.setVisible(true);
p3.setFocusable(false);
//p4.setLocation(0,0);
p4.setLayout(experimentLayout);
p4.setVisible(true);
p4.setFocusable(false);
//p5.setLocation(0,0);
p5.setLayout(experimentLayout);
p5.setVisible(true);
//p5.setFocusable(false);
//p6.setLocation(0,0);
p6.setLayout(experimentLayout);
p6.setVisible(true);
//p6.setFocusable(false);
p0.add(p1);
p0.add(p2);
p0.add(p3);
p0.add(p4);
p0.add(p5);
p0.add(p6);
p1.add(bBlueBuffBar);
p2.add(bRedBuffBar);
p3.add(pBlueBuffBar);
p4.add(pRedBuffBar);
p5.add(dragonBar);
p6.add(baronBar);
//p0.add(reset);
Color customColor = new Color(115,0,255);
Color customColor2 = new Color(37,204,37);
bBlueBuffBar.setBackground(Color.white);
bBlueBuffBar.setForeground(Color.blue);
//bBlueBuffBar.selectionBackground(Color.black);
bBlueBuffBar.setStringPainted(true);
bBlueBuffBar.setString("BLUE Golem - 5:00");
bBlueBuffBar.setMaximum(300);
bBlueBuffBar.setBorder(BorderFactory.createLineBorder(Color.black));
pBlueBuffBar.setBackground(Color.white);
pBlueBuffBar.setForeground(customColor);
pBlueBuffBar.setStringPainted(true);
pBlueBuffBar.setString("PURPLE Golem - 5:00");
pBlueBuffBar.setMaximum(300);
pBlueBuffBar.setBorder(BorderFactory.createLineBorder(Color.black));
bRedBuffBar.setBackground(Color.white);
bRedBuffBar.setForeground(Color.blue);
bRedBuffBar.setStringPainted(true);
bRedBuffBar.setString("BLUE Lizard - 5:00");
bRedBuffBar.setMaximum(300);
bRedBuffBar.setBorder(BorderFactory.createLineBorder(Color.black));
pRedBuffBar.setBackground(Color.white);
pRedBuffBar.setForeground(customColor);
pRedBuffBar.setStringPainted(true);
pRedBuffBar.setString("PURPLE Lizard - 5:00");
pRedBuffBar.setMaximum(300);
pRedBuffBar.setBorder(BorderFactory.createLineBorder(Color.black));
baronBar.setBackground(Color.white);
baronBar.setForeground(customColor2);
baronBar.setStringPainted(true);
baronBar.setString("Baron - 7:00");
baronBar.setMaximum(420);
baronBar.setBorder(BorderFactory.createLineBorder(Color.black));
dragonBar.setBackground(Color.white);
dragonBar.setForeground(customColor2);
dragonBar.setStringPainted(true);
dragonBar.setString("Dragon - 6:00");
dragonBar.setMaximum(360);
dragonBar.setBorder(BorderFactory.createLineBorder(Color.black));
this.addKeyListener(new KeyListener(){
@Override
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
if(arg0.getKeyChar() == '7'){
seven();
}
if(arg0.getKeyChar() == '8'){
//eight();
}
if(arg0.getKeyChar() == '9'){
//nine();
}
if(arg0.getKeyChar() == '0'){
//ten();
}
if(arg0.getKeyChar() == '-'){
//eleven();
}
if(arg0.getKeyChar() == '='){
//twelve();
}
}
@Override
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
}
});
this.setFocusable(true);
//this.requestFocus(true);
}
public void seven(){
bBlueBuffBar.setString("BLUE Golem - 5:00");
bouncer++;
timer = new Timer(1000, new ActionListener(){
public void actionPerformed(ActionEvent event){
// if(bouncer == 2){
// timer.stop();
// bGolemi = 59;
// bGolemj = 300;
// bGolemk = 4;
// bouncer = 0;
// timer.restart();
// }
if(bGolemi == 0){
bGolemi = 59;
bGolemk--;
}
sevenB = ""+bGolemi--;
bBlueBuffBar.setValue(bGolemj--);
bBlueBuffBar.setString("BLUE Golem - "+bGolemk+":"+sevenB);
if(bGolemk <= 0 && bGolemi <= 0){
timer.stop();
bBlueBuffBar.setValue(0);
bBlueBuffBar.setString("BLUE Golem - 0:00");;
}
if (bGolemi < 0){
timer.stop();
}
}
});
if(timer.isRunning()){
timer.stop();
bGolemi = 59;
bGolemj = 300;
bGolemk = 4;
timer.start();
}
else{
bGolemi = 59;
bGolemj = 300;
bGolemk = 4;
timer.start();
}
}
/*
public void eight(){
bRedBuffBar.setString("BLUE Lizard - 5:00");
final Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask(){
int i = 59;
int j = 300;
int k = 4;
public void run(){
if(i == 0){
i = 59;
k--;
}
bRedBuffBar.setValue(j--);
//bBlueBuff.setText(k+":"+i--);
bRedBuffBar.setString("BLUE Lizard - "+k+":"+i--);
if(k <= 0 && i <= 0){
timer.cancel();
bRedBuffBar.setValue(0);
bRedBuffBar.setString("BLUE Lizard - 0:00");;
}
if (i < 0)
timer.cancel();
}
}, 0, 1000);
}
public void nine(){
pBlueBuffBar.setString("PURPLE Golem - 5:00");
final Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask(){
int i = 59;
int j = 300;
int k = 4;
public void run(){
if(i == 0){
i = 59;
k--;
}
pBlueBuffBar.setValue(j--);
//bBlueBuff.setText(k+":"+i--);
pBlueBuffBar.setString("PURPLE Golem - "+k+":"+i--);
if(k <= 0 && i <= 0){
timer.cancel();
pBlueBuffBar.setValue(0);
pBlueBuffBar.setString("PURPLE Golem - 0:00");;
}
if (i < 0)
timer.cancel();
}
}, 0, 1000);
}
public void ten(){
pRedBuffBar.setString("PURPLE Lizard - 5:00");
final Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask(){
int i = 59;
int j = 300;
int k = 4;
public void run(){
if(i == 0){
i = 59;
k--;
}
pRedBuffBar.setValue(j--);
//bBlueBuff.setText(k+":"+i--);
pRedBuffBar.setString("PURPLE Lizard - "+k+":"+i--);
if(k <= 0 && i <= 0){
timer.cancel();
pRedBuffBar.setValue(0);
pRedBuffBar.setString("PURPLE Lizard - 0:00");;
}
if (i < 0)
timer.cancel();
}
}, 0, 1000);
}
public void eleven(){
bouncer++;
if(bouncer == 2){
dragonTimer.cancel();
bouncer = 0;
}
dragonBar.setString("Dragon - 6:00");
dragonTimer.scheduleAtFixedRate(new TimerTask(){
int i = 59;
int j = 360;
int k = 5;
public void run(){
if(i == 0){
i = 59;
k--;
}
dragonBar.setValue(j--);
//bBlueBuff.setText(k+":"+i--);
dragonBar.setString("Dragon - "+k+":"+i--);
StringSelection pst = new StringSelection("Dragon Spawns in "+k+":"+i);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(pst, null);
if(k == 0 && i == 30){
//dragonBar.
}
if(k <= 0 && i <= 0){
dragonTimer.cancel();
dragonBar.setValue(0);
dragonBar.setString("Dragon - 0:00");
}
//if (i < 0)
//dragonTimer.cancel();
}
}, 0, 1000);
}
public void twelve(){
baronBar.setString("Baron - 7:00");
final Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask(){
int i = 59;
int j = 420;
int k = 6;
public void run(){
if(i == 0){
i = 59;
k--;
}
baronBar.setValue(j--);
//bBlueBuff.setText(k+":"+i--);
baronBar.setString("Baron - "+k+":"+i--);
if(k <= 0 && i <= 0){
timer.cancel();
baronBar.setValue(0);
baronBar.setString("Baron - 0:00");;
}
if (i < 0)
timer.cancel();
}
}, 0, 1000);
}*/
@Override
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
}