Reinilton Posted April 11, 2015 at 07:30 PM Report Share #581063 Posted April 11, 2015 at 07:30 PM (edited) Como redimensionar uma imagem dentro de uma jlabel? Edited April 12, 2015 at 12:01 AM by Reinilton Link to comment Share on other sites More sharing options...
alexandre1985 Posted April 11, 2015 at 09:08 PM Report Share #581068 Posted April 11, 2015 at 09:08 PM O que é que queres dizer com redireccionar? http://alexandre1985.github.io Link to comment Share on other sites More sharing options...
Reinilton Posted April 12, 2015 at 12:03 AM Author Report Share #581076 Posted April 12, 2015 at 12:03 AM Desculpe quis dizer redimensionar Link to comment Share on other sites More sharing options...
apocsantos Posted April 12, 2015 at 11:02 AM Report Share #581082 Posted April 12, 2015 at 11:02 AM Bom dia, private Image getScaledImage(Image srcImg, int w, int h){ BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = resizedImg.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2.drawImage(srcImg, 0, 0, w, h, null); g2.dispose(); return resizedImg; } Creio que isto resolve o problema. Cordiais cumprimentos, Apocsantos "A paciência é uma das coisas que se aprendeu na era do 48k" O respeito é como a escrita de código, uma vez perdido, dificilmente se retoma o habito" Link to comment Share on other sites More sharing options...
Reinilton Posted April 15, 2015 at 01:48 AM Author Report Share #581264 Posted April 15, 2015 at 01:48 AM (edited) Fiz isso aqui mas não consegui colocar o trecho que você colocou import java.awt.Color; import java.awt.Dimension; import java.awt.Image; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.border.LineBorder; public class AlbumDeFotos extends JFrame{ JLabel jlabel; JButton botao; ImageIcon imageIcon; Image imagem; Dimension dimensao; public AlbumDeFotos() { super("Minha Janela"); setSize(800,600); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); setLayout(null); setVisible(true); } public void distribui(){ jlabel = new JLabel(); jlabel.setBounds(10, 10, 100, 100); jlabel.setBackground(Color.red); jlabel.setBorder(LineBorder.createBlackLineBorder()); jlabel.setVisible(true); add(jlabel); imageIcon = new ImageIcon(getClass().getResource("imagens//imagem1.jpg")); jlabel.setIcon(imageIcon); } public static void main(String[] args) { new AlbumDeFotos().distribui(); } } Edited April 16, 2015 at 09:15 PM by Reinilton Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now