Hi I have design a basic JFrame which displays three buttons in a frame. The code is given below:
import java.awt.*;
import javax.swing.*;
public class PaymentFrame {
public static void main(String[] args) {
JFrame f = new JFrame("Payment Frame ");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(800, 600);
Container content = f.getContentPane();
content.setBackground(new Color(240,170,50));
content.setLayout(new GridBagLayout());
content.add(new JButton("Enter Ticket No"));
content.add(new JButton("Pay (Cash)"));
content.add(new JButton("Pay (Card)"));
f.setVisible(true);
}
}
I wantto include images in the frame. I now how to do this using applets, but i would like to include and image or gif file in this frame to go together with buttons that are already in the frame. But Im not sure that this will work.
I am tempted to include the or import, the java.awt.Gaphics and the java.awt.Image in this frame to be able to handle and manilpulate an image. I am also thinking of using the
paint(Graphics g) method to do this. But I want to know if this is even possible having images in a frame and not in an applet. And also if there was a simpler way to do this. If anyone has the expetice on doing this could you please point me in the right direction and telling what is the best way to accomplish this?
Many thanks in advance...