/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication3;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.Timer;
/**
*
* @author Suporte01
*/
public class NewJFrame extends javax.swing.JFrame implements MouseMotionListener, MouseListener {
/**
* |--------------------------------------------------------------------------
* | Resizableframe vars
* |--------------------------------------------------------------------------
*/
private static final long serialVersionUID = 1L;
private Point start_drag;
private Point start_loc;
private Point precedent_loc;
private int precedent_width;
private int precedent_height;
Toolkit toolkit = Toolkit.getDefaultToolkit();
private int minWidth;
private int minHeight;
private Point initialLocation;
int cursorArea = 5;
Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
private int DIFF_MIN_WIDTH = 30;
private int DIFF_MIN_HEIGHT = 30;
/**
* |--------------------------------------------------------------------------
* | Tempos
* |--------------------------------------------------------------------------
*/
private static Contador tempoBlueBGolem;
private static Contador tempoBlueLizard;
private static Contador tempoBlueWi;
private static Contador tempoBlueDGolem;
private static Contador tempoBlueWolf;
private static Contador tempoBlueWr;
private static Contador tempoBaron;
private static Contador tempoDragon;
/**
* |--------------------------------------------------------------------------
* | Action Listeners
* |--------------------------------------------------------------------------
*/
public static ActionListener alblueBGolem = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
count(blueBGolem, timerBlueBGolem, tempoBlueBGolem, 1);
}
};
public static ActionListener alblueLizard = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
count(blueLizard, timerBlueLizard, tempoBlueLizard, 1);
}
};
public static ActionListener alblueWi = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
count(blueWi, timerBlueWi, tempoBlueWi, 0);
}
};
public static ActionListener alblueDGolem = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
count(blueDGolem, timerBlueDGolem, tempoBlueDGolem, 0);
}
};
public static ActionListener alblueWolf = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
count(blueWolf, timerBlueWolf, tempoBlueWolf, 0);
}
};
public static ActionListener alblueWr = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
count(blueWr, timerBlueWr, tempoBlueWr, 0);
}
};
public static ActionListener alDragon = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
count(Dragon, timerDragon, tempoDragon, 2);
}
};
public static ActionListener alBaron = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
count(Baron, timerBaron, tempoBaron, 3);
}
};
/**
* |--------------------------------------------------------------------------
* | Timers
* |--------------------------------------------------------------------------
*/
private static Timer timerBlueBGolem = new Timer(1000, alblueBGolem);
private static Timer timerBlueLizard = new Timer(1000, alblueLizard);
private static Timer timerBlueWi = new Timer(1000, alblueWi);
private static Timer timerBlueDGolem = new Timer(1000, alblueDGolem);
private static Timer timerBlueWolf = new Timer(1000, alblueWolf);
private static Timer timerBlueWr = new Timer(1000, alblueWr);
private static Timer timerBaron = new Timer(1000, alBaron);
private static Timer timerDragon = new Timer(1000, alDragon);
;
/**
* Creates new form NewJFrame
*/
public NewJFrame(Dimension initialDimension, Point initialLocation) {
this.initialLocation = initialLocation;
minWidth = (int) initialDimension.getWidth();
minHeight = (int) initialDimension.getHeight();
Init();
initComponents();
setBackground(new Color(1.0f, 1.0f, 1.0f, 0f));
Move.setBackground(new Color(1.0f, 1.0f, 1.0f, 0f));
}
private void Init() {
tempoBlueBGolem = new Contador(300);
tempoBlueLizard = new Contador(300);
tempoBlueWi = new Contador(50);
tempoBlueDGolem = new Contador(50);
tempoBlueWolf = new Contador(50);
tempoBlueWr = new Contador(50);
tempoBaron = new Contador(420);
tempoDragon = new Contador(360);
addMouseMotionListener(this);
addMouseListener(this);
this.setSize(minWidth, minHeight);
minWidth -= DIFF_MIN_WIDTH;
minHeight -= DIFF_MIN_HEIGHT;
setLocation(initialLocation);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
//
private void initComponents() {
Painel = new javax.swing.JPanel();
blueBGolem = new javax.swing.JTextField();
blueBGolemStart = new javax.swing.JButton();
blueLizardStart = new javax.swing.JButton();
blueWiStart = new javax.swing.JButton();
blueDGolemStart = new javax.swing.JButton();
blueWolfStart = new javax.swing.JButton();
blueWrStart = new javax.swing.JButton();
DragonStart = new javax.swing.JButton();
BaronStart = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
Move = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jButton9 = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setAlwaysOnTop(true);
setUndecorated(true);
Painel.setBackground(new java.awt.Color(112, 112, 112));
Painel.setOpaque(false);
Painel.setLayout(null);
blueBGolem.setEditable(false);
blueBGolem.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
blueBGolem.setForeground(new java.awt.Color(255, 255, 255));
blueBGolem.setHorizontalAlignment(javax.swing.JTextField.CENTER);
blueBGolem.setText("5:00");
blueBGolem.setOpaque(false);
blueBGolem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
blueBGolemActionPerformed(evt);
}
});
Painel.add(blueBGolem);
blueBGolem.setBounds(0, 30, 70, 20);
blueBGolemStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/javaapplication3/bluegolem.jpg"))); // NOI18N
blueBGolemStart.setBorderPainted(false);
blueBGolemStart.setContentAreaFilled(false);
blueBGolemStart.setFocusPainted(false);
blueBGolemStart.setFocusable(false);
blueBGolemStart.setMaximumSize(new java.awt.Dimension(75, 25));
blueBGolemStart.setMinimumSize(new java.awt.Dimension(75, 25));
blueBGolemStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
blueBGolemStartActionPerformed(evt);
}
});
Painel.add(blueBGolemStart);
blueBGolemStart.setBounds(0, 0, 73, 23);
blueLizardStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/javaapplication3/lizard.jpg"))); // NOI18N
blueLizardStart.setBorderPainted(false);
blueLizardStart.setContentAreaFilled(false);
blueLizardStart.setFocusPainted(false);
blueLizardStart.setFocusable(false);
blueLizardStart.setMaximumSize(new java.awt.Dimension(75, 25));
blueLizardStart.setMinimumSize(new java.awt.Dimension(75, 25));
blueLizardStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
blueLizardStartActionPerformed(evt);
}
});
Painel.add(blueLizardStart);
blueLizardStart.setBounds(70, 0, 73, 23);
blueWiStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/javaapplication3/wi.jpg"))); // NOI18N
blueWiStart.setBorderPainted(false);
blueWiStart.setContentAreaFilled(false);
blueWiStart.setFocusPainted(false);
blueWiStart.setFocusable(false);
blueWiStart.setMaximumSize(new java.awt.Dimension(75, 25));
blueWiStart.setMinimumSize(new java.awt.Dimension(75, 25));
blueWiStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
blueWiStartActionPerformed(evt);
}
});
Painel.add(blueWiStart);
blueWiStart.setBounds(140, 0, 73, 23);
blueDGolemStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/javaapplication3/golem.jpg"))); // NOI18N
blueDGolemStart.setBorderPainted(false);
blueDGolemStart.setContentAreaFilled(false);
blueDGolemStart.setFocusPainted(false);
blueDGolemStart.setFocusable(false);
blueDGolemStart.setMaximumSize(new java.awt.Dimension(75, 25));
blueDGolemStart.setMinimumSize(new java.awt.Dimension(75, 25));
blueDGolemStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
blueDGolemStartActionPerformed(evt);
}
});
Painel.add(blueDGolemStart);
blueDGolemStart.setBounds(210, 0, 73, 23);
blueWolfStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/javaapplication3/wolf.jpg"))); // NOI18N
blueWolfStart.setBorderPainted(false);
blueWolfStart.setContentAreaFilled(false);
blueWolfStart.setFocusPainted(false);
blueWolfStart.setFocusable(false);
blueWolfStart.setMaximumSize(new java.awt.Dimension(75, 25));
blueWolfStart.setMinimumSize(new java.awt.Dimension(75, 25));
blueWolfStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
blueWolfStartActionPerformed(evt);
}
});
Painel.add(blueWolfStart);
blueWolfStart.setBounds(280, 0, 73, 23);
blueWrStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/javaapplication3/wr.jpg"))); // NOI18N
blueWrStart.setBorderPainted(false);
blueWrStart.setContentAreaFilled(false);
blueWrStart.setFocusPainted(false);
blueWrStart.setFocusable(false);
blueWrStart.setMaximumSize(new java.awt.Dimension(75, 25));
blueWrStart.setMinimumSize(new java.awt.Dimension(75, 25));
blueWrStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
blueWrStartActionPerformed(evt);
}
});
Painel.add(blueWrStart);
blueWrStart.setBounds(350, 0, 73, 23);
DragonStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/javaapplication3/dragon.jpg"))); // NOI18N
DragonStart.setBorderPainted(false);
DragonStart.setContentAreaFilled(false);
DragonStart.setFocusPainted(false);
DragonStart.setFocusable(false);
DragonStart.setMaximumSize(new java.awt.Dimension(75, 25));
DragonStart.setMinimumSize(new java.awt.Dimension(75, 25));
DragonStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DragonStartActionPerformed(evt);
}
});
Painel.add(DragonStart);
DragonStart.setBounds(420, 0, 73, 23);
BaronStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/javaapplication3/baron.jpg"))); // NOI18N
BaronStart.setBorderPainted(false);
BaronStart.setContentAreaFilled(false);
BaronStart.setMaximumSize(new java.awt.Dimension(75, 25));
BaronStart.setMinimumSize(new java.awt.Dimension(75, 25));
BaronStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BaronStartActionPerformed(evt);
}
});
Painel.add(BaronStart);
BaronStart.setBounds(490, 0, 73, 23);
jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/javaapplication3/reset.png"))); // NOI18N
jButton7.setBorderPainted(false);
jButton7.setContentAreaFilled(false);
jButton7.setFocusPainted(false);
jButton7.setFocusable(false);
jButton7.setMaximumSize(new java.awt.Dimension(75, 25));
jButton7.setMinimumSize(new java.awt.Dimension(75, 25));
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
Painel.add(jButton7);
jButton7.setBounds(620, 30, 73, 23);
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/javaapplication3/move.png"))); // NOI18N
javax.swing.GroupLayout MoveLayout = new javax.swing.GroupLayout(Move);
Move.setLayout(MoveLayout);
MoveLayout.setHorizontalGroup(
MoveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, MoveLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
);
MoveLayout.setVerticalGroup(
MoveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, MoveLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
);
Painel.add(Move);
Move.setBounds(570, 0, 50, 30);
jButton9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/javaapplication3/spawn.png"))); // NOI18N
jButton9.setBorderPainted(false);
jButton9.setContentAreaFilled(false);
jButton9.setFocusPainted(false);
jButton9.setFocusable(false);
jButton9.setMaximumSize(new java.awt.Dimension(75, 25));
jButton9.setMinimumSize(new java.awt.Dimension(75, 25));
Painel.add(jButton9);
jButton9.setBounds(550, 30, 73, 23);
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/javaapplication3/fechar.png"))); // NOI18N
jButton1.setBorderPainted(false);
jButton1.setContentAreaFilled(false);
jButton1.setFocusPainted(false);
jButton1.setFocusable(false);
jButton1.setMaximumSize(new java.awt.Dimension(75, 25));
jButton1.setMinimumSize(new java.awt.Dimension(75, 25));
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
Painel.add(jButton1);
jButton1.setBounds(630, 0, 50, 30);
jTextField1.setText("jTextField1");
Painel.add(jTextField1);
jTextField1.setBounds(430, 30, 59, 20);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Painel, javax.swing.GroupLayout.DEFAULT_SIZE, 685, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Painel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}//
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void blueBGolemStartActionPerformed(java.awt.event.ActionEvent evt) {
//timerBlueBGolem.start();
blueBGolem.setText("ooi");
}
private void blueLizardStartActionPerformed(java.awt.event.ActionEvent evt) {
timerBlueLizard.start();
}
private void blueWiStartActionPerformed(java.awt.event.ActionEvent evt) {
timerBlueWi.start();
}
private void blueDGolemStartActionPerformed(java.awt.event.ActionEvent evt) {
timerBlueDGolem.start();
}
private void blueWolfStartActionPerformed(java.awt.event.ActionEvent evt) {
timerBlueWolf.start();
}
private void blueWrStartActionPerformed(java.awt.event.ActionEvent evt) {
timerBlueWr.start();
}
private void DragonStartActionPerformed(java.awt.event.ActionEvent evt) {
//timerDragon.start();
jTextField1.setText("oooi");
}
private void BaronStartActionPerformed(java.awt.event.ActionEvent evt) {
timerBaron.start();
}
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
timerBlueBGolem.stop();
timerBlueLizard.stop();
timerBlueWi.stop();
timerBlueDGolem.stop();
timerBlueWolf.stop();
timerBlueWr.stop();
timerBaron.stop();
timerDragon.stop();
tempoBlueBGolem.set(115);
tempoBlueLizard.set(115);
tempoBlueWi.set(115);
tempoBlueDGolem.set(115);
tempoBlueWolf.set(115);
tempoBlueWr.set(115);
tempoDragon.set(300);
tempoBaron.set(720);
}
private void blueBGolemActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
public static Point getScreenLocation(MouseEvent e, JFrame frame) {
Point cursor = e.getPoint();
Point view_location = frame.getLocationOnScreen();
return new Point((int) (view_location.getX() + cursor.getX()),
(int) (view_location.getY() + cursor.getY()));
}
@Override
public void mouseDragged(MouseEvent e) {
moveOrFullResizeFrame(e);
}
@Override
public void mouseMoved(MouseEvent e) {
Point cursorLocation = e.getPoint();
int xPos = cursorLocation.x;
int yPos = cursorLocation.y;
if (xPos >= cursorArea && xPos <= getWidth() - cursorArea && yPos >= getHeight() - cursorArea) {
setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
} else if (xPos >= getWidth() - cursorArea && yPos >= cursorArea && yPos <= getHeight() - cursorArea) {
setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
} else if (xPos <= cursorArea && yPos >= cursorArea && yPos <= getHeight() - cursorArea) {
setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
} else if (xPos >= cursorArea && xPos <= getWidth() - cursorArea && yPos <= cursorArea) {
setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));
} else if (xPos <= cursorArea && yPos <= cursorArea) {
setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));
} else if (xPos >= getWidth() - cursorArea && yPos <= cursorArea) {
setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));
} else if (xPos >= getWidth() - cursorArea && yPos >= getHeight() - cursorArea) {
setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
} else if (xPos <= cursorArea && yPos >= getHeight() - cursorArea) {
setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));
} else {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
@Override
public void mouseClicked(MouseEvent e) {
Object sourceObject = e.getSource();
if (sourceObject instanceof JPanel) {
if (e.getClickCount() == 2) {
if (getCursor().equals(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR))) {
headerDoubleClickResize();
}
}
}
}
private void moveOrFullResizeFrame(MouseEvent e) {
Object sourceObject = e.getSource();
Point current = getScreenLocation(e, this);
Point offset = new Point((int) current.getX() - (int) start_drag.getX(), (int) current.getY() - (int) start_drag.getY());
if (sourceObject instanceof JPanel
&& getCursor().equals(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR))) {
setLocation((int) (start_loc.getX() + offset.getX()), (int) (start_loc.getY() + offset.getY()));
} else if (!getCursor().equals(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR))) {
int oldLocationX = (int) getLocation().getX();
int oldLocationY = (int) getLocation().getY();
int newLocationX = (int) (this.start_loc.getX() + offset.getX());
int newLocationY = (int) (this.start_loc.getY() + offset.getY());
boolean N_Resize = getCursor().equals(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));
boolean NE_Resize = getCursor().equals(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));
boolean NW_Resize = getCursor().equals(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));
boolean E_Resize = getCursor().equals(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
boolean W_Resize = getCursor().equals(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
boolean S_Resize = getCursor().equals(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
boolean SW_Resize = getCursor().equals(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));
boolean setLocation = false;
int newWidth = e.getX();
int newHeight = e.getY();
if (NE_Resize) {
newHeight = getHeight() - (newLocationY - oldLocationY);
newLocationX = (int) getLocation().getX();
setLocation = true;
} else if (E_Resize) {
newHeight = getHeight();
} else if (S_Resize) {
newWidth = getWidth();
} else if (N_Resize) {
newLocationX = (int) getLocation().getX();
newWidth = getWidth();
newHeight = getHeight() - (newLocationY - oldLocationY);
setLocation = true;
} else if (NW_Resize) {
newWidth = getWidth() - (newLocationX - oldLocationX);
newHeight = getHeight() - (newLocationY - oldLocationY);
setLocation = true;
} else if (NE_Resize) {
newHeight = getHeight() - (newLocationY - oldLocationY);
newLocationX = (int) getLocation().getX();
} else if (SW_Resize) {
newWidth = getWidth() - (newLocationX - oldLocationX);
newLocationY = (int) getLocation().getY();
setLocation = true;
}
if (W_Resize) {
newWidth = getWidth() - (newLocationX - oldLocationX);
newLocationY = (int) getLocation().getY();
newHeight = getHeight();
setLocation = true;
}
if (newWidth >= (int) toolkit.getScreenSize().getWidth() || newWidth <= minWidth) {
newLocationX = oldLocationX;
newWidth = getWidth();
}
if (newHeight >= (int) toolkit.getScreenSize().getHeight() - 30 || newHeight <= minHeight) {
newLocationY = oldLocationY;
newHeight = getHeight();
}
if (newWidth != getWidth() || newHeight != getHeight()) {
this.setSize(newWidth, newHeight);
if (setLocation) {
this.setLocation(newLocationX, newLocationY);
}
}
}
}
private void headerDoubleClickResize() {
if (getWidth() < screen.getWidth() || getHeight() < screen.getHeight()) {
this.setSize((int) screen.getWidth(), (int) screen.getHeight());
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = this.getSize();
this.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
} else {
this.setSize(precedent_width, precedent_height);
this.setLocation(precedent_loc);
}
}
@Override
public void mousePressed(MouseEvent e) {
this.start_drag = getScreenLocation(e, this);
this.start_loc = this.getLocation();
if (getWidth() < screen.getWidth() || getHeight() < screen.getHeight()) {
precedent_loc = this.getLocation();
precedent_width = getWidth();
precedent_height = getHeight();
}
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
public class Contador {
private int i = 0;
public Contador(int i) {
this.i = i;
}
public void count() {
i--;
}
public int get() {
return i;
}
public void set(int i) {
this.i = i;
}
}
public static void count(JTextField Field, Timer cTimer, Contador Tempo, int Type) {
int min, seg;
min = (int) Math.ceil(Tempo.get() / 60);
seg = Tempo.get() - (min * 60);
if (Tempo.get() != 0) {
if (Field.getDisabledTextColor() == Color.GREEN) {
Field.setDisabledTextColor(Color.WHITE);
}
if ((Tempo.get() / 60) > 0) {
if (seg < 10) {
Field.setText(String.valueOf(min) + ":0" + String.valueOf(seg));
} else {
Field.setText(String.valueOf(min) + ":" + String.valueOf(seg));
}
} else {
if (seg < 10) {
Field.setText("0:0" + String.valueOf(seg));
} else {
Field.setText("0:" + String.valueOf(seg));
}
}
Tempo.count();
} else {
switch (Type) {
case 0:
Tempo.set(50);
break;
case 1:
Tempo.set(300);
break;
case 2:
Tempo.set(360);
break;
case 3:
Tempo.set(420);
break;
}
Field.setText("UP");
Field.setDisabledTextColor(Color.GREEN);
cTimer.stop();
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Windows".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
Toolkit toolkit = Toolkit.getDefaultToolkit();
int frameWidth = 685;
int frameHeight = 23;
Point initialLocation = new Point((int) toolkit.getScreenSize().getWidth() / 2 - frameWidth / 2,
(int) toolkit.getScreenSize().getHeight() / 2 - frameHeight / 2);
Dimension initialDimension = new Dimension(frameWidth, frameHeight);
NewJFrame fullResizibleFrame = new NewJFrame(initialDimension, initialLocation);
int frameWidth2 = 685;
int frameHeight2 = 23;
Move.setPreferredSize(new Dimension(frameWidth, 20));
Move.addMouseListener(fullResizibleFrame);
Move.addMouseMotionListener(fullResizibleFrame);
Point initialLocation2 = new Point((int) toolkit.getScreenSize().getWidth() / 2 - frameWidth / 2,
(int) toolkit.getScreenSize().getHeight() / 2 - frameHeight / 2);
Dimension initialDimension2 = new Dimension(frameWidth2, frameHeight2);
NewJFrame fullResizibleFrame2 = new NewJFrame(initialDimension2, initialLocation2);
final JPanel minimap = (JPanel) fullResizibleFrame2.getContentPane();
fullResizibleFrame.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton BaronStart;
private javax.swing.JButton DragonStart;
private static javax.swing.JPanel Move;
private javax.swing.JPanel Painel;
public javax.swing.JTextField blueBGolem;
private javax.swing.JButton blueBGolemStart;
private javax.swing.JButton blueDGolemStart;
private javax.swing.JButton blueLizardStart;
private javax.swing.JButton blueWiStart;
private javax.swing.JButton blueWolfStart;
private javax.swing.JButton blueWrStart;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton9;
private javax.swing.JLabel jLabel1;
private static javax.swing.JTextField jTextField1;
// End of variables declaration
}