📄 j_cardlayout.java.bak
字号:
// ////////////////////////////////////////////////////////
//
// J_CardLayout.java
//
// Created by Jun-Hai Yong, on XX xx, xxxx (Date)
// ////////////////////////////////////////////////////////
// Readme:
// Example of the class CardLayout.
// ////////////////////////////////////////////////////////
// Using this example, please explicitly refer to the book:
// Jun-Hai Yong. Programming in Java.
// Beijing: Tsinghua University Press, 2004.
// 使用本例子,请注明引用:
// 雍俊海. Java 程序设计. 北京: 清华大学出版社, 2004.
// Please note that the author and publisher make no
// warranty of any kind on the examples provided.
// ////////////////////////////////////////////////////////
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class J_CardLayout extends JFrame
{
private Container m_container;
private CardLayout m_card;
public J_CardLayout( )
{
super("CardLayout Example");
m_container = getContentPane( );
m_card= new CardLayout( );
m_container.setLayout( m_card );
for(int i = 0; i < 5; i++)
{
String s= "Button " + (i+1);
JButton b = new JButton( s );
m_container.add(s, b);
b.addActionListener( new ActionListener( )
{
public void actionPerformed( ActionEvent event )
{
m_card.next(m_container);
} // End of method: actionPerformed
} // End of inner class for handling bottons
);
} // End of loop: for
setSize(50, 100);
setVisible(true);
} // End of constructor: J_CardLayout
public static void main( String args[] )
{
J_CardLayout app = new J_CardLayout( );
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} // End of method: main
} // end class J_CardLayout
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -