日期:2014-05-20 浏览次数:20692 次
package c_port_packageBJTeacher;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.LinkedList;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.UIManager;
/**
* Java中CardLayout布局管理器使用的小例子
*/
public class MyChatLogFrame extends JFrame implements ActionListener, Runnable {
/**
*
*/
private static final long serialVersionUID = 1L;
public ArrayList<JTextArea> al = new ArrayList<JTextArea>();
private JPanel pane = null; // 主要的JPanel,该JPanel的布局管理将被设置成CardLayout
private JPanel p = null; // 放按钮的JPanel
private CardLayout card = null; // CardLayout布局管理器
private JButton button_1 = null; // 上一步
private JButton button_2 = null; // 下一步
public LinkedList<JTextArea> ld = new LinkedList<JTextArea>();
public MyChatLogFrame(String str,int pagenum) {
super("CardLayout Test");
int myLocalPagenum = pagenum;
card = new CardLayout(5, 5);
pane = new JPanel(card);
// String[] buffer = str.split("丮");
// int pagenum = Integer.parseInt(buffer[0]);
// str = buffer[1];
this.setResizable(false);
if(myLocalPagenum!=0){
for(int i = 0;i<myLocalPagenum;i++){
JPanel jp = new JPanel();
jp.setBackground(Color.RED);
JTextArea jta0 = new JTextArea();
jta0.setSize(332, 722);
jta0.setText("CJCO");
jta0.setLineWrap(true);
jta0.setSize(303, 700);
jta0.setBackground(Color.RED);
ld.add(jta0);
jp.add(jta0);
pane.add(jp,"CJCO");
this.add(pane);
}}else{
myLocalPagenum = 1;
for(int i = 0;i<myLocalPagenum;i++){
JPanel jp = new JPanel();
JTextArea jta0 = new JTextArea();
jta0.setBackground(Color.RED);
jta0.setSize(332, 722);
jta0.setText(CalcMyPage.ld0.get(i));
jta0.setLineWrap(true);
jta0.setSize(303, 700);
jta0.setBackground(Color.RED);
ld.add(jta0);
jp.add(jta0);
pane.add(jp,"CJCO");
this.add(pane);
}
}
try {
// 将LookAndFeel设置成Windows样式