Netbean Java Swing, JPanel / Jlabel Cant covers the entire frame

I want mine to JLabelcover the whole frame, but when I do this, it will not close the text box and the ok button. how to make mine JLabelto cover the whole frame.

enter image description here

P / s I want to do this JLabelas a background, so I can put the icon in JLabelas a background image.

0
source share
2 answers

Here is what I will do. Use JPanelfor background and enter some custom code.

  • Drag JPaneland drop into the shape to cover the entire frame to be the background.

  • JPanel . . .

    enter image description here

  • jPanel1 = new JPanel() {
        BufferedImage img;
        {
            try {
                img = ImageIO.read(getClass().getResource("/resources/stackoverflow5.png"));
            } catch (IOException ex) {  ex.printStackTrace(); }
        }
    
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(img, 0, 0, getWidth(), getHeight(), this);
    
        }
    };
    
  • , , . Ctrl + Shift + I

  • .

enter image description here

enter image description here

+4

, , . , Jpanel Jlabel Jframe, :

1) Jframe. 2) 3) " " 4) Jlabel, , . , .

enter image description here

p/s: , - , . .

0

Source: https://habr.com/ru/post/1535033/


All Articles