银行管理系统_Note-02

UI层的设计(卡片布局)

  1为主面板添加背景图片:

    JPanel mainPanel = new JPanel(){...};类似匿名类,然后大括号里面重写JComponent的paintComponent(Graphics g)方法,调用                       g.drawImage方法画背景图片

  2添加登录界面LoginPanel和注册界面RegesterPanel:

    这里使用一个管理面板的容器工具类ContainerUtils,将面板名字对应的Panel放在map里面:

public class ContainerUtils {
    private static Map<String , Object> map = new HashMap<>();
    
    public static void regester(String key , Object value) {
        map.put(key, value);
    }
    
    public static Object getContainer(String key) {
        return map.get(key);
    }
}

    再在主面板中通过这个面板工具类来管理,通过鼠标点击事件来切换界面:

JButton registerBtn = new JButton("注册");
        registerBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //获取主面板
                JPanel mainPanel = (JPanel) ContainerUtils.getContainer("mainPanel");
                //获取主面板的布局
                CardLayout card = (CardLayout) mainPanel.getLayout();
                
                card.show(mainPanel, "regesterPanel");
            }
        });

 

转载于:https://www.cnblogs.com/Jerry-java/p/5441938.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
#include <stdio.h>#include <string.h>#include <stdlib.h>#define MAX_SMS_LENGTH 200#define MAX_NAME_LENGTH 8#define MAX_PHONE_LENGTH 11typedef struct { char word[MAX_SMS_LENGTH]; /*短信内容*/ int length; /*短信长度*/} Message;typedef struct { char name[MAX_NAME_LENGTH]; /*姓名*/ char phone[MAX_PHONE_LENGTH]; /*电话号码或手机号码*/} Note;void extract_phone_number(Message* message, Note* note) { int start = 0; int phone_start = -1; int phone_end = -1; while (start < message->length) { if (message->word[start] >= '0' && message->word[start] <= '9') { phone_start = start; phone_end = start; start++; while (start < message->length && message->word[start] >= '0' && message->word[start] <= '9') { phone_end = start; start++; } if (phone_end - phone_start == 6 || phone_end - phone_start == 7) { strncpy(note->phone, message->word + phone_start, phone_end - phone_start + 1); note->phone[phone_end - phone_start + 1] = '\0'; } else if (phone_end - phone_start == 10 || phone_end - phone_start == 11) { strncpy(note->phone, message->word + phone_start, phone_end - phone_start + 1); note->phone[phone_end - phone_start + 1] = '\0'; } if (strlen(note->phone) > 0) { break; } } else { start++; } }}void save_to_contact(Note* note) { // 将 note 存储到通讯录中}int main() { Message message; Note note; // 读取短信 fgets(message.word, MAX_SMS_LENGTH, stdin); message.length = strlen(message.word) - 1; message.word[message.length] = '\0'; memset(note.name, 0, MAX_NAME_LENGTH); memset(note.phone, 0, MAX_PHONE_LENGTH); extract_phone_number(&message, &note); save_to_contact(&note); return 0;}
06-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值