this has been bugging me for a while but i just can't seem to figure out what i'm doing wrong. So i'm setting the background of a pannel with image Icon but when i resize the window it leave the BG at the same size and i get this huge white wall around the exposed edge, i'd like to stretch the bg as the window changes
here's my relevant code
protected JPanel createRightPane() {
final ImageIcon BGiconSM = ScaledImageIcon("parchmentTall.jpg", "BG Plate", initalWidth/2, initalHeight);
final ImageIcon iconSM = ScaledImageIcon("titlebar.png", "Title Bar BG", (initalWidth/3), 40);
//TODO Parchment image resize
final JPanel content = new JPanel(new GridBagLayout());
content.setOpaque(false);
final JPanel panel = new JPanel(new BorderLayout()) {
protected void paintComponent(Graphics g)
{
// Dispaly image at full size
Image BGicon = BGiconSM.getImage();
g.drawImage(BGicon, 0, 0, null);
super.paintComponent(g);
}
};
panel.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e){
Rectangle r = frame.getBounds();
int h = r.height;
int w = r.width;
if (h >= initalHeight){h = initalHeight-30;}
//System.out.println(h);
//System.out.println(w);
/* protected paintComponent(Graphics g)
{
// Dispaly image at full size
Image BGicon = BGiconSM.getImage();
g.drawImage(BGicon, 0, 0, null);
super.paintComponent(g);
}
*/
}
});