目录

Java手机通讯录并实现自动发送QQ消息及单人视频聊天窗口

1. 原始问题描述

2. 实现效果​             ​            ​              ​

3.部分源码

每一个联系人的实体类

详细信息页面

4.参考博文

5.完整代码


1. 原始问题描述

模拟设计一个手机通讯录管理系统

(1) 显示功能:按名字的汉字首字母归类显示,并提供右侧字母导航条,当点击其中一个字母时,可 快速跳转到该字母分类的联系人列表。

(2) 新增功能:可以录入新联系人,包括:姓名、电话号码、电子邮件等。录入的新联系人能按照名字首字母自动进行归类。

(3) 修改功能:选中某联系人后可以进行修改。

(4) 删除功能:可以删除联系人,并自动调整显示。

(5) 查询功能:可以按名字、电话号码、电子邮件等进行模糊查询。

2. 实现效果
             

              

                     

                     

3.部分源码

每一个联系人的实体类

import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;import java.util.Arrays;public class TelephoneBook implements Comparable<TelephoneBook> {private int block;private String name;private String[] telephone;private String mark;private String email;private TelephoneBook next;public String getName() {return name;}public TelephoneBook(String name, String[] telephone, String mark, String email) {this.name = name;this.telephone = telephone;this.mark = mark;this.email = email;}public void setName(String name) {this.name = name;}public String[] getTelephone() {return telephone;}public void setTelephone(String[] telephone) {this.telephone = telephone;}public String getMark() {return mark;}public void setMark(String mark) {this.mark = mark;}public String getEmail() {return email;}public void setEmail(String email) {this.email = email;}public int getBlock() {return getBookBlock();}public void setBlock(int block) {this.block = block;}public TelephoneBook getNext() {return next;}public void setNext(TelephoneBook next) {this.next = next;}@Overridepublic String toString() {return "TelephoneBook{" +"name='" + name + '\'' +", telephone=" + Arrays.toString(telephone) +", mark='" + mark + '\'' +", email='" + email + '\'' +'}';}//计算获得联系人所在分块public int getBookBlock() {int block = 0;for (int i = 0; i < 26; i++) {if (TelephoneBook.getFirstSpell(getName().substring(0, 1)).compareTo(String.valueOf((char) ('a' + i))) == 0) {block = i;break;}}return block;}//获取拼音首字母public static String getFirstSpell(String chinese) {StringBuffer pybf = new StringBuffer();char[] arr = chinese.toCharArray();HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();//输出全部小写defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);//不带音调defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);for (int i = 0; i < arr.length; i++) {if (arr[i] > 128) {               //不属于ASCII字符try {String[] temp = PinyinHelper.toHanyuPinyinStringArray(arr[i], defaultFormat);if (temp != null) {pybf.append(temp[0].charAt(0));}} catch (BadHanyuPinyinOutputFormatCombination e) {e.printStackTrace();}} else {pybf.append(arr[i]);}}//去除空白字符return pybf.toString().replaceAll("\\W", "").trim();}@Overridepublic int compareTo(TelephoneBook o) {if (getPingYin(this.getName()).compareTo(getPingYin(o.getName())) > 1) {return 1;} else if (getPingYin(this.getName()).compareTo(getPingYin(o.getName())) < 1) {return -1;} else {return 0;}}public static String getPingYin(String inputString) {HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();format.setCaseType(HanyuPinyinCaseType.LOWERCASE);format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);format.setVCharType(HanyuPinyinVCharType.WITH_V);char[] input = inputString.trim().toCharArray();String output = "";try {for (int i = 0; i < input.length; i++) {if (Character.toString(input[i]).matches("[\\u4E00-\\u9FA5]+")) {String[] temp = PinyinHelper.toHanyuPinyinStringArray(input[i], format);output += temp[0];} elseoutput += Character.toString(input[i]);}} catch (BadHanyuPinyinOutputFormatCombination e) {e.printStackTrace();}return output;}
}

详细信息页面

