简体   繁体   English

如何在其他窗格中显示面板?

[英]How can i show my panels in the other panes?

Hi this is my problem i cant show the panels into the root panel, im doing a similar chat some like skype but the part that i need to show(messages), its not showed, when i send the message to the users. 嗨,这是我的问题,我无法将面板显示到根面板中,即时通讯在进行类似Skype的聊天,但是当我向用户发送消息时,我需要显示的部分(消息)没有显示。 在此处输入图片说明 Well this is my code to send my message: 这是我发送信息的代码:

btnSend.setOnAction(new EventHandler<ActionEvent>() {


            @Override
            public void handle(ActionEvent event) {


                String empty = "";
                String sendMessage = txtMensajes.getText();
                String[] talkTo_array = lstDisplayBuddys.getSelectionModel().getSelectedItem().toString().split("-");
                String talkTo = talkTo_array[talkTo_array.length - 1]+"@mpns.mcm.net.mx";

                try{
                    // CONDITION IF ARE EMPTY THE MESSAGES 

                    if (sendMessage.equals(empty)) {
                        JOptionPane.showMessageDialog(null, "Add some message");
                    }
                    else{
                        if (talkTo != sendMessage) {
                            while (true) {

                                try {

                                    sendMessage(XMPPChatHelper.encodeBase64(sendMessage), talkTo);
                                    System.out.println("send message");

                                    //SHOW MY MESSAGES WHEN I SEND IT
                                    Platform.runLater(()->{
                                        pnContArea.getChildren().addAll(drawSendMessage(sendMessage));
                                        txtMensajes.setText("");
                                    });



                                } catch (XMPPException e) {

                                    e.printStackTrace();
                                }
                                break;
                            }
                            ConnectionDBHistorialHelper ConnectionDBHistorialHelper=new ConnectionDBHistorialHelper();
                            ConnectionDBHistorialHelper.saveMessageSend(sendMessage);
                        }
                    }
                }catch(Exception e){

                }
            }

        });

and this is the method that draw the image and the text into the other panel: 这是将图像和文本绘制到另一个面板中的方法:

public StackPane drawSendMessage(String message){
        StackPane paneSend=new StackPane();
        Platform.runLater(()->{
            Text sendMessageText=new Text(message);
            ImageView imaSend=new ImageView(HomeController.class.getResource("/image/isend.png").toExternalForm());
            paneSend.getChildren().addAll(imaSend,sendMessageText);
            paneSend.setAlignment(Pos.BASELINE_LEFT);

        });
        return paneSend;
    }

thnks advanced. thnks先进。

他很容易做到,您只需要初始化任何变量,在这种情况下,所有窗格

@FXML private variablePane variable;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM