public void publish() throws Exception
    {
        try {
                if(!"".equals(jTextField4.getText()))
                {
                    topics[1] = new Topic(jTextField4.getText(), QoS.AT_LEAST_ONCE);
                    qoses = this.connection.subscribe(topics);
                    String tmp;
                    if(jRadioButton1.isSelected() == true)      //JSON
                    {
                        //pubblica il messaggio
                        tmp = jTextField3.getText();
                        this.connection.publish(jTextField4.getText(), tmp.getBytes(), QoS.AT_LEAST_ONCE, false);
                    }
                    else if(jRadioButton2.isSelected() == true) //Normal
                    {
                        //pubblica il messaggio
                        //tmp = "{\" " + InetAddress.getLocalHost().getHostName() + " \": \" " + jTextField3.getText() +" \"}";
                        this.connection.publish(jTextField4.getText(), jTextField3.getText().getBytes(), QoS.AT_LEAST_ONCE, false);
                    }
                    else if(jRadioButton3.isSelected() == true) //Chat
                    {
                        //pubblica il messaggio
                        tmp = "{\" " + InetAddress.getLocalHost().getHostName() + " \": \" " + jTextField3.getText() +" \"}";
                        this.connection.publish(jTextField4.getText(), tmp.getBytes(), QoS.AT_LEAST_ONCE, false);
                    }
                }
                else
                {JOptionPane.showMessageDialog(null, "No Topic to Publish!");}
                
                //tmp = "{\" " + InetAddress.getLocalHost().getHostName() + " \": \" " + jTextField3.getText() +" \"}";
                //this.connection.publish(jTextField4.getText(), /*jTextField3.getText()*/tmp.getBytes(), QoS.AT_LEAST_ONCE, false);           
        } catch (Exception ex) {
            Logger.getLogger(mainJFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }