- #1
Quantum_Prodegy
[SOLVED] Importing Images to a Java frame
Hey guys,
I have a very simple java program. I opens a frame, and I want to be able to put a picture in the frame. How do I import a picture and set it as the background to the frame?
Here is my simple program:
import java.io.*;
import java.awt.*;
import java.awt.event.*;
class demo extends Frame
{
void setup()
{
setLayout(new FlowLayout());
Button ok = new Button(" OK ");
add(ok);
}
}
public class window
{
public static void main (String[] args)
{
int width = 700, height = 134;
demo frm = new demo();
frm.setup();
frm.setBackground(Color.gray);
frm.setTitle("Logon Message");
frm.setSize(width, height);
frm.setVisible(true);
}
}
so as you can see it is an extremely basic window, and I would like to import a graphic as the background to the window within the setup() method.
Any help much appreciated, thanks!
-Jon
Hey guys,
I have a very simple java program. I opens a frame, and I want to be able to put a picture in the frame. How do I import a picture and set it as the background to the frame?
Here is my simple program:
import java.io.*;
import java.awt.*;
import java.awt.event.*;
class demo extends Frame
{
void setup()
{
setLayout(new FlowLayout());
Button ok = new Button(" OK ");
add(ok);
}
}
public class window
{
public static void main (String[] args)
{
int width = 700, height = 134;
demo frm = new demo();
frm.setup();
frm.setBackground(Color.gray);
frm.setTitle("Logon Message");
frm.setSize(width, height);
frm.setVisible(true);
}
}
so as you can see it is an extremely basic window, and I would like to import a graphic as the background to the window within the setup() method.
Any help much appreciated, thanks!
-Jon