Java Reference
In-Depth Information
public void
valueChanged(ListSelectionEvent e)
{
displayPicJL.setIcon(
pictures[pictureJList.getSelectedIndex()]);
infoJL.setText(
pictureNames[pictureJList.getSelectedIndex()]);
repaint();
}
}
Sample Run: Figure 12-18 shows a sample run of the
JListPictureViewer
program.
FIGURE 12-18
Sample run of the
JListPictureViewer
program
1
2
In earlier chapters, you saw two layout managers:
GridLayout
and
null
. For
GridLayout
, you specify the number of rows and columns you want, and you can place
your components from left to right, row-by-row, or from top to bottom. If you choose
the
null
layout, you have to specify the size and location of each component. Java
provides many layout managers; this section briefly introduces two more.
Search WWH ::
Custom Search