Пример #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;
  }
    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;
    }
 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;
 }
Пример #4
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);
  }
Пример #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);
 }
Пример #6
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();
  }
  /**
   * 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
Пример #8
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);
              }
            });
      }
    }
  }
Пример #9
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();
  }