Redimensionner un ImageIcon avec l'interface graphique de netbeans
Bonjour à tous,
Voila je commence à developper une petite appli et j'ai quelques soucis d'ordre graphique
J'utilise pour faire ma jFrame l'interface graphique de netBeans
Sauf qu'il y a une propriete que je trouve pas
Voila je souhaite afficher une image dans un bouton
Pour cela j'ai créer un bouton et j'y ai ajouté une imageIcone
Sauf que mon image est bien trop grosse. Et lorsque je veux redimensionner la taille de mon bouton cela redui l'image mais pas proportionnelement
Donc j'obtiens une image toute déformé
En me promenant sur le forum j'ai vu que des message ou il fallait directement rentrer dans le code que genere netbeans
sauf que je n'y ai pas vraiement accés
Quelqu'un a-t-il une idée ?
Voila le code de ma jframe (genéré par netbeans) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* Lancer.java
*
* Created on 30 mai 2009, 09:02:16
*/
package conversion;
/**
*
* @author DD
*/
public class Lancer extends javax.swing.JFrame {
/** Creates new form Lancer */
public Lancer() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
fermer = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(255, 255, 204));
fermer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/croix.png"))); // NOI18N
fermer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fermerActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(111, Short.MAX_VALUE)
.addComponent(fermer))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(fermer, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(59, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void fermerActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
}
/**
* @param args the command line arguments
*/
// Variables declaration - do not modify
private javax.swing.JButton fermer;
// End of variables declaration
} |