日期:2014-05-20 浏览次数:20690 次
package c_port_packageBJTeacher;
import java.awt.BorderLayout;
/**
* Java中CardLayout布局管理器使用的小例子
*/
public class MyChatLogFrame1 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 MyChatLogFrame1(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);
if(i!=0){
CalcMyPage.ld0.remove(i);
}
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);
}
} 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("CJCO");
jta0.setLineWrap(true);
jta0.setSize(303, 700);
jta0.setBackground(Color.RED);
ld.add(jta0);