コード例 #1
0
ファイル: Example1.java プロジェクト: RWTH-OS/MP-MPICH
  /**
   * And now for a little assembly. Put together the buttons, progress bar and status text field.
   */
  Example1(String name) {
    setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), name));

    progressBar.setMaximum(NUMLOOPS);

    startButton = new JButton("Start");
    startButton.addActionListener(startListener);
    startButton.setEnabled(true);

    interruptButton = new JButton("Cancel");
    interruptButton.addActionListener(interruptListener);
    interruptButton.setEnabled(false);

    JComponent buttonBox = new JPanel();
    buttonBox.add(startButton);
    buttonBox.add(interruptButton);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    add(buttonBox);
    add(progressBar);
    add(statusField);
    statusField.setAlignmentX(CENTER_ALIGNMENT);

    buttonBox.setBorder(spaceBelow);
    Border pbBorder = progressBar.getBorder();
    progressBar.setBorder(BorderFactory.createCompoundBorder(spaceBelow, pbBorder));
  }
コード例 #2
0
  private void addField(OptionField field) {
    // Add label
    JLabel l = new JLabel(field.getDisplayName() + ":");
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = currentRow;
    c.insets = new Insets(5, 2, 2, 2);
    c.anchor = GridBagConstraints.NORTHWEST;
    content.add(l, c);

    // Add enable checkbox
    if (field.getEnableToggle() != null) {
      c = new GridBagConstraints();
      c.gridx = 1;
      c.gridy = currentRow;
      c.fill = GridBagConstraints.BOTH;
      c.insets = new Insets(2, 2, 2, 2);
      c.anchor = GridBagConstraints.NORTHWEST;
      content.add(field.getEnableToggle(), c);
    }

    // Add field
    c = new GridBagConstraints();
    c.gridx = 2;
    c.gridy = currentRow;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(2, 2, 2, 2);
    c.anchor = GridBagConstraints.NORTHWEST;
    content.add(field.getComponent(), c);

    // Add change listener
    field.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            fireChangeEvent();
          }
        });

    // Update state
    currentRow++;
    pack();
  }
コード例 #3
0
ファイル: LockableDemo.java プロジェクト: rolfdeboer/navajo
 private JComponent createLayerPanel() {
   JComponent panel = new JPanel();
   panel.add(new JCheckBox("JCheckBox"));
   panel.add(new JRadioButton("JRadioButton"));
   panel.add(new JTextField(15));
   JButton button = new JButton("Have a nice day");
   button.setMnemonic('H');
   button.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           logger.info("LockableLayerDemo.actionPerformed");
         }
       });
   panel.add(button);
   panel.add(new JTextField(15));
   panel.add(new JCheckBox("JCheckBox"));
   panel.add(new JRadioButton("JRadioButton"));
   panel.add(new JTextField(15));
   panel.add(new JCheckBox("JCheckBox"));
   panel.add(new JRadioButton("JRadioButton"));
   panel.setBorder(BorderFactory.createEtchedBorder());
   return panel;
 }
コード例 #4
0
  @Override
  protected JComponent createChangePanel() {
    final JComponent primaryPanel = new JPanel(new BorderLayout());
    JComponent propertyPanel = new JPanel(new BorderLayout());
    JComponent nameAndRandomizePanel = new JPanel(new BorderLayout());
    JComponent propertySetterPanel = createPropertyPanel();
    JComponent centerPanel = createCenterPanel();
    if (canRandomize) {
      shouldRandomizeCheckBox = new JCheckBox();
      shouldRandomizeCheckBox.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              shouldRandomize = shouldRandomizeCheckBox.isSelected();
            }
          });
      nameAndRandomizePanel.add(shouldRandomizeCheckBox, BorderLayout.LINE_START);
      final MouseListener unrandomizer =
          new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
              if (e.getComponent().contains(e.getPoint())
                  && !shouldRandomizeCheckBox.contains(e.getPoint())) {
                shouldRandomizeCheckBox.setSelected(false);
                shouldRandomize = false;
              } else {
                System.out.println(e.getPoint() + "Is out of bounds");
              }
            }
          };
      ContainerListener mouseListenerAdder =
          new ContainerAdapter() {
            @Override
            public void componentAdded(ContainerEvent e) {
              addListeners(e.getChild());
            }

            public void addListeners(Component c) {
              c.addMouseListener(unrandomizer);
              if (c instanceof Container) {
                ((Container) c).addContainerListener(this);
                for (Component child : ((Container) c).getComponents()) {
                  addListeners(child);
                }
              }
            }
          };
      primaryPanel.addMouseListener(unrandomizer);
      primaryPanel.addContainerListener(mouseListenerAdder);
    }
    if (centerPanel != null) primaryPanel.add(centerPanel, BorderLayout.CENTER);
    nameAndRandomizePanel.add(new JLabel(name), BorderLayout.CENTER);
    propertyPanel.add(nameAndRandomizePanel, BorderLayout.LINE_START);
    propertyPanel.add(propertySetterPanel, BorderLayout.LINE_END);
    primaryPanel.add(propertyPanel, BorderLayout.PAGE_START);
    return primaryPanel;
  }
