pessoal, eu to inserindo uma imagem redimensionada em um JLabel, a imagem aparece la normalzinha…só meio ruimzinha de ver pq o label é pekeno mais blz…
o problema é que quando eu faço isso aki testando, esta me imprimindo um stacktrace de erro, apontando pra umas classes no javax.swing em umas linhas, no java.awt em outras, mais em nenhuma linha da mensagem de erro aponta para a minha classe…
outra coisa tb é que depois que eu faço isso quando eu minimizo a janela, ao voltar as mensagens aparecem de novo… não sei se é ao exibir a imagem…
esse é o código que insere a imagem, como é o mesmo para varias JLabels na mesma JPanel, eu o separei em um metodo:
[code]private void setImageBackground(javax.swing.JLabel label){
String[] descricao = {"imagem jpg"};
String[] tipo = {"jpg"};
//vai me retorna o endereço do arquivo selecionado
String arquivo = FileChooserFactory.getSelectedFileAdress(descricao, tipo);
if (!(new java.io.File(arquivo).exists())){
//javax.swing.JOptionPane.showMessageDialog(null, "selecione uma imagem valida");
return;
}
BufferedImage fundo = null;
try{
fundo = ImageIO.read(new File(arquivo));
}catch(java.io.IOException ioe){
System.out.println("IO Error");
fundo = new BufferedImage(1,1,BufferedImage.BITMASK );
}
ImageIcon jpg = new ImageIcon( fundo.getScaledInstance(50, 50, 1000) );
label.setIcon(jpg);
}[/code]
bom…o stacktrace que eu falei é esse:
init:
deps-jar:
compile-single:
run-single:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width and height must be >= 0
at javax.swing.plaf.basic.BasicHTML.getHTMLBaseline(BasicHTML.java:69)
at javax.swing.plaf.basic.BasicHTML.getBaseline(BasicHTML.java:87)
at javax.swing.plaf.basic.BasicLabelUI.getBaseline(BasicLabelUI.java:290)
at javax.swing.JComponent.getBaseline(JComponent.java:2530)
at javax.swing.GroupLayout$ComponentSpring.getBaseline(GroupLayout.java:3000)
at javax.swing.GroupLayout$BaselineGroup.calculateBaselineAndResizeBehavior(GroupLayout.java:2657)
at javax.swing.GroupLayout$BaselineGroup.calculateSize(GroupLayout.java:2633)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1593)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1590)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1588)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1588)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$SequentialGroup.setValidSize(GroupLayout.java:1972)
at javax.swing.GroupLayout$Group.setSize(GroupLayout.java:1553)
at javax.swing.GroupLayout.calculateAutopadding(GroupLayout.java:1058)
at javax.swing.GroupLayout.layoutContainer(GroupLayout.java:899)
at java.awt.Container.layout(Container.java:1398)
at java.awt.Container.doLayout(Container.java:1387)
at java.awt.Container.validateTree(Container.java:1485)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validate(Container.java:1457)
at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:670)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:127)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width and height must be >= 0
at javax.swing.plaf.basic.BasicHTML.getHTMLBaseline(BasicHTML.java:69)
at javax.swing.plaf.basic.BasicHTML.getBaseline(BasicHTML.java:87)
at javax.swing.plaf.basic.BasicLabelUI.getBaseline(BasicLabelUI.java:290)
at javax.swing.JComponent.getBaseline(JComponent.java:2530)
at javax.swing.GroupLayout$ComponentSpring.getBaseline(GroupLayout.java:3000)
at javax.swing.GroupLayout$BaselineGroup.calculateBaselineAndResizeBehavior(GroupLayout.java:2657)
at javax.swing.GroupLayout$BaselineGroup.calculateSize(GroupLayout.java:2633)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1593)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1590)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1588)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1588)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$SequentialGroup.setValidSize(GroupLayout.java:1972)
at javax.swing.GroupLayout$Group.setSize(GroupLayout.java:1553)
at javax.swing.GroupLayout.calculateAutopadding(GroupLayout.java:1058)
at javax.swing.GroupLayout.layoutContainer(GroupLayout.java:899)
at java.awt.Container.layout(Container.java:1398)
at java.awt.Container.doLayout(Container.java:1387)
at java.awt.Container.validateTree(Container.java:1485)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validate(Container.java:1457)
at java.awt.Window.dispatchEventImpl(Window.java:2456)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
to usando o netbeans 6.5 e jdk 6 up 10
alguém ai teria alguma dica???