Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to stop opening of duplicate window using Smack API in swing?
    text
    copied!<p>I have 2 swing classes which extends <code>JFrame</code>. Both have <code>show()</code> method in there constructor. From <code>ClassOne</code> i called <code>ClassTwo</code> like <code>new ClassTwo()</code> on button click event. But if i press the button again new window for <code>ClassTwo</code> is opened. So how can i stop opening of ClassTwo window if one ClassTwo window is opened ?</p> <p><strong>Edit</strong></p> <p>now this problem is solved but now when i first open ClassTwo window it shows one window. Then after closing it when i again open ClassTwo window it opens two window and this count keep on increamenting. Why this is happening?</p> <p><strong>EDIT 2</strong></p> <p>I found that its not swing problem but its problem from MultiUsreChat class of Samck API. So anyone who have worked on it help me.</p> <p>the code in ClassOne is:</p> <pre><code>if(!winList.contains(room_jid)){ new ClassTwo(room_jid,....); winList.add(room_jid); } </code></pre> <p>and in ClassTwo is:</p> <pre><code>public ClassTwo(....){ ...... this.muc = new MultiUserChat(connection, room_jid); if(!muc.isJoined()) muc.join(this.user_id); //---- This line opens previously closed window. ..... if(!isVisible()) show(); } </code></pre> <p><strong>Edit 3</strong></p> <p>constructor of classone</p> <pre><code>public ClassOne(){ JButton btn = new JButton("Open"); btn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ if(!winList.contains(room_jid)){ new ClassTwo(room_jid,....); winList.add(room_jid); } } }); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload