import java.awt.Color; import java.awt.Dimension; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.SwingConstants; public class Libre extends JPanel { public Libre() { JButton bouton = new JButton("bouton"); JScrollPane ecriture = new JScrollPane(new JTextArea()); JLabel message =new JLabel("Bonjour", SwingConstants.CENTER); setLayout(null); setPreferredSize(new Dimension(200, 200)); bouton.setBounds(30, 10, 150, 30); message.setBackground(Color.YELLOW); message.setOpaque(true); ecriture.setSize(100, 100); ecriture.setLocation(60, 50); message.setBounds(10, 170, 100, 20); add(bouton); add(ecriture); add(message); } } class EssaiLibre { public static void main(String[] arg) { JFrame monCadre = new JFrame(); monCadre.setContentPane(new Libre()); monCadre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); monCadre.pack(); monCadre.setVisible(true); } }