コード例 #5
0
  /**
   * Creates preview for the device(video) in the video container.
   *
   * @param device the device
   * @param videoContainer the container
   * @throws IOException a problem accessing the device.
   * @throws MediaException a problem getting preview.
   */
  private static void createPreview(MediaDevice device, final JComponent videoContainer)
      throws IOException, MediaException {
    videoContainer.removeAll();

    videoContainer.revalidate();
    videoContainer.repaint();

    if (device == null) return;

    Component c =
        (Component)
            GuiActivator.getMediaService()
                .getVideoPreviewComponent(
                    device, videoContainer.getSize().width, videoContainer.getSize().height);

    videoContainer.add(c);
  }
コード例 #6
0
  /**
   * Constructs a popup using the specified settings.
   *
   * @param content The component that represents the popup content.
   * @param hideOnClick If <code>true</code> then the popup will hide when any area outside of it is
   *     clicked (rather like a popup menu). If <code>false</code> the popup will not hide when any
   *     area outside of it is clicked.
   * @param timerDelay The number of milliseconds after which the the popup will automatically hide
   *     itself. If a value of zero is specified, then the popup will remain displayed indefinitely.
   * @param isModal If <code>true</code>, mouse listener events that occur outside the component
   *     area are forwarded to the appropriate component in the content pane i.e other components
   *     may be interacted with whilst the popup is displayed. If <code>false</code> then the popup
   *     behaves rather like a modal dialog, so that no other components can receive mouse events
   *     until the component has closed.
   */
  public PopupComponent(JComponent content, boolean hideOnClick, int timerDelay, boolean isModal) {
    glassPane = new JPanel(null);

    glassPane.setLayout(null);

    glassPane.add(content);

    glassPane.setOpaque(false);

    listeners = new ArrayList<PopupComponentListener>();

    setupListeners();

    setContent(content);

    this.HIDE_ON_CLICK = hideOnClick;

    this.POPUP_IS_MODAL = isModal;

    // Check to see if a timer delay has been
    // specified.  If so, set up the timer.
    if (timerDelay > 0) {
      HIDE_ON_TIMER = true;

      HIDE_TIMER_DELAY = timerDelay;

      timer =
          new Timer(
              HIDE_TIMER_DELAY,
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  // Hide the popup if the mouse is outside
                  // the content
                  if (mouseOverGlassPane == true) {
                    hidePopup();

                    timer.stop();
                  } else {
                    timer.stop();

                    timer.start();
                  }
                }
              });
    }
  }
コード例 #7
0
  /**
   * Sets the content that the popup displays
   *
   * @param content A JComponent that represents the content to be displayed.
   */
  public void setContent(JComponent content) {
    if (content == null) {
      throw new NullPointerException("Popup content must not be null");
    }

    // Remove the previous popup content
    if (this.content != null) {
      glassPane.remove(this.content);
    }

    // Set this content to the new content
    this.content = content;

    // Set the size of the content
    this.content.setSize(this.content.getPreferredSize());

    // Put the content into the glass pane
    glassPane.add(this.content);
  }
コード例 #8
0
ファイル: LockableDemo.java プロジェクト: rolfdeboer/navajo
 private JComponent createToolPanel() {
   JComponent box = Box.createVerticalBox();
   JCheckBox button = new JCheckBox(disablingItem.getText());
   button.setModel(disablingItem.getModel());
   box.add(Box.createGlue());
   box.add(button);
   box.add(Box.createGlue());
   JRadioButton blur = new JRadioButton(blurItem.getText());
   blur.setModel(blurItem.getModel());
   box.add(blur);
   JRadioButton emboss = new JRadioButton(embossItem.getText());
   emboss.setModel(embossItem.getModel());
   box.add(emboss);
   JRadioButton translucent = new JRadioButton(busyPainterItem.getText());
   translucent.setModel(busyPainterItem.getModel());
   box.add(translucent);
   box.add(Box.createGlue());
   return box;
 }
コード例 #9
0
  private void addSeparator(String label) {
    JPanel p = new JPanel(new GridBagLayout());
    GridBagConstraints c;

    if (label != null) {
      // left border
      c = new GridBagConstraints();
      c.gridy = 0;
      c.ipadx = 15; // half the desired width
      p.add(new JSeparator(), c);

      // label
      c = new GridBagConstraints();
      c.gridy = 0;
      c.insets = new Insets(0, 4, 0, 4);
      p.add(new JLabel(label), c);
    }

    // right border
    c = new GridBagConstraints();
    c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    p.add(new JSeparator(), c);

    // add to window
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = currentRow++;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.HORIZONTAL;
    if (label == null) {
      // simple separator between predicate name and options; don't use
      // pronounced section break
      c.insets = new Insets(3, 0, 3, 0);
    } else {
      c.insets = new Insets(10, 0, 0, 0);
    }
    content.add(p, c);
  }
コード例 #10
0
ファイル: MediaConfiguration.java プロジェクト: onsip/jitsi
  /**
   * Creates preview for the (video) device in the video container.
   *
   * @param device the device
   * @param videoContainer the video container
   * @throws IOException a problem accessing the device
   * @throws MediaException a problem getting preview
   */
  private static void createVideoPreview(CaptureDeviceInfo device, JComponent videoContainer)
      throws IOException, MediaException {
    videoContainer.removeAll();

    videoContainer.revalidate();
    videoContainer.repaint();

    if (device == null) return;

    for (MediaDevice mediaDevice : mediaService.getDevices(MediaType.VIDEO, MediaUseCase.ANY)) {
      if (((MediaDeviceImpl) mediaDevice).getCaptureDeviceInfo().equals(device)) {
        Dimension videoContainerSize = videoContainer.getPreferredSize();
        Component preview =
            (Component)
                mediaService.getVideoPreviewComponent(
                    mediaDevice, videoContainerSize.width, videoContainerSize.height);

        if (preview != null) videoContainer.add(preview);
        break;
      }
    }
  }
コード例 #11
0
ファイル: JSheet.java プロジェクト: karlvr/Quaqua
  private static JSheet createSheet(final JOptionPane pane, Component parentComponent, int style) {
    Window window = getWindowForComponent(parentComponent);
    final JSheet sheet;
    if (window instanceof Frame) {
      sheet = new JSheet((Frame) window);
    } else {
      sheet = new JSheet((Dialog) window);
    }

    JComponent contentPane = (JComponent) sheet.getContentPane();
    contentPane.setLayout(new BorderLayout());

    if (isNativeSheetSupported()) {
      contentPane.setBorder(new EmptyBorder(12, 0, 0, 0));
    }

    contentPane.add(pane, BorderLayout.CENTER);
    sheet.setResizable(false);
    sheet.addWindowListener(
        new WindowAdapter() {

          private boolean gotFocus = false;

          @Override
          public void windowClosing(WindowEvent we) {
            pane.setValue(null);
          }

          @Override
          public void windowClosed(WindowEvent we) {
            if (pane.getValue() == JOptionPane.UNINITIALIZED_VALUE) {
              sheet.fireOptionSelected(pane);
            }
          }

          @Override
          public void windowGainedFocus(WindowEvent we) {
            // Once window gets focus, set initial focus
            if (!gotFocus) {
              // Ugly dirty hack: JOptionPane.selectInitialValue() is protected.
              // So we call directly into the UI. This may cause mayhem,
              // because we override the encapsulation.
              // pane.selectInitialValue();
              OptionPaneUI ui = pane.getUI();
              if (ui != null) {
                ui.selectInitialValue(pane);
              }
              gotFocus = true;
            }
          }
        });
    sheet.addComponentListener(
        new ComponentAdapter() {

          @Override
          public void componentShown(ComponentEvent ce) {
            // reset value to ensure closing works properly
            pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
          }
        });
    pane.addPropertyChangeListener(
        new PropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent event) {
            // Let the defaultCloseOperation handle the closing
            // if the user closed the window without selecting a button
            // (newValue = null in that case).  Otherwise, close the sheet.
            if (sheet.isVisible()
                && event.getSource() == pane
                && (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY))
                && event.getNewValue() != null
                && event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) {
              sheet.setVisible(false);
              sheet.fireOptionSelected(pane);
            }
          }
        });
    sheet.pack();
    return sheet;
  }
コード例 #12
0
  public AboutDialog(JConsole jConsole) {
    super(jConsole, Resources.getText("Help.AboutDialog.title"), false);

    setAccessibleDescription(this, getText("Help.AboutDialog.accessibleDescription"));
    setDefaultCloseOperation(HIDE_ON_CLOSE);
    setResizable(false);
    JComponent cp = (JComponent) getContentPane();

    createActions();

    JLabel mastheadLabel = new JLabel(mastheadIcon);
    setAccessibleName(mastheadLabel, getText("Help.AboutDialog.masthead.accessibleName"));

    JPanel mainPanel = new TPanel(0, 0);
    mainPanel.add(mastheadLabel, NORTH);

    String jConsoleVersion = Version.getVersion();
    String vmName = System.getProperty("java.vm.name");
    String vmVersion = System.getProperty("java.vm.version");
    String urlStr = getText("Help.AboutDialog.userGuideLink.url");
    if (isBrowseSupported()) {
      urlStr = "<a style='color:#35556b' href=\"" + urlStr + "\">" + urlStr + "</a>";
    }

    JPanel infoAndLogoPanel = new JPanel(new BorderLayout(10, 10));
    infoAndLogoPanel.setBackground(bgColor);

    String colorStr = String.format("%06x", textColor.getRGB() & 0xFFFFFF);
    JEditorPane helpLink =
        new JEditorPane(
            "text/html",
            "<html><font color=#"
                + colorStr
                + ">"
                + getText("Help.AboutDialog.jConsoleVersion", jConsoleVersion)
                + "<p>"
                + getText("Help.AboutDialog.javaVersion", (vmName + ", " + vmVersion))
                + "<p>"
                + getText("Help.AboutDialog.userGuideLink", urlStr)
                + "</html>");
    helpLink.setOpaque(false);
    helpLink.setEditable(false);
    helpLink.setForeground(textColor);
    mainPanel.setBorder(BorderFactory.createLineBorder(borderColor));
    infoAndLogoPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    helpLink.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              browse(e.getDescription());
            }
          }
        });
    infoAndLogoPanel.add(helpLink, NORTH);

    ImageIcon brandLogoIcon = new ImageIcon(getClass().getResource("resources/brandlogo.png"));
    JLabel brandLogo = new JLabel(brandLogoIcon, JLabel.LEADING);

    JButton closeButton = new JButton(closeAction);

    JPanel bottomPanel = new TPanel(0, 0);
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    buttonPanel.setOpaque(false);

    mainPanel.add(infoAndLogoPanel, CENTER);
    cp.add(bottomPanel, SOUTH);

    infoAndLogoPanel.add(brandLogo, SOUTH);

    buttonPanel.setBorder(new EmptyBorder(2, 12, 2, 12));
    buttonPanel.add(closeButton);
    bottomPanel.add(buttonPanel, NORTH);

    statusBar = new JLabel(" ");
    bottomPanel.add(statusBar, SOUTH);

    cp.add(mainPanel, NORTH);

    pack();
    setLocationRelativeTo(jConsole);
    Utilities.updateTransparency(this);
  }
コード例 #13
0
  /** Loads the configuration form obtained from the chat room. */
  protected void loadConfigurationForm() {
    Iterator<ChatRoomConfigurationFormField> configurationSet = configForm.getConfigurationSet();

    while (configurationSet.hasNext()) {
      ChatRoomConfigurationFormField formField = configurationSet.next();

      Iterator<?> values = formField.getValues();
      Iterator<String> options = formField.getOptions();

      JComponent field;
      JLabel label = new JLabel("", JLabel.RIGHT);

      if (formField.getLabel() != null) label.setText(formField.getLabel() + ": ");

      String fieldType = formField.getType();

      if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_BOOLEAN)) {
        // Create a check box when the field is of type boolean.
        field = new SIPCommCheckBox(formField.getLabel());
        label.setText("");

        if (values.hasNext()) {
          ((JCheckBox) field).setSelected((Boolean) values.next());
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) {
        field = new JLabel();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JLabel) field).setText(value);
          field.setFont(new Font(null, Font.ITALIC, 10));
          field.setForeground(Color.GRAY);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_LIST_MULTI)) {
        field = new TransparentPanel(new GridLayout(0, 1));

        field.setBorder(BorderFactory.createLineBorder(Color.GRAY));

        Hashtable<Object, JCheckBox> optionCheckBoxes = new Hashtable<Object, JCheckBox>();

        while (options.hasNext()) {
          Object option = options.next();
          JCheckBox checkBox = new SIPCommCheckBox(option.toString());

          field.add(checkBox);
          optionCheckBoxes.put(option, checkBox);
        }

        while (values.hasNext()) {
          Object value = values.next();

          (optionCheckBoxes.get(value)).setSelected(true);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_LIST_SINGLE)) {
        field = new JComboBox();

        while (options.hasNext()) {
          ((JComboBox) field).addItem(options.next());
        }

        if (values.hasNext()) {
          ((JComboBox) field).setSelectedItem(values.next());
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_MULTI)) {
        field = new JEditorPane();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JEditorPane) field).setText(value);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_SINGLE)
          || fieldType.equals(ChatRoomConfigurationFormField.TYPE_ID_SINGLE)) {
        field = new JTextField();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JTextField) field).setText(value);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_PRIVATE)) {
        field = new JPasswordField();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JPasswordField) field).setText(value);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_ID_MULTI)) {
        StringBuffer buff = new StringBuffer();

        while (values.hasNext()) {
          String value = values.next().toString();
          buff.append(value);

          if (values.hasNext()) buff.append(System.getProperty("line.separator"));
        }
        field = new JTextArea(buff.toString());
      } else {
        if (label.getText() == null) continue;

        field = new JTextField();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JTextField) field).setText(value);
        }
      }

      // If the field is not fixed (i.e. could be changed) we would like
      // to save it in a list in order to use it later when user saves
      // the configuration data.
      if (!fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) {
        uiFieldsTable.put(formField.getName(), field);
      }

      JPanel fieldPanel = new TransparentPanel(new GridLayout(1, 2));
      fieldPanel.setOpaque(false);

      if (!(field instanceof JLabel))
        fieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
      else fieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0));

      fieldPanel.add(label);
      fieldPanel.add(field);

      this.mainPanel.add(fieldPanel);
    }
  }