import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;import java.util.Optional;public class DetailInformation extends BorderPane {public DetailInformation(TelephoneBook telephoneBook, BorderPane borderPane, int index){this.setTop(getBorderTop(telephoneBook.getName(),borderPane));this.setCenter(getBorderBody(telephoneBook));this.setBottom(getBorderBottom(borderPane,telephoneBook,index));}public static VBox getBorderTop(String name, BorderPane borderPane){VBox vBox = new VBox();HBox back = new HBox();HBox hBox = new HBox();hBox.setPrefHeight(150);hBox.setAlignment(Pos.BOTTOM_LEFT);back.setAlignment(Pos.CENTER_LEFT);hBox.setPadding(new Insets(0,0,25,15));back.setPadding(new Insets(25,0,25,15));// 返回Label backTo = new Label("返回");Label label = new Label(name);// 设置字体和背景backTo.setFont(new Font(24));label.setFont(new Font(24));backTo.setTextFill(Color.WHITE);label.setTextFill(Color.WHITE);hBox.setStyle("-fx-background-color: #3D5A80");back.setStyle("-fx-background-color: #3D5A80");hBox.getChildren().add(label);back.getChildren().add(backTo);vBox.getChildren().addAll(back,hBox);// 返回backTo.setOnMouseClicked(event -> {borderPane.getChildren().clear();borderPane.setTop(TelephoneBookListPane.getBorderTop(borderPane));ScrollPane scrollPane = TelephoneBookListPane.getBorderBody(borderPane);borderPane.setCenter(scrollPane);borderPane.setBottom(TelephoneBookListPane.getBorderBottom(borderPane));borderPane.setLeft(TelephoneBookListPane.getSideBar(scrollPane));});return vBox;}//获取主体public static VBox getBorderBody(TelephoneBook telephoneBook){VBox vBox = new VBox();String[] phones = telephoneBook.getTelephone();if(phones.length == 1){vBox.getChildren().add(getRecord("电话",telephoneBook.getTelephone()[0]));}else{for(int i = 0; i < phones.length; i++){vBox.getChildren().add(getRecord("电话" + (i + 1),telephoneBook.getTelephone()[i]));}}vBox.getChildren().addAll(getRecord("邮件",telephoneBook.getEmail()),getRecord("备注",telephoneBook.getMark()));vBox.setPrefHeight(400);return vBox;}//获取单条记录public static HBox getRecord(String label, String mark){HBox hBox = new HBox();Label myLabel = new Label(label + ": ");myLabel.setFont(new Font(20));Text myMark = new Text(mark);myMark.setFont(new Font(20));hBox.getChildren().addAll(myLabel,myMark);hBox.setPadding(new Insets(10,10,10,10));hBox.setSpacing(10);hBox.setStyle("-fx-border-width: 0 0 1 0;-fx-border-color: #e0e0e0");return hBox;}//获取底部操作public static HBox getBorderBottom(BorderPane borderPane,TelephoneBook telephoneBook,int index){HBox hBox = new HBox();Label edit = new Label("编辑联系人");Label delete = new Label("删除联系人");edit.setFont(new Font(18));delete.setFont(new Font(18));hBox.setPadding(new Insets(20,40,20,40));hBox.setSpacing(100);hBox.getChildren().addAll(edit,delete);hBox.setStyle("-fx-background-color: #98C1D9");// 编辑edit.setOnMouseClicked(event -> {borderPane.getChildren().clear();TelephoneBook book = TelephoneBookListPane.getList().get(index);borderPane.setCenter(new AddAndEditPane("编辑联系人",borderPane,book,2,index));});// 删除delete.setOnMouseClicked(event -> {Alert _alert = new Alert(Alert.AlertType.CONFIRMATION,"",new ButtonType("否", ButtonBar.ButtonData.NO),new ButtonType("是", ButtonBar.ButtonData.YES));//设置窗口的标题_alert.setTitle("提示");_alert.setHeaderText("您将删除该联系人,是否继续?");//showAndWait() 将在对话框消失以前不会执行之后的代码Optional<ButtonType> _buttonType = _alert.showAndWait();//根据点击结果返回if(_buttonType.get().getButtonData().equals(ButtonBar.ButtonData.YES)){borderPane.getChildren().clear();TelephoneBookListPane.getList().remove(index);borderPane.setTop(TelephoneBookListPane.getBorderTop(borderPane));ScrollPane scrollPane = TelephoneBookListPane.getBorderBody(borderPane);borderPane.setCenter(scrollPane);borderPane.setBottom(TelephoneBookListPane.getBorderBottom(borderPane));borderPane.setLeft(TelephoneBookListPane.getSideBar(scrollPane));}});return hBox;}
}

4.参考博文

JAVA中如何获取中文汉字的首字母

Java 摄像(依靠开源框架WebCam)

5.完整代码

博主已上传至CSDN文件

未经允许不得转载,只能作学习用途!

未经允许不得转载,只能作学习用途!

未经允许不得转载,只能作学习用途!


Java手机通讯录并实现自动发送QQ消息及单人视频聊天窗口相关推荐

  1. python自动发送qq消息_自动给qq好友发消息

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 最近突然想做个自动发送qq消息的东西,然后上网搜了一下实现方法,找到了几篇用python实现的帖子,就自己试了试(原来只是简单了解过python,好多地方 ...

  2. 用python自动发送qq消息 可选择发送内容与次数

    python初学者,今天来试一下用python实现自动发送qq消息,实现自动化刷屏 只需要输入你要发送的内容.要发送的好友名称以及发送的次数,就可以实现了,效果如下 注意:聊天框必须只开这一个窗口,否 ...

  3. 自动发送QQ消息功能的原理及实现

    一.QQ窗口分析 近来QQ尾巴病毒,在网络上很是流行,我也常常收到网友们发到来的带尾巴的消息.国庆节闲来无事,就拿此病毒来消遣一下--写一个类似的自动发送QQ消息的小程序. 先让我们分析一下QQ尾巴的 ...

  4. 纯java手机通讯录

    要求 1.查看全部通讯录的信息 2.实现新增人员功能 3.修改用户信息功能 4.删除数据功能 5.查找人员功能实现 IOperatorMobile.java package com.geminno.m ...

  5. java手机通讯录格式转换_通讯录格式转换器设计与开发(JAVA平台)

    通讯录格式转换器设计与开发(平台)(任务书,开题报告,文献综述,中期检查表,外文翻译,毕业论文17000字,程序代码) 本文从当前社会人们需求出发,首先介绍了人们在处理手机信息和网络信息交互时的极大不 ...

  6. java手机通讯录格式转换_xml转换成vcf 魅族手机通讯录Contact.xml备份在flyme上的恢复(Java/C#实现xml转vCard)...

    xml转换成vcf 魅族手机通讯录Contact.xml备份在flyme上的恢复(Java/C#实现xml转vCard) 分类:杂谈| 发布:佚名| 查看: | 发表时间:2014/6/10 由上一篇 ...

  7. python实现自动发送qq消息

    太好玩了,刚开始的时候一不留神发群里了,肾上腺素激增,幸好那个群禁言! 下载相关库包: pip install pyautogui Mac版: import pyautogui as gui gui. ...

  8. Python 自动发送QQ端口消息 —— 2022/2/10

    自动发送QQ消息 pip install pywin32 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com import ...

  9. 【C#】QQ消息自动发送代码

    1.准备Windows API,是用C#开发的,所以要准备C#封装的Windows API.可以到以下地址下载: C#版封装的Windows API,简体版+增加版,源码 http://bmpj.ne ...

最新文章

  1. docker 删除容器_Docker使用命令和技巧
  2. 往往存储与计算机硬盘或其他,硬盘是计算机系统中信息资源最重要的存储设备其所存放信息-Read.DOC...
  3. 导致SEO优化排名不理想的三大因素,你踩雷了没?
  4. 深入理解javascript原型和闭包(6)——继承
  5. springboot2.3.x版本对应的spring5与thymeleaf版本配置
  6. Jmeter基础(二)
  7. leetcode 378. Kth Smallest Element in a Sorted Matrix | 378. 有序矩阵中第 K 小的元素(小根堆)
  8. 游戏会记录某个api的调用_专家坐诊丨老出BUG怎么办?游戏服务器常见问题的解决方法分享...
  9. java struts2下载文件_java struts2入门学习---文件下载的二种方式
  10. 自学电脑编程_81岁老太自学编程开发APP,她的日常酷过95%年轻人
  11. java cache system_JCS(Java Cache System)基本结构分析和使用
  12. 数学知识——高数速查手册
  13. 截止失真放大电路_基本放大电路应该如何分析?
  14. WPS新建文字分享微信.docx形式_高效神器:花 5 分钟输入文字,就能自动变成 PPT...
  15. TensorFlow学习--tf.summary.histogram与直方图仪表板/tensorboard_histograms
  16. Image Segmentation Using Deep Learning: A Survery
  17. 【经验分享】打通“任督”二脉——企业数字化转型中如何构建DevOps能力体系?
  18. 区块链技术 英文(BlockChain Terminal)简称BCT ——区块链终端
  19. Sliding Window(滑动窗口)
  20. 人工智能数学基础-线性代数4:矩阵及矩阵运算

热门文章

  1. MSN登录错误 8e5e0158
  2. matlab实验之简单识别手写0-9数字程序
  3. html字体由粗变细的方法,CSS 让 fontawesome 图标字体变细(示例代码)
  4. 21天以上的重复会形成习惯
  5. php 递归实现无限极分类和排序_php递归无限极分类
  6. 万能计算器——中缀表达式转换成后缀表达式(C++实现)【可以计算小数和负数】
  7. 通过一个word模板来生成新的word并且填充内容
  8. 这大概是博主用过的最好用的打卡功能——华为云WeLink
  9. 如何调成适用计算机的分辨率,怎么调电脑分辨率调最合适
  10. 微知库计算机应用基础,数据备份与恢复 课程标准 课程标准.doc