import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;
import com.mysql.jdbc.PreparedStatement;
public class Panel extends JPanel implements ActionListener{
private JLabel picture;
private JList list;
private JSplitPane splitPane;
int ndex, nexEvo;
String name, pDesc, species, nd, ne, c, g, h, w;
float cr, gr,ht, wt;
String[] type, abi, weak;
String link;
private static final int IMG_WIDTH = 400;
private static final int IMG_HEIGHT = 400;
BufferedImage im, im2;
int n=100;
public Image blink, billtalk, side;
Timer time;
boolean backspace;
Button adminbbtn = new Button(100, 550, 45, 200, 100, 55);
Normbtn normbtn = new Normbtn(100, 550, 250, 400, 100, 250);
AddBtn addbtn= new AddBtn(175, 400, 250, 350, 175, 250);
EditBtn editbtn = new EditBtn(175, 400, 400, 500, 175, 400);
DelBtn delbtn = new DelBtn(175, 400, 550, 650, 175, 550);
Graphics2D g2D; Image next;
int m=1;
BufferedImage img, admin, norm, bill, addz, del, edit, imgnext, pokedex, ndexBI;
public Panel(){
setFocusable(true);
ndex=0;
PreparedStatement s;
try { //change the path
img = ImageIO.read(new File("C:\\Users\\theworldiwant\\workspace\\INTRODB\\src\\pokemoncenter.jpg"));
admin = ImageIO.read(new File("C:\\Users\\theworldiwant\\workspace\\INTRODB\\src\\admin.gif"));
norm = ImageIO.read(new File("C:\\Users\\theworldiwant\\workspace\\INTRODB\\src\\Normal_click.jpg"));
bill = ImageIO.read(new File("C:\\Users\\theworldiwant\\workspace\\INTRODB\\src\\Bill'shouse.jpg"));
addz = ImageIO.read(new File("C:\\Users\\theworldiwant\\workspace\\INTRODB\\src\\add.jpg"));
edit = ImageIO.read(new File("C:\\Users\\theworldiwant\\workspace\\INTRODB\\src\\edit.jpg"));
del = ImageIO.read(new File("C:\\Users\\theworldiwant\\workspace\\INTRODB\\src\\delete.jpg"));
pokedex = ImageIO.read(new File("C:\\Users\\theworldiwant\\workspace\\INTRODB\\src\\POKEDEX.jpg"));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
ImageIcon d = new ImageIcon("talk.gif");
blink = d.getImage();
ImageIcon g = new ImageIcon("bill_talk.gif");
billtalk = g.getImage();
ImageIcon h= new ImageIcon("side.jpg");
side = h.getImage();
ImageIcon a= new ImageIcon(ndex+".jpg");
next = a.getImage();
this.setBackground(Color.GRAY);
addKeyListener(new ML());
if(!adminbbtn.adminclicked&&!normbtn.normclicked){
this.add(adminbbtn);
adminbbtn.addMouseListener(new ML());
this.add(normbtn);
normbtn.addMouseListener(new ML());
}
if(adminbbtn.adminclicked||normbtn.normclicked){
adminbbtn.removeMouseListener(null);
adminbbtn.removeKeyListener(null);
this.remove(adminbbtn);
this.remove(normbtn);
if(adminbbtn.adminclicked){
this.add(addbtn);
this.add(editbtn);
this.add(delbtn);
addbtn.addMouseListener(new ML());
editbtn.addMouseListener(new ML());
delbtn.addMouseListener(new ML());
}
if(normbtn.normclicked){
this.remove(addbtn);
this.remove(editbtn);
this.remove(delbtn);
}
}
}
public void actionPerformed (ActionEvent e){
repaint();
}
private static BufferedImage resizeImage(BufferedImage originalImage, int type){
BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type);
Graphics2D g = resizedImage.createGraphics();
g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null);
g.dispose();
return resizedImage;
}
public void paint (Graphics g){
super.paint(g);
Graphics2D g2D = (Graphics2D) g;
this.g2D=g2D;
time = new Timer(300, this);
time.start();
if(!adminbbtn.adminclicked&&!normbtn.normclicked){
g2D.drawImage(img, 0, 0, null);
g2D.drawImage(adminbbtn.admin2, 100, 55, null);
g2D.drawImage(norm, 100, 250, null);
g2D.drawImage(blink, 500, 100, null);
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
Font font = new Font("Serif", Font.BOLD, 50);
g2D.setColor(Color.pink);
g2D.setFont(font);
g2D.drawString("Hello, and welcome to the ", 35, 475);
g2D.drawString("POKEMON CENTER .^.^. ", 35, 550);
g2D.drawString("Please Choose a Mode. ", 35, 625);
g2D.setColor(Color.WHITE);
}
if(adminbbtn.adminclicked){
g2D.drawImage(bill, 0, 0, null);
g2D.drawImage(billtalk, 500, 110, null);
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
Font font = new Font("Serif", Font.BOLD, 50);
g2D.setColor(Color.WHITE);
g2D.setFont(font);
g2D.drawString("Hi! Welcome to Admin Mode! .^.^. ", 40, 100);
g2D.drawString("What would you like to do? : ", 40, 170);
g2D.drawImage(addz, 175, 250, null);
g2D.drawImage(edit, 175, 400, null);
g2D.drawImage(del, 175, 550, null);
}
if(normbtn.normclicked){
g2D.drawImage(pokedex, 0, 0, null);
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
Font font = new Font("Serif", Font.BOLD, 30);
Font font1 = new Font("Serif", Font.BOLD, 25);
g2D.setColor(Color.WHITE);
g2D.setFont(font);
g2D.drawString("Ndex no. : ", 75, 525);
g2D.drawString(ndex + "", 225, 525);
g2D.drawString("Name :", 350, 525);
g2D.setFont(font1);
g2D.drawString(name, 450, 525);
g2D.setFont(font);
g2D.drawString("Description :", 75, 575);
g2D.setFont(font1);
g2D.drawString(pDesc.substring(0, 30) + "", 250, 575);
g2D.drawString(pDesc.substring(30, 75 ) + "", 90, 610);
g2D.drawString(pDesc.substring(75) + "", 90, 630);
g2D.drawString("Weakness :", 75, 660);
g2D.setFont(font1);
g2D.drawString(weak[0], 250, 660);
g2D.drawString(weak[1], 400, 660);
g2D.setFont(font1);
g2D.drawString("Height :", 725, 100);
g2D.setFont(font1);
g2D.drawString(ht + " m", 850, 100);
g2D.setFont(font1);
g2D.drawString("Weight :", 725, 150);
g2D.setFont(font1);
g2D.drawString(wt + " lbs", 850, 150);
g2D.setFont(font1);
g2D.drawString("Type :", 725, 180);
g2D.setFont(font1);
g2D.drawString(type[0], 850, 180);
g2D.drawString(type[1], 850, 212);
g2D.setFont(font1);
g2D.drawString("Ability :", 725, 250);
g2D.setFont(font1);
g2D.drawString(abi[0], 825, 250);
g2D.drawString(abi[1], 825, 275);
g2D.setFont(font1);
g2D.drawString("Species :", 725, 300);
g2D.setFont(font1);
g2D.drawString(species, 825, 300);
g2D.setFont(font1);
g2D.drawString("Catch Rate :", 725, 340);
g2D.setFont(font1);
g2D.drawString(cr +"%", 875, 340);
g2D.setFont(font1);
g2D.drawString("Gender Ratio :", 725, 370);
g2D.setFont(font1);
g2D.drawString("Male:", 775, 410);
g2D.drawString(gr+"%", 875, 410);
g2D.drawString("Female :", 775, 440);
g2D.drawString(n-gr + "%", 875, 440);
g2D.setFont(font1);
g2D.drawString("Next Evolution :", 725, 545);
g2D.setFont(font1);
try {
im = ImageIO.read(new File("C:\\Users\\theworldiwant\\workspace\\INTRODB\\src\\"+ ndex + ".png"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
g2D.drawImage(im, 300, 250, null);
g2D.drawString(nexEvo +"", 825, 700);
g2D.drawImage(im2, 825, 750, null);
}
}
public class ML implements MouseListener, KeyListener{
public void mouseClicked(MouseEvent e) {
if(!normbtn.normclicked)
adminbbtn.mouseClicked(e);
if(!adminbbtn.adminclicked)
normbtn.mouseClicked(e);
if(!normbtn.normclicked){
addbtn.mouseClicked(e);
editbtn.mouseClicked(e);
delbtn.mouseClicked(e);
}
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
if(!normbtn.normclicked)
adminbbtn.keyPressed(e);
if(!adminbbtn.adminclicked)
normbtn.keyPressed(e);
if(e.VK_BACK_SPACE==key){
backspace=true;
}
if(!normbtn.normclicked){
addbtn.keyPressed(e);
delbtn.keyPressed(e);
editbtn.keyPressed(e);
}
if(e.VK_ESCAPE==key){
System.exit(0);
}
}
@Override
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub
int key = e.getKeyCode();
if(!normbtn.normclicked)
adminbbtn.keyPressed(e);
if(!adminbbtn.adminclicked)
normbtn.keyPressed(e);
if(e.VK_BACK_SPACE==key){
backspace=true;
}
if(e.VK_ESCAPE==key){
System.exit(0);
}
if(!normbtn.normclicked){
addbtn.keyPressed(e);
delbtn.keyPressed(e);
editbtn.keyPressed(e);
}
}
}
}