コード例 #14
0
  public BundleOptionsFrame(String displayName, String instanceName, List<OptionGroup> options) {
    setResizable(false);
    this.displayName = displayName;
    content = (JComponent) getContentPane();
    content.setLayout(new GridBagLayout());

    final BundleOptionsFrame frame = this;

    // Close button
    Action closeAction =
        new AbstractAction("Close") {
          @Override
          public void actionPerformed(ActionEvent e) {
            frame.setVisible(false);
          }
        };
    JButton close_button = new JButton(closeAction);
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = currentRow++;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(2, 2, 2, 2);
    content.add(close_button, c);

    // Escape key binding
    JComponent root = frame.getRootPane();
    root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
    root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke("ctrl W"), "close");
    root.getActionMap().put("close", closeAction);

    if (instanceName != null) {
      // Predicate name
      StringOption opt = new StringOption();
      opt.setDisplayName("Predicate name");
      opt.setDefault(instanceName);
      instanceNameField = new StringField(opt);
      instanceNameField.addChangeListener(
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              updateTitle();
            }
          });
      addField(instanceNameField);
      JTextField tf = (JTextField) instanceNameField.getComponent();
      tf.selectAll();
      tf.requestFocusInWindow();
    } else {
      // We're a codec; no instance name
      instanceNameField = null;
    }
    updateTitle();

    // Options
    ExampleField example = null;
    for (OptionGroup group : options) {
      addSeparator(group.getDisplayName());
      for (Option option : group.getOptions()) {
        OptionField field;
        if (option instanceof BooleanOption) {
          field = new BooleanField((BooleanOption) option);
        } else if (option instanceof StringOption) {
          field = new StringField((StringOption) option);
        } else if (option instanceof NumberOption) {
          field = new NumberField((NumberOption) option);
        } else if (option instanceof ChoiceOption) {
          field = new ChoiceField((ChoiceOption) option);
        } else if (option instanceof ExampleOption) {
          if (example != null) {
            throw new IllegalArgumentException("Cannot display more than one ExampleOption");
          }
          example = new ExampleField((ExampleOption) option);
          field = example;
        } else {
          throw new IllegalArgumentException("Unknown option type");
        }
        addField(field);
        optionFields.add(field);
      }
    }
    this.exampleField = example;

    pack();
  }
コード例 #15
0
ファイル: PanelSupport.java プロジェクト: bihai/net2java
 public void setParent(JComponent c) {
   Container oldParent = this.getParent();
   oldParent.remove(this);
   c.add(this);
   // System.out.println("Switched parents from " + oldParent + " to " + c);
 }
