簡體   English   中英

使用Java從另一個應用程序的輸出向組合框添加值

[英]adding a value to combo box from output of another application using java

我有一個帶有組合框的Java應用程序,它顯示可用的com端口。

我還有另一個顯示藍牙名稱的應用程序。

現在我想在原始應用程序中顯示藍牙名稱以及com端口號,該怎么辦?

我使用以下代碼在組合框中顯示com端口

      public Vector LoadComPorts()
        {
                   int totalElements;
                    CommPortIdentifier portId;
                    Enumeration en = CommPortIdentifier.getPortIdentifiers();
                    Vector listData = new Vector(8);
                    // Walk through the list of port identifiers and, if it
                           // is a serial port, add its name to the list.
                    while (en.hasMoreElements())
                    {
                                portId = (CommPortIdentifier) en.nextElement();
                                if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)
                                {
                                            listData.addElement(portId.getName());
                                }

                                           //
                                            //  listData.addElement("COM30"); //ADDEDLINE
                    }

                   //   listData.addElement("COM29"); //ADDEDLINE

                    totalElements = listData.size();

                    //Iterate through the vector
                    for (int index = 0; index < totalElements; index ++)
                    {
                                System.out.println(listData.get(index));
                    }

                    return listData;
        }

     public Vector LoadComPorts2() //addedline
        {
               Vector listData = new Vector(8);

                String[] portNames = SerialPortList.getPortNames();

                for (String port : portNames)
                {
                   listData.add(port);
                }


               return listData;
}

如果您有其他應用程序的源代碼,請調用枚舉藍牙端口的方法。 如果您沒有源並且只有可執行文件,那么您需要提供更多信息。 無論您提供任何信息,都無法給出可接受的答案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM