Skip to content

Commit

Permalink
Committing images that weren't in the last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
john committed Apr 19, 2015
1 parent 317bda8 commit 1e7d177
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 0 deletions.
Binary file added MerchantRPGCSE2102/src/images/Merchant-real.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MerchantRPGCSE2102/src/images/RPG_samplemap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MerchantRPGCSE2102/src/images/merchant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MerchantRPGCSE2102/src/images/scrollbutton.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions MerchantRPGCSE2102/src/view/ScrollButton.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JButton;

public class ScrollButton extends JButton{

private static final long serialVersionUID = 1L;
BufferedImage image;
String text;

public ScrollButton(String text) {
this.text = text;
try {
image = ImageIO.read(new File("src/images/scrollbutton.jpg"));
} catch (IOException e) {
e.printStackTrace();
}
}

@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d= (Graphics2D) g;
g.drawImage(image, 0, 0, null);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(Color.BLACK);
g2d.setFont(new Font("Elephant", Font.BOLD, 15));
g2d.drawString(text, 12, 30);
}

@Override
public Dimension getPreferredSize() {
return new Dimension(image.getWidth(), image.getHeight());
}
}
45 changes: 45 additions & 0 deletions MerchantRPGCSE2102/src/view/TransactionPanel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package view;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LayoutManager;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JPanel;

public class TransactionPanel extends JPanel {

private static final long serialVersionUID = 1L;
BufferedImage background = null;


TransactionPanel(LayoutManager lm) {
super(lm);
background = loadImage("Merchant-real.png");
}

@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(background, 0, 0, null);

}

public BufferedImage loadImage(String fileName) {

BufferedImage image = null;

try {
image = ImageIO.read(new File("src/images/" + fileName));
} catch (IOException e) {
e.printStackTrace();
}

return image;
}

}

0 comments on commit 1e7d177

Please sign in to comment.