Sunday 16 June 2019

java - How to add an image to a JFrame container?

i have this code where the container displays a specific background color.
Instead of displaying the color i want to add an image to the background,how should i do it?



public class mark {


public static void main(String[] args) {
// TODO Auto-generated method stub

wmmain m=new mark().new wmmain();
m.setSize(800,500);
m.setVisible(true);

}
class wmmain extends JFrame /* MAIN WINDOW */

{
Container container;

public wmmain()
{
super("Digital Image WaterMarking");

addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)

{
System.out.print("Exit");
System.exit(0);
}
});



container=this.getContentPane();
container.setLayout(new BorderLayout());

container.setBackground(new Color(72, 118, 255));

}
}
}

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...