2015-08-24 16 views
1

嗨,这是我的问题,我不能显示面板进入根面板,即时通讯做类似的聊天有些像Skype,但我需要显示(消息),它没有显示,当我发送消息给用户的部分。 enter image description here 嗯,这是我的代码发送我的消息:如何在其他窗格中显示我的面板?

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){ 

       } 
      } 

     }); 

,这是绘制图像和文本到其它面板的方法:

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前进。

回答

0

他,他这是很容易做到,你只需要与

@FXML private variablePane variable; 
,用来初始化的变量任何在这种情况下,所有的窗格
相关问题