Bonjour ! j'ai un petit probleme concernant l'affichage de JButton ainsi que d'un label.
Voici mon code :
import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class Fenetre extends JFrame {
JButton b1 = new JButton(new ImageIcon("Images/b1.jpg"));
JButton b2 = new JButton(new ImageIcon("Images/b1.jpg"));
JLabel l1;
static JLabel l2 = new JLabel("") ;
private JPanel panneau = new JPanel();
private JLabel fond = new JLabel(new ImageIcon("Images/m.jpg"));
private static JTextArea jtf = new JTextArea();
public Fenetre()
{
this.setTitle("Projet");
this.setSize(455,700);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setContentPane(panneau);
this.setResizable(false);
this.setVisible(true);
jtf.setEditable(false);
panneau.setLayout(new FlowLayout());
JPanel top = new JPanel();
jtf.setPreferredSize(new Dimension(151, 25));
b1.setPreferredSize(new Dimension(152, 25));
b2.setPreferredSize(new Dimension(151, 25));
top.add(b1);
top.add(jtf);
top.add(b2);
panneau.add(top);
panneau.add(fond);
}
}
Ainsi qu'une image qui illustre le probleme :
J'arrive a les afficher mais il y'a un espace gris entre les composants que j'aimerais enlever. Savez-vous comment pour que les composants soient colles et qu'il n'y ait pas d'espace entre eux? Merci enormemenet !
Merci pour cette reponse, oui donc ca marche avec les boutons ils n'ont plus d'espace entre eux car ils font la meme taille mais il y'a toujours de l'espae entre la grande image et les tableaux, lorseque j'essaie un GridLayout les images sont completement deformes comment y remedier faut il utliser un autre layout?