Exemplo n.º 1
0
  public JFrame buildFrame() {

    f = new JFrame("AMSA World");
    f.setSize(800, 600);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLayout(new GridBagLayout());

    textArea.setFocusable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            checkInput();
          }
        };
    inputText.addActionListener(listener);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1.0;
    c.gridwidth = 3;
    c.weighty = 0.025;
    c.gridx = 0;
    c.gridy = 0;
    f.add(topPanel, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = 2;
    c.gridx = 0;
    c.gridy = 1;
    f.add(scrollPane, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = 1;
    c.gridx = 2;
    c.gridy = 1;
    f.add(sidePanel, c);
    sidePanel.setVisible(false);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weighty = 0.025;
    c.gridwidth = 3;
    c.gridx = 0;
    c.gridy = 2;
    f.add(inputText, c);

    f.setVisible(true);

    return f;
  }
Exemplo n.º 2
0
    public DisplayResults() {
      GridBagLayout gbl = new GridBagLayout();
      GridBagConstraints gbc = new GridBagConstraints();
      setLayout(gbl);

      gbc.anchor = GridBagConstraints.NORTHWEST;
      gbc.fill = GridBagConstraints.HORIZONTAL;

      text.setForeground(Color.black);
      add(text, gbc);
      gbc.gridy = 0;
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(emptyLabel, gbc);
      add(Box.createVerticalStrut(0), gbc);
      add(emptyLabel, gbc);

      /*	 gbc.gridy = 1;
      VTextMsg result = new VTextMsg(sshare, vnmrif, null);
      result.setPreferredSize(new Dimension(300, 30));
      result.setForeground(Color.black);
      add( result, gbc );
      */
      setBorder(
          new CompoundBorder(
              BorderFactory.createTitledBorder("  Results  "),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
Exemplo n.º 3
0
    public DisplayUserDirectory() {
      GridBagLayout gbl = new GridBagLayout();
      GridBagConstraints gbc = new GridBagConstraints();
      setLayout(gbl);

      gbc.anchor = GridBagConstraints.NORTHWEST;
      gbc.fill = GridBagConstraints.HORIZONTAL;

      hmlabel.setForeground(Color.black);
      add(hmlabel, gbc);
      add(Box.createHorizontalStrut(10), gbc);
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(hmdir, gbc);
      add(Box.createVerticalStrut(15), gbc);

      gbc.gridwidth = 1;
      vjlabel.setForeground(Color.black);
      add(vjlabel, gbc);
      add(Box.createHorizontalStrut(10), gbc);
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(vjdir, gbc);
      add(Box.createVerticalStrut(0), gbc);

      gbc.gridwidth = 1;
      vjlabel2.setForeground(Color.black);
      add(vjlabel2, gbc);
      setBorder(
          new CompoundBorder(
              // i18n
              // BorderFactory.createTitledBorder(" User_Directories "),
              BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
 protected GridBagConstraints createConstraints(int x, int y) {
   GridBagConstraints c = new GridBagConstraints();
   c.gridx = x;
   c.gridy = y;
   c.gridwidth = 2;
   c.gridheight = 1;
   c.ipadx = 1;
   c.weightx = 0.5;
   c.weighty = 0.5;
   c.fill = GridBagConstraints.BOTH;
   c.anchor = GridBagConstraints.CENTER;
   return c;
 }
Exemplo n.º 5
0
 private void addGrid(
     JPanel p, Component co, int x, int y, int w, int fill, double wx, int anchor) {
   GridBagConstraints c = new GridBagConstraints();
   c.gridx = x;
   c.gridy = y;
   c.gridwidth = w;
   c.anchor = anchor;
   c.weightx = wx;
   c.fill = fill;
   if (fill == GridBagConstraints.BOTH || fill == GridBagConstraints.VERTICAL) c.weighty = 1.0;
   c.insets = new Insets(y == 0 ? 10 : 0, GAP, GAP, GAP);
   p.add(co, c);
 }
Exemplo n.º 6
0
  /** Créer les composants */
  private void initComponents() {

    text = new JTextArea();
    button_licence = new JButton();
    button_close = new JButton();
    logo = new LogoComponent();

    // Ajout des actions listeners
    button_licence.addActionListener(new ButtonLicenceActionListener());
    button_close.addActionListener(new ButtonCloseActionListener(this));

    logo.setPreferredSize(new Dimension(128, 128));

    text.setText(
        "Version : 1.0b \n"
            + "\n"
            + "Copyright © 2008-2012 Sipieter Clément \n"
            + "Copyright © 2011-2012 Sellem Lev-Arcady");
    text.setBackground(this.getBackground());

    button_licence.setText("Licence");
    button_close.setText("Fermer");

    this.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    this.add(logo, gbc);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridwidth = 3;
    gbc.insets = new Insets(20, 20, 20, 20);
    this.add(text, gbc);

    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 5, 20, 5);

    this.add(button_licence, gbc);

    gbc.gridx = 2;
    gbc.gridy = 2;
    this.add(button_close, gbc);
    this.pack();
  }
    public void addForDisplay(CTalkativeTextPane pane, LabelPair<String, String> lp) {
      GridBagLayout gridbag = (GridBagLayout) getLayout();
      labelPair = lp;
      label = new JLabel(labelPair.getSingular(), JLabel.LEFT);
      pane.getDocument().addDocumentListener(this);

      GridBagConstraints c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = 0;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.weightx = 0.1;
      c.weighty = 0.1;
      c.anchor = GridBagConstraints.LINE_START;
      c.insets = new Insets(0, 20, 0, 00);
      gridbag.setConstraints(pane, c);
      add(pane);

      c = new GridBagConstraints();
      c.gridx = 1;
      c.gridy = 0;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.weightx = 0.1;
      c.weighty = 0.1;
      c.anchor = GridBagConstraints.LINE_START;
      c.insets = new Insets(0, 0, 0, 20);
      gridbag.setConstraints(label, c);
      add(label);

      JPanel filler = new JPanel();
      filler.setBackground(white);
      c = new GridBagConstraints();
      c.gridx = 2;
      c.gridy = 0;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.weightx = 0.8;
      c.weighty = 0.8;
      c.fill = GridBagConstraints.BOTH;
      c.anchor = GridBagConstraints.LINE_END;
      gridbag.setConstraints(filler, c);
      add(filler);

      filler = null;
      c = null;
    }
Exemplo n.º 8
0
  /**
   * Sets the reason of a call failure if one occurs. The renderer should display this reason to the
   * user.
   *
   * @param reason the reason to display
   */
  public void setErrorReason(final String reason) {
    if (!SwingUtilities.isEventDispatchThread()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              setErrorReason(reason);
            }
          });
      return;
    }

    if (errorMessageComponent == null) {
      errorMessageComponent = new JTextPane();

      JTextPane textPane = (JTextPane) errorMessageComponent;
      textPane.setEditable(false);
      textPane.setOpaque(false);

      StyledDocument doc = textPane.getStyledDocument();

      MutableAttributeSet standard = new SimpleAttributeSet();
      StyleConstants.setAlignment(standard, StyleConstants.ALIGN_CENTER);
      StyleConstants.setFontFamily(standard, textPane.getFont().getFamily());
      StyleConstants.setFontSize(standard, 12);
      doc.setParagraphAttributes(0, 0, standard, true);

      GridBagConstraints constraints = new GridBagConstraints();
      constraints.fill = GridBagConstraints.HORIZONTAL;
      constraints.gridx = 0;
      constraints.gridy = 4;
      constraints.weightx = 1;
      constraints.weighty = 0;
      constraints.insets = new Insets(5, 0, 0, 0);

      add(errorMessageComponent, constraints);
      this.revalidate();
    }

    errorMessageComponent.setText(reason);

    if (isVisible()) errorMessageComponent.repaint();
  }
Exemplo n.º 9
0
    public DisplayTemplate(String strDir, String strDefDirFile) {
      setLayout(m_gbl);

      m_gbc.anchor = GridBagConstraints.NORTHWEST;
      m_gbc.fill = GridBagConstraints.HORIZONTAL;

      m_strPathDir = strDir;
      m_strDefDirFile = strDefDirFile;

      setLayout(new BorderLayout());
      m_pnlDisplay = new JPanel(m_gbl);
      JScrollPane spDisplay = new JScrollPane(m_pnlDisplay);
      add(spDisplay, BorderLayout.CENTER);

      JComponent pnlTool = getToolBar();
      add(pnlTool, BorderLayout.NORTH);

      layoutUIComponents(FileUtil.openPath(m_strDefDirFile), true);
      VItemArea1.addChangeListener(this);
      VUserToolBar.addChangeListener(this);
    }
Exemplo n.º 10
0
  private void drawComponents() {
    GridBagConstraints con = new GridBagConstraints();
    con.gridx = 0;
    con.gridy = 0;
    con.gridwidth = 1;
    con.gridheight = 1;
    con.anchor = GridBagConstraints.NORTH;
    con.fill = GridBagConstraints.HORIZONTAL;
    con.insets = new Insets(5, 5, 5, 5);
    con.weightx = 0;
    con.weighty = 0;

    Box btns = Box.createHorizontalBox();
    btns.add(btnDetails);
    btns.add(Box.createHorizontalGlue());
    btns.add(btnClose);

    // Set up content
    Container content = getContentPane();
    content.setLayout(new GridBagLayout());

    // Add message label
    con.weightx = 1;
    con.weighty = 1;
    content.add(lblMessage, con);

    // Add button box
    con.gridy = 1;
    con.weighty = 0;
    content.add(btns, con);

    // Add trace pane
    con.gridy = 2;

    content.add(srlTrace, con);

    // Set default button
    getRootPane().setDefaultButton(btnClose);
  }
  /**
   * The consturctor Constructor instantiates all the panels, convertible value instance, and the
   * frame. And adds the panels to the frame. And sets a proper size for the frame.
   */
  public HappyHackingConverter() {
    CFrame frame = new CFrame();
    frame.setBackground(white);

    ConvertibleValue temperatures = new ConvertibleValue();
    ConvertibleValue distances = new ConvertibleValue();
    ConvertibleValue weights = new ConvertibleValue();

    GridBagLayout leftSideLayout = new GridBagLayout();
    JPanel leftSide = new JPanel(leftSideLayout);
    leftSide.setBackground(white);

    GridBagLayout rightSideLayout = new GridBagLayout();
    JPanel rightSide = new JPanel(rightSideLayout);
    rightSide.setBackground(white);

    GridBagConstraints metricTemperatureConstraints = new GridBagConstraints();
    metricTemperatureConstraints.gridx = 0;
    metricTemperatureConstraints.gridy = 0;
    metricTemperatureConstraints.weighty = 0.1;
    metricTemperatureConstraints.weightx = 1;
    metricTemperatureConstraints.fill = GridBagConstraints.BOTH;
    metricTemperatureConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    JPanel metricTemperaturePanel =
        new TemperaturePanel(frame, temperatures, TemperatureScales.CENTIGRADE);
    leftSideLayout.setConstraints(metricTemperaturePanel, metricTemperatureConstraints);
    leftSide.add(metricTemperaturePanel);

    GridBagConstraints metricDistancesPanelConstraints = new GridBagConstraints();
    metricDistancesPanelConstraints.gridx = 0;
    metricDistancesPanelConstraints.gridy = 1;
    metricDistancesPanelConstraints.weighty = 0.3;
    metricDistancesPanelConstraints.weightx = 1;
    metricDistancesPanelConstraints.fill = GridBagConstraints.BOTH;
    metricDistancesPanelConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    JPanel metricDistancesPanel = new MetricDistancesPanel(frame, distances);
    leftSideLayout.setConstraints(metricDistancesPanel, metricDistancesPanelConstraints);
    leftSide.add(metricDistancesPanel);

    GridBagConstraints fahrenheitConstraints = new GridBagConstraints();
    fahrenheitConstraints.gridx = 0;
    fahrenheitConstraints.gridy = 0;
    fahrenheitConstraints.weighty = 0.1;
    fahrenheitConstraints.weightx = 1;
    fahrenheitConstraints.fill = GridBagConstraints.BOTH;
    fahrenheitConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    JPanel fahrenheitTemperaturePanel =
        new TemperaturePanel(frame, temperatures, TemperatureScales.FAHRENHEIT);
    rightSideLayout.setConstraints(fahrenheitTemperaturePanel, fahrenheitConstraints);
    rightSide.add(fahrenheitTemperaturePanel);

    GridBagConstraints imperialDistancesPanelConstraints = new GridBagConstraints();
    imperialDistancesPanelConstraints.gridx = 0;
    imperialDistancesPanelConstraints.gridy = 1;
    imperialDistancesPanelConstraints.weighty = 0.3;
    imperialDistancesPanelConstraints.weightx = 1;
    imperialDistancesPanelConstraints.fill = GridBagConstraints.BOTH;
    imperialDistancesPanelConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    JPanel imperialDistancesPanel = new ImperialDistancesPanel(frame, distances);
    rightSideLayout.setConstraints(imperialDistancesPanel, imperialDistancesPanelConstraints);
    rightSide.add(imperialDistancesPanel);

    GridBagConstraints metricWeightsConstraints = new GridBagConstraints();
    metricWeightsConstraints.gridx = 0;
    metricWeightsConstraints.gridy = 2;
    metricWeightsConstraints.weighty = 0.6;
    metricWeightsConstraints.weightx = 1;
    metricWeightsConstraints.fill = GridBagConstraints.BOTH;
    metricWeightsConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    MetricWeightsPanel metricWeightsPanel = new MetricWeightsPanel(frame, weights);
    leftSideLayout.setConstraints(metricWeightsPanel, metricWeightsConstraints);
    leftSide.add(metricWeightsPanel);

    GridBagConstraints imperialWeightsConstraints = new GridBagConstraints();
    imperialWeightsConstraints.gridx = 0;
    imperialWeightsConstraints.gridy = 2;
    imperialWeightsConstraints.weighty = 0.6;
    imperialWeightsConstraints.weightx = 1;
    imperialWeightsConstraints.fill = GridBagConstraints.BOTH;
    imperialWeightsConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    ImperialWeightsPanel imperialWeightsPanel = new ImperialWeightsPanel(frame, weights);
    rightSideLayout.setConstraints(imperialWeightsPanel, imperialWeightsConstraints);
    rightSide.add(imperialWeightsPanel);

    CSplit split = new CSplit(JSplitPane.HORIZONTAL_SPLIT, true, leftSide, rightSide);
    Container contentPane = frame.getContentPane();
    contentPane.add(split);
    frame.validate();
    frame.pack();
    frame.setSize(600, 997);
    split.setResizeWeight(0.5);
    split.setDividerLocation(0.5);
  } // end of HappyHackingConverter constructor
Exemplo n.º 12
0
  /** Creates sound level related components. */
  private void createSoundLevelIndicators() {
    TransparentPanel localLevelPanel = new TransparentPanel(new BorderLayout(5, 0));
    TransparentPanel remoteLevelPanel = new TransparentPanel(new BorderLayout(5, 0));

    localLevel =
        new InputVolumeControlButton(
            call, ImageLoader.MICROPHONE, ImageLoader.MUTE_BUTTON, false, false);
    remoteLevel =
        new OutputVolumeControlButton(call.getConference(), ImageLoader.HEADPHONE, false, false)
            .getComponent();

    final SoundLevelIndicator localLevelIndicator =
        new SoundLevelIndicator(SoundLevelChangeEvent.MIN_LEVEL, SoundLevelChangeEvent.MAX_LEVEL);
    final SoundLevelIndicator remoteLevelIndicator =
        new SoundLevelIndicator(SoundLevelChangeEvent.MIN_LEVEL, SoundLevelChangeEvent.MAX_LEVEL);

    localLevelPanel.add(localLevel, BorderLayout.WEST);
    localLevelPanel.add(localLevelIndicator, BorderLayout.CENTER);
    remoteLevelPanel.add(remoteLevel, BorderLayout.WEST);
    remoteLevelPanel.add(remoteLevelIndicator, BorderLayout.CENTER);

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 5;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.insets = new Insets(10, 0, 0, 0);

    add(localLevelPanel, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 6;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.insets = new Insets(5, 0, 10, 0);

    add(remoteLevelPanel, constraints);

    if (!GuiActivator.getConfigurationService()
        .getBoolean(
            "net.java.sip.communicator.impl.gui.main.call." + "DISABLE_SOUND_LEVEL_INDICATORS",
            false)) {
      callPeer.addStreamSoundLevelListener(
          new SoundLevelListener() {
            public void soundLevelChanged(Object source, int level) {
              remoteLevelIndicator.updateSoundLevel(level);
            }
          });
      /*
       * By the time the UI gets to be initialized, the callPeer may have
       * been removed from its Call. As far as the UI is concerned, the
       * callPeer will never have a Call again and there will be no audio
       * levels to display anyway so there is no point in throwing a
       * NullPointerException here.
       */
      if (call != null) {
        call.addLocalUserSoundLevelListener(
            new SoundLevelListener() {
              public void soundLevelChanged(Object source, int level) {
                localLevelIndicator.updateSoundLevel(level);
              }
            });
      }
    }
  }
Exemplo n.º 13
0
  /**
   * Creates a <tt>CallPeerPanel</tt> for the given call peer.
   *
   * @param callRenderer the renderer of the call
   * @param callPeer the <tt>CallPeer</tt> represented in this panel
   * @param uiVideoHandler the facility which is to aid the new instance in the dealing with the
   *     video-related information
   */
  public OneToOneCallPeerPanel(
      SwingCallRenderer callRenderer, CallPeer callPeer, UIVideoHandler2 uiVideoHandler) {
    this.callRenderer = callRenderer;
    this.callPeer = callPeer;
    // we need to obtain call as soon as possible
    // cause if it fails too quickly we may fail to show it
    this.call = callPeer.getCall();
    this.uiVideoHandler = uiVideoHandler;

    peerName = CallManager.getPeerDisplayName(callPeer);
    securityPanel = SecurityPanel.create(this, callPeer, null);

    photoLabel = new JLabel(getPhotoLabelIcon());
    center = createCenter();
    statusBar = createStatusBar();

    setPeerImage(CallManager.getPeerImage(callPeer));

    /* Lay out the main Components of the UI. */
    setLayout(new GridBagLayout());

    GridBagConstraints cnstrnts = new GridBagConstraints();

    if (center != null) {
      cnstrnts.fill = GridBagConstraints.BOTH;
      cnstrnts.gridx = 0;
      cnstrnts.gridy = 1;
      cnstrnts.weightx = 1;
      cnstrnts.weighty = 1;
      add(center, cnstrnts);
    }
    if (statusBar != null) {
      cnstrnts.fill = GridBagConstraints.NONE;
      cnstrnts.gridx = 0;
      cnstrnts.gridy = 3;
      cnstrnts.weightx = 0;
      cnstrnts.weighty = 0;
      cnstrnts.insets = new Insets(5, 0, 0, 0);
      add(statusBar, cnstrnts);
    }

    createSoundLevelIndicators();
    initSecuritySettings();

    /*
     * Add the listeners which will be notified about changes in the model
     * and which will update this view.
     */
    callPeerAdapter = new CallPeerAdapter(callPeer, this);
    uiVideoHandler.addObserver(uiVideoHandlerObserver);

    /*
     * This view adapts to whether it is displayed in full-screen or
     * windowed mode.
     */
    if (callRenderer instanceof Component) {
      ((Component) callRenderer).addPropertyChangeListener(CallContainer.PROP_FULL_SCREEN, this);
    }

    OperationSetDesktopSharingClient desktopSharingClient =
        callPeer.getProtocolProvider().getOperationSet(OperationSetDesktopSharingClient.class);
    if (desktopSharingClient != null) {
      desktopSharingMouseAndKeyboardListener =
          new DesktopSharingMouseAndKeyboardListener(callPeer, desktopSharingClient);
    } else desktopSharingMouseAndKeyboardListener = null;

    updateViewFromModel();
  }