Skip to main content

Posts

Showing posts with the label image

How to set a background image to a jFrame?

in Eclipse in NetBeans IDE If you are using Netbeans IDE or windowbuilder in Eclipse to develop Swing GUIs, you might wanted to set background images to jFrames. The easiest way is putting a jLabel to cover whole jFrame and set an image to it. It might be ok Absolute layout but if you are using  something like SpringLayout this will not work. And also there might be problems with re-sizing the jFrame. Instead of that what we are going to do is put a jPanel to cover up the whole jFrame and set a background image to it. in Eclipse WindowBuilder I have already installed WindowBuilder plugin in my Eclipse and created a java project. And I have created a new jFrame form with WindowBuilder. (If you are not familiar with eclipse and windowbuilder please google it and read first) Here is the code for MyFrame class which is automatically created by windowbuilder 1: package org.jframebg; 2: import java.awt.BorderLayout; 3: import java.awt.EventQ...