0

I have been making a program where I have created a JFrame with a BorderLayout distribution. On the center I have a class extended from a JPanel called AreaDibujo where I use a BufferedImage. In order to use this buffered image properly, I need to pass two int parameters on its constructor, the height and width it will cover.

How can I make it cover all the panel? AKA how do I determinate my panel size (the program runs on fullscreen)?

Here is an image of how does the program look so far:

https://i.stack.imgur.com/GGCLa.png

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Legoruu
  • 1
  • 1
  • *How can I make it cover all the JPanel?* - an easy way is to use a JLabel with the [Stretch Icon](https://tips4java.wordpress.com/2012/03/31/stretch-icon/). The image will automatically be resized to fill the space available. – camickr May 30 '21 at 17:51

1 Answers1

0

How can I determine the height and width of a JPanel? .. I have a class extended from a JPanel called AreaDibujo

Since it seems the code is using custom painting, the height and width of the panel can be determined when the paintComponent(Graphics) method is called, using this.getWidth() and this.getHeight()..

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433