[sip-comm-dev] Pb with gui plugin and JButton


#1

Hello everyone,

I'm trying to implement a JDialog which will popup and ask the user of sip if he/she wants to accept/reject/ignore an invitation (same as whiteboard invitation)

The problem is that when I integrate a JButton in my code of the JDialog (strongly inspired by exemplePlugin), the popup doesn't open when an invitation is sent (it works fine when I don't add the JButton) bellow the code and my manifest file.

Cheers,

Fabien

···

---------------------------------------------------------------------------------

/*
  * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
  */
package net.java.sip.communicator.plugin.game.gui;

import java.awt.*;

import javax.swing.*;

import net.java.sip.communicator.plugin.game.*;
import net.java.sip.communicator.service.protocol.*;

/**
  * A plugin dialog that is open through the right button menu over a contact and
  * shows the contact name.
  *
  * @author Yana Stamcheva (Fabien Pozzobon)
  */

public class GamePluginDialog
     extends JDialog
{
     /**
      * The <tt>GameInvitation</tt> for which this dialog is.
      */
     private GameInvitation invitation;

     /**
      * The <tt>MultiUserGameManager</tt> is the one that deals with invitation
      * events.
      */
     private GameSessionManager gameManager;

     /**
      * The operation set that would handle the rejection if the user choose to
      * reject the invitation.
      */
     private OperationSetGaming gameOpSet;

     private JTextArea infoTextArea = new JTextArea();

     private JPanel mainPanel = new JPanel();

     private JLabel contactLabel = new JLabel();

     private JLabel nameLabel = new JLabel();

     //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     //HERE IS THE BUG (THE LINE BELOW)

     private JButton acceptButton = new JButton(Resources.getString("accept"));

     //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

     //private JButton rejectButton = new JButton(Resources.getString("reject"));

     //private JButton ignoreButton = new JButton(Resources.getString("ignore"));

     public GamePluginDialog(GameSessionManager gameManager,
             OperationSetGaming gameOpSet,
             GameInvitation invitation)
     {
         this.setTitle("Invitation");

         this.gameManager = gameManager;

         this.gameOpSet = gameOpSet;

         this.invitation = invitation;

         this.infoTextArea.setPreferredSize(new Dimension(250, 70));

         this.infoTextArea.setText("This is an example plugin that shows the "
             + "currently selected contact"
             + " in a separate window.");

         this.nameLabel.setText("You received an invitation to play a game with the contact :");
         this.contactLabel.setText(this.invitation.getInviter());

         this.mainPanel.add(infoTextArea);
         this.mainPanel.add(nameLabel);
         this.mainPanel.add(contactLabel);

         /*this.mainPanel.add(this.acceptButton);
         this.mainPanel.add(this.rejectButton);
         this.mainPanel.add(this.ignoreButton);*/

         this.getContentPane().add(mainPanel);

         this.setStyles();

         this.setResizable(false);
         this.pack();
     }

     private void setStyles()
     {
         this.mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

         this.mainPanel.setBorder(
             BorderFactory.createEmptyBorder(10, 10, 10, 10));

         this.infoTextArea.setEditable(false);
         this.infoTextArea.setOpaque(false);
         this.infoTextArea.setWrapStyleWord(true);
         this.infoTextArea.setLineWrap(true);
         this.infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD));
         this.infoTextArea.setAlignmentX(JTextArea.CENTER_ALIGNMENT);

         this.nameLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);

         this.contactLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
         this.contactLabel.setAlignmentY(JLabel.TOP_ALIGNMENT);
         this.contactLabel.setFont(contactLabel.getFont().deriveFont(Font.BOLD));
     }
}

-------------------------------------------------------------------------------

Bundle-Activator: net.java.sip.communicator.plugin.game.GamePluginLaunch
Bundle-Name: Game plugin
Bundle-Description: A plugin that implement the game invitation in SIP.
Bundle-Vendor: sip-communicator.org
Bundle-Version: 0.0.1
Import-Package: org.osgi.framework,
  net.java.sip.communicator.util,
  net.java.sip.communicator.service.contactlist,
  net.java.sip.communicator.service.contactlist.event,
  net.java.sip.communicator.service.gui,
  net.java.sip.communicator.service.gui.event,
  net.java.sip.communicator.service.protocol.event,
  net.java.sip.communicator.service.protocol,
  net.java.sip.communicator.service.protocol.gameobjects,
  javax.swing,
  javax.swing.event,
  javax.swing.table,
  javax.swing.text,
  javax.swing.text.html,
  javax.accessibility,
  javax.swing.plaf,
  javax.swing.plaf.metal,
  javax.swing.plaf.basic,
  javax.imageio,
  javax.swing.filechooser,
  javax.swing.tree,
  javax.swing.undo,
  javax.swing.border

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#2