コード例 #16
0
ファイル: MediaConfiguration.java プロジェクト: onsip/jitsi
  /**
   * Creates the UI controls which are to control the details of a specific <tt>AudioSystem</tt>.
   *
   * @param audioSystem the <tt>AudioSystem</tt> for which the UI controls to control its details
   *     are to be created
   * @param container the <tt>JComponent</tt> into which the UI controls which are to control the
   *     details of the specified <tt>audioSystem</tt> are to be added
   */
  public static void createAudioSystemControls(AudioSystem audioSystem, JComponent container) {
    GridBagConstraints constraints = new GridBagConstraints();

    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weighty = 0;

    int audioSystemFeatures = audioSystem.getFeatures();
    boolean featureNotifyAndPlaybackDevices =
        ((audioSystemFeatures & AudioSystem.FEATURE_NOTIFY_AND_PLAYBACK_DEVICES) != 0);

    constraints.gridx = 0;
    constraints.insets = new Insets(3, 0, 3, 3);
    constraints.weightx = 0;

    constraints.gridy = 0;
    container.add(
        new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_CAPTURE)), constraints);
    if (featureNotifyAndPlaybackDevices) {
      constraints.gridy = 2;
      container.add(
          new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_PLAYBACK)), constraints);
      constraints.gridy = 3;
      container.add(
          new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_NOTIFY)), constraints);
    }

    constraints.gridx = 1;
    constraints.insets = new Insets(3, 3, 3, 0);
    constraints.weightx = 1;

    JComboBox captureCombo = null;

    if (featureNotifyAndPlaybackDevices) {
      captureCombo = new JComboBox();
      captureCombo.setEditable(false);
      captureCombo.setModel(
          new DeviceConfigurationComboBoxModel(
              captureCombo,
              mediaService.getDeviceConfiguration(),
              DeviceConfigurationComboBoxModel.AUDIO_CAPTURE));
      constraints.gridy = 0;
      container.add(captureCombo, constraints);
    }

    int anchor = constraints.anchor;
    SoundLevelIndicator capturePreview =
        new SoundLevelIndicator(
            SimpleAudioLevelListener.MIN_LEVEL, SimpleAudioLevelListener.MAX_LEVEL);

    constraints.anchor = GridBagConstraints.CENTER;
    constraints.gridy = (captureCombo == null) ? 0 : 1;
    container.add(capturePreview, constraints);
    constraints.anchor = anchor;

    constraints.gridy = GridBagConstraints.RELATIVE;

    if (featureNotifyAndPlaybackDevices) {
      JComboBox playbackCombo = new JComboBox();

      playbackCombo.setEditable(false);
      playbackCombo.setModel(
          new DeviceConfigurationComboBoxModel(
              captureCombo,
              mediaService.getDeviceConfiguration(),
              DeviceConfigurationComboBoxModel.AUDIO_PLAYBACK));
      container.add(playbackCombo, constraints);

      JComboBox notifyCombo = new JComboBox();

      notifyCombo.setEditable(false);
      notifyCombo.setModel(
          new DeviceConfigurationComboBoxModel(
              captureCombo,
              mediaService.getDeviceConfiguration(),
              DeviceConfigurationComboBoxModel.AUDIO_NOTIFY));
      container.add(notifyCombo, constraints);
    }

    if ((AudioSystem.FEATURE_ECHO_CANCELLATION & audioSystemFeatures) != 0) {
      final SIPCommCheckBox echoCancelCheckBox =
          new SIPCommCheckBox(
              NeomediaActivator.getResources().getI18NString("impl.media.configform.ECHOCANCEL"));

      /*
       * First set the selected one, then add the listener in order to
       * avoid saving the value when using the default one and only
       * showing to user without modification.
       */
      echoCancelCheckBox.setSelected(mediaService.getDeviceConfiguration().isEchoCancel());
      echoCancelCheckBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              mediaService.getDeviceConfiguration().setEchoCancel(echoCancelCheckBox.isSelected());
            }
          });
      container.add(echoCancelCheckBox, constraints);
    }

    if ((AudioSystem.FEATURE_DENOISE & audioSystemFeatures) != 0) {
      final SIPCommCheckBox denoiseCheckBox =
          new SIPCommCheckBox(
              NeomediaActivator.getResources().getI18NString("impl.media.configform.DENOISE"));

      /*
       * First set the selected one, then add the listener in order to
       * avoid saving the value when using the default one and only
       * showing to user without modification.
       */
      denoiseCheckBox.setSelected(mediaService.getDeviceConfiguration().isDenoise());
      denoiseCheckBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              mediaService.getDeviceConfiguration().setDenoise(denoiseCheckBox.isSelected());
            }
          });
      container.add(denoiseCheckBox, constraints);
    }

    createAudioPreview(audioSystem, captureCombo, capturePreview);
  }
コード例 #17
0
ファイル: JPopupMenu.java プロジェクト: benzonico/ruling_java
 /**
  * Appends the specified menu item to the end of this menu.
  *
  * @param menuItem the <code>JMenuItem</code> to add
  * @return the <code>JMenuItem</code> added
  */
 public JMenuItem add(JMenuItem menuItem) {
   super.add(menuItem);
   return menuItem;
 }
