Je viens de mettre une image de taille fixe pour le fond du bouton avec la ligne suivante :
<imagePainter method="buttonBackground" path="images/button_02.png" sourceInsets="0 0 0 0" />
Et le texte tronqué :

Mais rien n'y fait, le texte est toujours tronqué et je ne vois pas d'ou proviens le problème. Voici le code qui me permet d'afficher mes différents composants :
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
| gridBagLayoutDial = new GridBagLayout();
gridBagConstraintsDial = new GridBagConstraints();
// Dial Panel
jPanelDial = new JPanel();
jPanelDial.setName("jPanelDial");
jPanelDial.setLayout(gridBagLayoutDial); // Définir le calque du panel
jTextFieldDial = new JTextField(); jTextFieldDial.setName("jTextFieldDial");
jButtonMessage = new JButton("Message"); jButtonMessage.setName("jButtonMessage");
jButtonHoldOn = new JButton("En Attente");
jButtonHoldOn.setName("jButtonHoldOn");
jButtonTransfer = new JButton("Transférer"); jButtonTransfer.setName("jButtonTransfer");
jButtonMessage.setHorizontalAlignment(SwingConstants.LEFT);
jButtonHoldOn.setHorizontalAlignment(SwingConstants.LEFT);
jButtonTransfer.setHorizontalAlignment(SwingConstants.LEFT);
gridBagConstraintsDial.fill = GridBagConstraints.BOTH;
gridBagConstraintsDial.gridheight = 3;
gridBagConstraintsDial.gridwidth = 1;
gridBagConstraintsDial.gridx = 0;
gridBagConstraintsDial.gridy = 0;
gridBagConstraintsDial.weightx = 1;
gridBagLayoutDial.setConstraints(jTextFieldDial, gridBagConstraintsDial);
jPanelDial.add(jTextFieldDial);
gridBagConstraintsDial.fill = GridBagConstraints.HORIZONTAL;
gridBagConstraintsDial.gridheight = 1;
gridBagConstraintsDial.gridx = 1;
gridBagConstraintsDial.weightx = 0;
gridBagConstraintsDial.anchor = gridBagConstraintsDial.EAST;
gridBagLayoutDial.setConstraints(jButtonMessage, gridBagConstraintsDial);
jPanelDial.add(jButtonMessage);
gridBagConstraintsDial.gridy = 1;
gridBagLayoutDial.setConstraints(jButtonHoldOn, gridBagConstraintsDial);
jPanelDial.add(jButtonHoldOn);
gridBagConstraintsDial.gridy = 2;
gridBagLayoutDial.setConstraints(jButtonTransfer, gridBagConstraintsDial);
jPanelDial.add(jButtonTransfer); |
Et voici le code du fichier XML :
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
|
<!-- Style par défaut pour tout les boutons -->
<style id="defaultButton">
<object id="background" class="com.cmm.synth.BackgroundPainter" />
<object class="javax.swing.plaf.ColorUIResource" id="startColor">
<int>255</int>
<int>255</int>
<int>255</int>
</object>
<defaultsProperty key="Button.startBackground" type="idref" value="startColor" />
<object class="javax.swing.plaf.ColorUIResource" id="endColor">
<int>234</int>
<int>235</int>
<int>237</int>
</object>
<defaultsProperty key="Button.endBackground" type="idref" value="endColor" />
<object id="border" class="com.cmm.synth.SimpleBorderPainter" />
<object class="javax.swing.plaf.ColorUIResource" id="buttonBorderColor">
<int>167</int>
<int>166</int>
<int>170</int>
</object>
<defaultsProperty key="Button.borderColor" type="idref" value="buttonBorderColor" />
<state>
<painter method="buttonBackground" idref="background" />
<painter method="buttonBorder" idref="border" />
<font name="Verdana" size="12" style="BOLD" />
</state>
<state value="MOUSE_OVER">
<opaque value="true" />
<color value="#C2CFE5" type="BACKGROUND" />
<painter method="buttonBorder" idref="border" />
</state>
<state value="PRESSED">
<opaque value="true" />
<color value="#99AFD4" type="BACKGROUND" />
<painter method="buttonBorder" idref="border" />
</state>
</style>
<bind style="defaultButton" type="region" key="Button" />
<!-- Style jButtonMessage -->
<style id="jButtonMessage">
<imageIcon id="iconMessage" path="images/letter.png" />
<property key="Button.icon" value="iconMessage" />
<insets top="2" left="4" bottom="2" right="4" />
</style>
<bind style="jButtonMessage" type="name" key="jButtonMessage" />
<!-- Style jButtonHoldOn -->
<style id="jButtonHoldOn">
<imageIcon id="iconHoldOn" path="images/holdon.png" />
<property key="Button.icon" value="iconHoldOn" />
<insets top="2" left="4" bottom="2" right="4" />
</style>
<bind style="jButtonHoldOn" type="name" key="jButtonHoldOn" />
<!-- Style jButtonTransfer -->
<style id="jButtonTransfer">
<imageIcon id="iconTransfer" path="images/transfer.png" />
<property key="Button.icon" value="iconTransfer" />
<insets top="2" left="4" bottom="2" right="4" />
</style>
<bind style="jButtonTransfer" type="name" key="jButtonTransfer" /> |
Si vous avez une petite idée, de mon problème alors merci !
Partager