Java——CardLayout卡片式格局
来源:互联网 发布:自助认证发票软件 编辑:程序博客网 时间:2024/05/16 13:06
/*
* Copyright (c) 2014, 烟台大学计算机学院
* All rights reserved.
* 文件名称:test.cpp
* 作 者:李晓凯
* 完成日期:2015年 11 月 24 日
* 版 本 号:v1.0
*
* 问题描述:利用Java编写了一个卡片式的布局程序
* 输入描述:
* 程序输出:
*/
翻转到容器的第一张卡片public void last(Container parent)翻转到容器的最后一张卡片public void next(Container parent)翻转到指定容器的下一张卡片public void previous(Container parent)翻转到指定容器的前一张卡片public void show(Container parent)翻转到使用addLayoutConmponent 添加到
此布局的具有指定的name的组件代码:
package Frame;import java.awt.BorderLayout;import java.awt.CardLayout;import java.awt.Color;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;public class CardLayoutDemo extends JFrame {private JPanel pane = null;private JPanel p = null;private CardLayout card = null;private JButton button_1 = null;private JButton button_2 = null;private JButton b_1 = null, b_2 = null, b_3 = null;private JPanel p_1 = null, p_2 = null, p_3 = null;public CardLayoutDemo() {card = new CardLayout(5, 5);pane = new JPanel(card);p = new JPanel();button_1 = new JButton("< 上一步");button_2 = new JButton("下一步 >");b_1 = new JButton("1");b_2 = new JButton("2");b_3 = new JButton("3");b_1.setMargin(new Insets(2, 2, 2, 2));b_2.setMargin(new Insets(2, 2, 2, 2));b_3.setMargin(new Insets(2, 2, 2, 2));p.add(button_1);p.add(b_1);p.add(b_2);p.add(b_3);p.add(button_2);p_1 = new JPanel();p_2 = new JPanel();p_3 = new JPanel();p_1.setBackground(Color.red);p_2.setBackground(Color.blue);p_3.setBackground(Color.green);p_1.add(new JLabel("JPanel_1"));p_2.add(new JLabel("JPanel_2"));p_3.add(new JLabel("JPanel_3"));pane.add(p_1, "p1");pane.add(p_2, "p2");pane.add(p_3, "p3");button_1.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {card.previous(pane);}});button_2.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {card.next(pane);}});b_1.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubcard.show(pane, "p1");}});b_2.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubcard.show(pane, "p2");}});b_3.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubcard.show(pane, "p3");}});getContentPane().add(pane);getContentPane().add(p, BorderLayout.SOUTH);setSize(300, 200);setVisible(true);}public static void main(String[] args) {new CardLayoutDemo();}}
0 0
- Java——CardLayout卡片式格局
- 三十二、Java图形化界面设计——布局管理器之CardLayout(卡片布局)
- Java图形化界面设计——布局管理器之CardLayout(卡片布局)
- 三十二、Java图形化界面设计——布局管理器之CardLayout(卡片布局)
- Java图形化界面设计——布局管理器之CardLayout(卡片布局)
- 六、Java图形化界面设计——布局管理器之CardLayout(卡片布局)
- 三十二、Java图形化界面设计——布局管理器之CardLayout(卡片布局)
- [转]Java图形化界面设计——布局管理器之CardLayout(卡片布局)
- Java学习笔记之卡片式布局CardLayout
- 十九、java-GUI之卡片布局(CardLayout)
- 卡片布局(CardLayout)
- CardLayout(卡片布局)
- Java中CardLayout卡片布局管理器使用的小例子
- Java中CardLayout卡片布局管理器使用的小例子
- Ext Js 3.2 卡片式布局--CardLayout应用
- CardLayout(卡片布局管理器)
- Java图形用户界面2—布局管理器补充CardLayout
- Java布局管理器(三)之GridLayout(网格布局管理)和CardLayout( 卡片布局管理)
- 图像细化
- mabatis配合oracle自增长
- iOS报错日志- collectionview
- mfc dll
- jQuery实现数据分页显示Demo
- Java——CardLayout卡片式格局
- 图形变换之使用矩阵变换
- 关于在ViewPage 中显示ImageView的坑
- Android--ListView--万能适配器
- Linux crontab 命令格式与详细例子
- springmvc配置文件,扫描组件分开扫描和直接全扫描的区别
- android电池管理系统
- iOS中protobuf和tcp长链接(AsyncSocket)scoket配合使用
- iOS---修改Xcode7建立的工程名称