Hi,
I have done my ordering class. which contains all the components.
My problems is how do I set picture as the background and maximize the picture size?
either one of the way
1) i have a class that contains the picture program. How to connect the two program?
the pic as the background for the ordering class.
/**
* @(#)orderingPic.java
*
*
* @author
* @version 1.00 2010/10/4
*/
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class orderingPic {
public static void main(String[] args) {
ImagePanel panel = new ImagePanel(new ImageIcon("all.jpg").getImage());
JFrame frame = new JFrame("Fruit Splash Online system ~");
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
}
class ImagePanel extends JPanel {
private Image img;
public ImagePanel(String img) {
this(new ImageIcon(img).getImage());
}
public ImagePanel(Image img) { this.img = img;
Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
setPreferredSize(size);
setMinimumSize(size);
setMaximumSize(size);
setSize(size);
setLayout(null);
}
public void paintComponent(Graphics g) {
g.drawImage(img, 0, 0, null);
}
}
2) add picture to the ordering class.