当前位置: 首页 > news >正文

马云做黄页网站时候威海seo

马云做黄页网站时候,威海seo,网站建设找盛誉网络,企业所得税会计分录目录 1. 创建一个可观察的列表,用于存储ListView中的数据,这里的User是包装了用户的相关信息。 2.通过本人id获取friendid,及好友的id,然后用集合接送,更方便直观一点。 3.用for遍历集合,逐个添加。 4.渲染器&…

目录

1. 创建一个可观察的列表,用于存储ListView中的数据,这里的User是包装了用户的相关信息。

2.通过本人id获取friendid,及好友的id,然后用集合接送,更方便直观一点。

3.用for遍历集合,逐个添加。

4.渲染器(ImageCellFctoryFriendList)定制

5.渲染器具体方法如下:


1. 创建一个可观察的列表,用于存储ListView中的数据,这里的User是包装了用户的相关信息。

 // 创建一个可观察的列表,用于存储ListView中的数据ObservableList<User> friendList = FXCollections.observableArrayList();

记得把javafx的你需要使用的ListView命名

2.通过本人id获取friendid,及好友的id,然后用集合接送,更方便直观一点。

​List<User> ren = (List<User>) Connection.ois.readObject();//我的id,好友id及添加时间​

3.用for遍历集合,逐个添加。

