Card Layout
You can think of a Card Layout as a deck of cards. During run time, only one component ("the top card") is visible at a time and each component ("card") is the same size. In design time in the Form Editor, the Card Layout is displayed as a JTabbedPane to make it easier to design the form. This enables you to switch between cards by clicking on their tabs when you are designing the form.
In the property sheet for the
CardLayout
node, you can set theCurrent Card
property tocard1
,card2
, and so on. In code, the methodsshow
,next
,previous
,first
, andlast
can be used to select cards. For example, the following code selects the next card inpanel1
whenbutton1
is clicked:private void button1ActionPerformed(java.awt.event.ActionEvent evt) { // Add your handling code here: CardLayout cards = (CardLayout)panel1.getLayout(); cards.next(panel1); }See the JTabbedPane component if you want to design a visual form that has tabbed panes in run time.
Contents | Prev | Next | Index |