Sara
Sara

Reputation: 1

JLabel Background Image using palette in netbeans

I have added background image to my frame using Label from palette box. By using Icon in properties tool box, but the image is not getting fit to frame while maximizing in extended state. How to make background image that fits to screen using label properties tool box?

and my code for this is...

    bgLabel = new javax.swing.JLabel(); 
bgLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mission/Bluebg1.jpg")));
 jPanel1.add(bgLabel); bgLabel.setBounds(-10, 0, 880, 470); 

Upvotes: 0

Views: 499

Answers (1)

CoderNeji
CoderNeji

Reputation: 2074

Actually the Label you have set using the Netbeans Drag and Drop facility has set its bounds... and on resizing the Label doesn't gets resized because it has its bounds fixed already...

As a result the icon on the label remains as it is...

If you want to make that resizeable then go to properties box and check both the check-boxes having

  1. Horizontal resizable.
  2. Vertical resizable.

That will do what you want.

Upvotes: 1

Related Questions