コード例 #18
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
  protected void dolayout(String strDir, String strFreq, String strTraynum) {
    // TopBar
    String strTitle = gettitle(strFreq);
    Color color = DisplayOptions.getColor("Heading3");

    // Center Panel
    JPanel panelCenter = new JPanel(new GridBagLayout());
    GridBagConstraints gbc =
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.2,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0);
    ImageIcon icon = getImageIcon();
    // panelCenter.add(new JLabel(icon));
    addComp(panelCenter, new JLabel(icon), gbc, 0, 0);
    strTitle = getSampleName(strDir, strTraynum);
    m_lblSampleName = new JLabel(strTitle);
    if (strTitle == null || !strTitle.trim().equals("")) strTitle = "3";
    Font font = m_lblSampleName.getFont();
    font = DisplayOptions.getFont(font.getName(), Font.BOLD, 300);
    m_lblSampleName.setFont(font);
    m_lblSampleName.setForeground(color);
    // panelCenter.add(m_lblSampleName);
    m_pnlSampleName = new JPanel(new CardLayout());
    m_pnlSampleName.add(m_lblSampleName, OTHER);
    addComp(panelCenter, m_pnlSampleName, gbc, 1, 0);
    m_pnlSampleName.setVisible(false);
    m_pnlTrays = new JPanel(new GridLayout(1, 0));
    // Vast panels
    VBox pnlVast1 = new VBox(m_pnlTrays, "1");
    m_pnlTrays.add(pnlVast1);
    m_pnlVast[0] = pnlVast1;
    VBox pnlVast2 = new VBox(m_pnlTrays, "2");
    m_pnlTrays.add(pnlVast2);
    m_pnlVast[1] = pnlVast2;
    VBox pnlVast3 = new VBox(m_pnlTrays, "3");
    m_pnlTrays.add(pnlVast3);
    m_pnlVast[2] = pnlVast3;
    VBox pnlVast4 = new VBox(m_pnlTrays, "4");
    m_pnlTrays.add(pnlVast4);
    m_pnlVast[3] = pnlVast4;
    VBox pnlVast5 = new VBox(m_pnlTrays, "5");
    m_pnlTrays.add(pnlVast5);
    m_pnlVast[4] = pnlVast5;
    m_pnlSampleName.add(m_pnlTrays, VAST);

    // Login Panel
    JPanel panelThird = new JPanel(new BorderLayout());
    JPanel panelLogin = new JPanel(new GridBagLayout());
    gbc = new GridBagConstraints();
    panelThird.add(panelLogin);
    Object[] aStrUser = getOperators();
    m_cmbUser = new JComboBox(aStrUser);
    BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();
    m_cmbUser.setRenderer(renderer);
    m_cmbUser.setEditable(true);
    m_passwordField = new JPasswordField();
    // *Warning, working around a Java problem*
    // When we went to the T3500 running Redhat 5.3, the JPasswordField
    // fields sometimes does not allow ANY entry of characters.  Setting
    // the enableInputMethods() to true fixed this problem.  There are
    // comments that indicate that this could cause the typed characters
    // to be visible.  I have not found that to be a problem.
    // This may not be required in the future, or could cause characters
    // to become visible in the future if Java changes it's code.
    // GRS  8/20/09
    m_passwordField.enableInputMethods(true);

    m_lblLogin = new VLoginLabel(null, "Incorrect username/password \n Please try again ", 0, 0);
    m_lblLogin.setVisible(false);
    okButton.setActionCommand("enter");
    okButton.addActionListener(this);
    cancelButton.setActionCommand("cancel");
    cancelButton.addActionListener(this);
    helpButton.setActionCommand("help");
    helpButton.addActionListener(this);
    m_passwordField.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) enterLogin();
          }
        });

    // These is some wierd problem such that sometimes, the vnmrj command
    // area gets the focus and these items in the login box do not get
    // the focus.  Even clicking in these items does not bring focus to
    // them.  Issuing requestFocus() does not bring focus to them.
    // I can however, determing if either the operator entry box or
    // the password box has focus and if neither does, I can unshow and
    // reshow the panel and that fixes the focus.  So, I have added this
    // to the mouseClicked action.  If neither has focus, it will
    // take focus with setVisible false then true.
    comboTextField = m_cmbUser.getEditor().getEditorComponent();
    m_passwordField.addMouseListener(this);
    comboTextField.addMouseListener(this);

    m_lblUsername = new JLabel(Util.getLabel("_Operator"));
    addComp(panelLogin, m_lblUsername, gbc, 0, 0);
    addComp(panelLogin, m_cmbUser, gbc, 1, 0);
    m_lblPassword = new JLabel(Util.getLabel("_Password"));
    addComp(panelLogin, m_lblPassword, gbc, 0, 1);
    addComp(panelLogin, m_passwordField, gbc, 1, 1);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = GridBagConstraints.REMAINDER;
    addComp(panelLogin, m_lblLogin, gbc, 2, 0);
    setPref();

    Container container = getContentPane();
    JPanel panelLoginBox = new JPanel(new BorderLayout());
    panelLoginBox.add(panelCenter, BorderLayout.CENTER);
    panelLoginBox.add(panelThird, BorderLayout.SOUTH);
    container.add(panelLoginBox, BorderLayout.CENTER);
  }