hey guys, title kinda says it all. i've tried changing the path 10000 times. idk if its wrong in the code. help please! thanks,
Java Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class calculator extends JPanel{
String addPath = "/Users/swedishfished/Desktop/eclipse/calcuLater\\!/src/add.png";
String subtractPath = "/Users/swedishfished/Desktop/eclipse/calcuLater\\!/src/subtract.png";
String multiplyPath = "/Users/swedishfished/Desktop/eclipse/calcuLater\\!/src/multiply.png";
String dividePath = "/Users/swedishfished/Desktop/eclipse/calcuLater\\!/src/divide.png";
private JFrame frame;
calculator() throws IOException{
frame = new JFrame("wassup");
frame.setSize(500,500);
frame.add(this);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
File add = new File(addPath);
File subtract = new File(subtractPath);
File multiply = new File(multiplyPath);
File divide = new File(dividePath);
BufferedImage a = ImageIO.read(add);
BufferedImage s = ImageIO.read(subtract);
BufferedImage m = ImageIO.read(multiply);
BufferedImage d = ImageIO.read(divide);
JLabel aLabel = new JLabel(new ImageIcon(a));
JLabel sLabel = new JLabel(new ImageIcon(s));
JLabel mLabel = new JLabel(new ImageIcon(m));
JLabel dLabel = new JLabel(new ImageIcon(d));
frame.add(aLabel);
// aLabel.setLocation(200,200);
frame.add(mLabel);
// mLabel.setLocation(600,200);
frame.add(sLabel);
// sLabel.setLocation(200,600);
frame.add(dLabel);
// dLabel.setLocation(600,600);
}
}
No comments:
Post a Comment