Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public BufferedImage image[] = new BufferedImage[5];
- int ClassType = 0 ;
- int x =150;
- public MPaneel() {
- class DogeWarrior implements MouseListener
- {
- int Strength;
- int Hp;
- public void ShowPic()
- {
- try {
- image[ClassType] = ImageIO.read(new File("src/Opdracht/DogeWarrior69.png"));
- ClassType++;
- } catch (IOException ex) {
- // handle exception...
- }
- }
- @Override
- public void mouseClicked(MouseEvent e) {
- }
- @Override
- public void mouseEntered(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseExited(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mousePressed(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseReleased(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- }
- class Elephant
- {
- int Strength;
- int Hp;
- public void ShowPic()
- {
- try {
- image[ClassType] = ImageIO.read(new File("src/Opdracht/Elephant.jpg"));
- ClassType++;
- } catch (IOException ex) {
- }
- }
- }
- class PooTart
- {
- int Strength;
- int Hp;
- public void ShowPic()
- {
- try {
- image[ClassType] = ImageIO.read(new File("src/Opdracht/PooTart.jpg"));
- ClassType++;
- } catch (IOException ex) {
- }
- }
- }
- DogeWarrior a = new DogeWarrior();
- a.ShowPic();
- Elephant b = new Elephant();
- b.ShowPic();
- PooTart c = new PooTart();
- c.ShowPic();
- }
- public void paintComponent(Graphics g) {
- super.paintComponent(g);
- for (int i = 0; i < image.length; i++) {
- if(image[i] != null) {
- image[i].getScaledInstance(100, 100, java.awt.Image.SCALE_SMOOTH);
- x=x+50;
- g.drawImage(image[i], x, 0,50,50, null);
- // JOptionPane.showMessageDialog(null, x);
- // do some work here on intValue
- }
- }
- }
- @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
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement