Cambiar el tamaño de la imagen con respecto al tamaño del marco

Hi I am adding an image to my application and I want to resize the image if I change the size of my application window. How can I achieve it. here it is how I am adding it.Thanks WL

        ImageIcon logo = new ImageIcon(getClass().getResource("folder/image.jpg"));

        JLabel label =  new JLabel("", logo, JLabel.CENTER);
        BorderLayout border = new BorderLayout();
        JPanel upperpanel = new JPanel(border);
        upperpanel.add(menuBar, BorderLayout.NORTH);

        add(upperpanel, BorderLayout.NORTH);

preguntado el 02 de febrero de 12 a las 10:02

Seems like you missed to add your label somewhere, isn't it ? -

1 Respuestas

Image tiene el método

public Image getScaledInstance(int width, int height, int hints)

Respondido 02 Feb 12, 14:02

I am not sure, but since the Image is added to the JLabel, so isn't JLabel's size will define the size of the image now. - cOw nIcE

@Gagandeep Bali no, resize for image ended on size of pixels +1 - mKorbel

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.