ImageIcon icon = new ImageIcon("images/middle.gif",
"a pretty but meaningless splat");
setLayout(new GridLayout(3,1)); //3 rows, 1 column
label1 = new JLabel("Image and Text",
icon,
JLabel.CENTER);
//Set the position of the text, relative to the icon:
label1.setVerticalTextPosition(JLabel.BOTTOM);
label1.setHorizontalTextPosition(JLabel.CENTER);
label2 = new JLabel("Text-Only Label");
label3 = new JLabel(icon);
//Add labels to the JBufferedPane.
add(label1);
add(label2);
add(label3);