Fabien.Pozzobon@ulp.u-strasbg.fr a écrit :

Well... it's a problem with Resources.getString("accept"),

sorry for disturbing... now it works fine :stuck_out_tongue:

···

Hello everyone,

I'm trying to implement a JDialog which will popup and ask the user of
sip if he/she wants to accept/reject/ignore an invitation (same as
whiteboard invitation)

The problem is that when I integrate a JButton in my code of the
JDialog (strongly inspired by exemplePlugin), the popup doesn't open
when an invitation is sent (it works fine when I don't add the JButton)
bellow the code and my manifest file.

Cheers,

Fabien

---------------------------------------------------------------------------------

/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.game.gui;

import java.awt.*;

import javax.swing.*;

import net.java.sip.communicator.plugin.game.*;
import net.java.sip.communicator.service.protocol.*;

/**
* A plugin dialog that is open through the right button menu over a
contact and
* shows the contact name.
*
* @author Yana Stamcheva (Fabien Pozzobon)
*/

public class GamePluginDialog
    extends JDialog
{
    /**
     * The <tt>GameInvitation</tt> for which this dialog is.
     */
    private GameInvitation invitation;

    /**
     * The <tt>MultiUserGameManager</tt> is the one that deals with invitation
     * events.
     */
    private GameSessionManager gameManager;

    /**
     * The operation set that would handle the rejection if the user choose to
     * reject the invitation.
     */
    private OperationSetGaming gameOpSet;

    private JTextArea infoTextArea = new JTextArea();

    private JPanel mainPanel = new JPanel();

    private JLabel contactLabel = new JLabel();

    private JLabel nameLabel = new JLabel();

    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    //HERE IS THE BUG (THE LINE BELOW)

    private JButton acceptButton = new JButton(Resources.getString("accept"));

    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    //private JButton rejectButton = new
JButton(Resources.getString("reject"));

    //private JButton ignoreButton = new
JButton(Resources.getString("ignore"));

    public GamePluginDialog(GameSessionManager gameManager,
            OperationSetGaming gameOpSet,
            GameInvitation invitation)
    {
        this.setTitle("Invitation");

        this.gameManager = gameManager;

        this.gameOpSet = gameOpSet;

        this.invitation = invitation;

        this.infoTextArea.setPreferredSize(new Dimension(250, 70));

        this.infoTextArea.setText("This is an example plugin that shows the "
            + "currently selected contact"
            + " in a separate window.");

        this.nameLabel.setText("You received an invitation to play a
game with the contact :");
        this.contactLabel.setText(this.invitation.getInviter());

        this.mainPanel.add(infoTextArea);
        this.mainPanel.add(nameLabel);
        this.mainPanel.add(contactLabel);

        /*this.mainPanel.add(this.acceptButton);
        this.mainPanel.add(this.rejectButton);
        this.mainPanel.add(this.ignoreButton);*/

        this.getContentPane().add(mainPanel);

        this.setStyles();

        this.setResizable(false);
        this.pack();
    }

    private void setStyles()
    {
        this.mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

        this.mainPanel.setBorder(
            BorderFactory.createEmptyBorder(10, 10, 10, 10));

        this.infoTextArea.setEditable(false);
        this.infoTextArea.setOpaque(false);
        this.infoTextArea.setWrapStyleWord(true);
        this.infoTextArea.setLineWrap(true);

this.infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD));
        this.infoTextArea.setAlignmentX(JTextArea.CENTER_ALIGNMENT);

        this.nameLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);

        this.contactLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
        this.contactLabel.setAlignmentY(JLabel.TOP_ALIGNMENT);

this.contactLabel.setFont(contactLabel.getFont().deriveFont(Font.BOLD));
    }
}

-------------------------------------------------------------------------------

Bundle-Activator: net.java.sip.communicator.plugin.game.GamePluginLaunch
Bundle-Name: Game plugin
Bundle-Description: A plugin that implement the game invitation in SIP.
Bundle-Vendor: sip-communicator.org
Bundle-Version: 0.0.1
Import-Package: org.osgi.framework,
net.java.sip.communicator.util,
net.java.sip.communicator.service.contactlist,
net.java.sip.communicator.service.contactlist.event,
net.java.sip.communicator.service.gui,
net.java.sip.communicator.service.gui.event,
net.java.sip.communicator.service.protocol.event,
net.java.sip.communicator.service.protocol,
net.java.sip.communicator.service.protocol.gameobjects,
javax.swing,
javax.swing.event,
javax.swing.table,
javax.swing.text,
javax.swing.text.html,
javax.accessibility,
javax.swing.plaf,
javax.swing.plaf.metal,
javax.swing.plaf.basic,
javax.imageio,
javax.swing.filechooser,
javax.swing.tree,
javax.swing.undo,
javax.swing.border

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net