for (User user : ren) {  

sitItems展示我添加的好友信息(项目中我只展示了好友的头像,昵称及在线状态)

​this.friendListview.setItems(this.friendList);this.friendList.add(person);​

最后,通过setCellFctory(渲染器)展示控件的每个单元格,并且它可以允许你为每个单元格提供一个定制的渲染器,这里我定制的渲染器为ImageCellFctoryFriendList(方法名自定义),为自定义函数,格式需要一样,但是内容可以自定义。

 this.friendListview.setCellFactory(new ImageCellFactoryFriendList());

4.渲染器(ImageCellFctoryFriendList)定制

具体代码在本文章的最后!!!

这里先获取需要的用户信息,然后进行展示,两个50分别为展示头像的长和宽。

 //更新单元格内容String username = listviewmember.name;//获取用户名String imagePath = listviewmember.image;//获取用户头像int online = listviewmember.online; // 获取用户在线状态//显示头像File imageFile = new File(imagePath);Image images = new Image(imageFile.toURI().toString());this.imageView.setFitWidth(50.0);this.imageView.setFitHeight(50.0);this.imageView.setImage(images);this.setGraphic(this.imageView);// 设置用户名setText(username);// 设置在线状态的颜色if (online==1) {setTextFill(Color.GREEN); // 在线状态为绿色setText(username + " (在线)");} else {setTextFill(Color.RED); // 不在线状态为红色setText(username + " (离线)");}this.setPrefHeight(-1.0);

设置右击菜单,这里右会出现两个按钮,

option1.setOnAction((event) -> {是设置点击按钮1,执行查看资料功能,内容可以直接设置。

注意:有几个按钮就需要添加几个进MenuItem。

          //设置右键菜单ContextMenu contextMenu = new ContextMenu();MenuItem option1 = new MenuItem("查看资料");MenuItem option2 = new MenuItem("删除好友");contextMenu.getItems().addAll(new MenuItem[]{option1,option2});this.setContextMenu(contextMenu);//查看资料option1.setOnAction((event) -> {

最后显示之前设置的MenuItem。

//设置鼠标点击事件,当右键点击时,显示上述创建的ContextMenuthis.setOnMouseClicked((event) -> {if (event.getButton() == MouseButton.SECONDARY) {contextMenu.show(this, event.getScreenX(), event.getScreenY());}});

具体效果如下:

5.渲染器具体方法如下:

其中User为用户信息,MarkTool类是为了方便客户端,服务端传递信息的。


public class ImageCellFactoryFriendList implements Callback<ListView<User>, ListCell<User>> {public ImageCellFactoryFriendList() {}public ListCell<User> call(ListView<User> param) {return new ListCell<User>() {private ImageView imageView = new ImageView();protected void updateItem(User listviewmember, boolean empty) {super.updateItem(listviewmember, empty);if (!empty && listviewmember != null) {//更新单元格内容String username = listviewmember.name;//获取用户名String imagePath = listviewmember.image;//获取用户头像int online = listviewmember.online; // 获取用户在线状态//显示头像File imageFile = new File(imagePath);Image images = new Image(imageFile.toURI().toString());this.imageView.setFitWidth(50.0);this.imageView.setFitHeight(50.0);this.imageView.setImage(images);this.setGraphic(this.imageView);// 设置用户名setText(username);// 设置在线状态的颜色if (online==1) {setTextFill(Color.GREEN); // 在线状态为绿色setText(username + " (在线)");} else {setTextFill(Color.RED); // 不在线状态为红色setText(username + " (离线)");}this.setPrefHeight(-1.0);//设置右键菜单ContextMenu contextMenu = new ContextMenu();MenuItem option1 = new MenuItem("查看资料");MenuItem option2 = new MenuItem("删除好友");contextMenu.getItems().addAll(new MenuItem[]{option1,option2});this.setContextMenu(contextMenu);//查看资料option1.setOnAction((event) -> {System.out.println("查看资料按钮!!");LookPersonalData.id = listviewmember.id;LookPersonalData.user=listviewmember;FriendPersonalData.user = listviewmember;//???URL url = this.getClass().getResource("LookPersonalData.fxml");if (url == null) {System.err.println("无法找到LookPersonalData.fxml资源文件");} else {Parent root = null;try {root = (Parent)FXMLLoader.load(url);} catch (IOException var7) {IOException e = var7;e.printStackTrace();return;}Stage stage = new Stage();stage.setTitle("个人界面");stage.initStyle(StageStyle.UTILITY);Scene scene = new Scene(root, 800.0, 640.0);stage.setScene(scene);stage.show();}});//删除好友option2.setOnAction((event) -> {System.out.println("删除好友按钮!!");try {String id = listviewmember.id;String friendid = listviewmember.friendid;User u = new User(id, friendid);String Operation = MarkTool.DeleteFriend;Connection.oos.writeObject(Operation);Connection.oos.writeObject(u);String response = Connection.ois.readObject().toString();System.out.println(response + "删除成功与否结果已收到");//103    yesif (response.equals(MarkTool.DeleteFriendfail)) {Alert alertxx = new Alert(Alert.AlertType.INFORMATION);alertxx.setTitle("错误");alertxx.setHeaderText((String)null);alertxx.setContentText("删除失败,看样子他不想失去你呢!");alertxx.showAndWait();}else {Alert alertx = new Alert(Alert.AlertType.INFORMATION);alertx.setTitle("正确");alertx.setHeaderText((String) null);alertx.setContentText("删除成功,减少一位损友!");alertx.showAndWait();}}  catch (IOException var15) {IOException exx = var15;throw new RuntimeException(exx);} catch (ClassNotFoundException var16) {ClassNotFoundException ex = var16;throw new RuntimeException(ex);}});//设置鼠标点击事件,当右键点击时,显示上述创建的ContextMenuthis.setOnMouseClicked((event) -> {if (event.getButton() == MouseButton.SECONDARY) {contextMenu.show(this, event.getScreenX(), event.getScreenY());}});} else {this.setText((String)null);this.setGraphic((Node)null);this.setPrefHeight(0.0);}}};}
}

http://www.ds6.com.cn/news/72012.html

相关文章:

  • 专门为网站建设服务的公司去哪里找需要推广的app
  • 中铁建设集团华北分公司网站域名查询注册信息查询
  • 门户网站做等保需要备案哪些百度免费广告发布平台
  • 建设彩票网站制作免费优化网站
  • wordpress和csdn的区别seo行业岗位有哪些
  • 货源网站开发今日小说百度搜索风云榜
  • 成都市自住房建设网站网站发布与推广方案
  • 天元建设集团有限公司开票信息seo网页优化公司
  • 找公司做网站注意事项百度关键词怎么做
  • 舟山网站建设企业产品seo优化
  • 毕业设计网站建设重庆网站seo技术
  • 手机网站开发解决方案全国疫情实时动态
  • 聊城网站开发培训网站发帖推广平台
  • dedecms 建两个网站的问题广告网络推广怎么做
  • 河南高端网站建设冯宗耀seo教程
  • 万达做的电商网站女教师网课入06654侵录屏
  • 北京响应式网站开发新的网络推广方式
  • 不用写代码做网站软件百度模拟点击软件判刑了
  • 网站建设需要的资质网络推广 网站制作
  • 网站做导航条网站推广多少钱
  • 注册公司名字核名查询系统seo关键词首页排名
  • 做设计挣钱的网站网络域名
  • 如何做电子海报在网站做一个网站需要什么
  • p2p免费网站建设最新国内新闻10条
  • 网站上怎么引用视频怎样宣传自己的品牌
  • 做一个网址多少钱安徽seo报价
  • 视频娱乐模版网站购买搜索竞价排名
  • 领动做的企业网站怎么样域名备案查询官网
  • 怎么样看网站用什么程序做的上海做关键词推广企业
  • 私人网站如何做竞价百度提交网站收录查询