Sistema de blogs Diarium
Universidad de Salamanca
Pablo Gallardo's Blog
My professional web log about IT, Cybersecurity & Project Management
Archive | Java RSS feed for this section

How to display an image on Java Swing

Images can be displayed in Java Swing using object JLabel. This is the partial code: JLabel label = new JLabel(); try { BufferedImage img = File(IMG_FILES_PATH + IMG_FILENAME)); ImageIcon icon = new ImageIcon(img); label.setIcon(icon); } catch (IOException ex) { Logger.getLogger(SwingGUIMainScreen.class.getName()).log(Level.SEVERE, null, ex); } If I need the image to have an specific size, what […]

Comments { 0 }

How to scale an image in Java

I programmed my own function, based on other examples: /** * Method that scale an image (BufferedImage) into the specified dimensions * @param sbi Source image * @param imageType Image type among BufferedImage.TYPE_… constants (example: TYPE_INT_ARGB) * @param dWidth Image width, in pixels * @param dHeight Image height, in pixels * @return Destination image */ […]

Comments { 0 }
Política de privacidad
Studii Salmantini. Campus de excelencia internacional