private int addButton(SIPCommButton button, int gridX, int xBounds, boolean isLast) {
    lastAddedButton = button;

    constraints.insets = new Insets(0, 0, V_GAP, 0);
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = gridX;
    constraints.gridy = 2;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0f;
    constraints.weighty = 0f;
    this.add(button, constraints);

    int yBounds =
        TOP_BORDER
            + BOTTOM_BORDER
            + 2 * V_GAP
            + ComponentUtils.getStringSize(nameLabel, nameLabel.getText()).height
            + ComponentUtils.getStringSize(displayDetailsLabel, displayDetailsLabel.getText())
                .height;

    button.setBounds(xBounds, yBounds, BUTTON_WIDTH, BUTTON_HEIGHT);

    button.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    setButtonBg(button, gridX, isLast);

    return button.getWidth();
  }
Esempio n. 2
0
 public void actionPerformed(ActionEvent e) {
   texta.setText(
       lblName.getText()
           + text0.getText()
           + '\n'
           + lblSex.getText()
           + ((JRadioButton) e.getSource()).getText());
 }
Esempio n. 3
0
 public void stateChanged(ChangeEvent e) {
   texta.setText(
       lblName.getText()
           + text0.getText()
           + '\n'
           + lblAge.getText()
           + ((JSpinner) e.getSource()).getValue());
 }
Esempio n. 4
0
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    textLabel.setFont(table.getFont());
    textLabel.setText(Objects.toString(value, ""));
    textLabel.setBorder(hasFocus ? focusCellHighlightBorder : noFocusBorder);

    FontMetrics fm = table.getFontMetrics(table.getFont());
    Insets i = textLabel.getInsets();
    int swidth =
        iconLabel.getPreferredSize().width + fm.stringWidth(textLabel.getText()) + i.left + i.right;
    int cwidth = table.getColumnModel().getColumn(column).getWidth();
    dim.width = swidth > cwidth ? cwidth : swidth;

    if (isSelected) {
      textLabel.setOpaque(true);
      textLabel.setForeground(table.getSelectionForeground());
      textLabel.setBackground(table.getSelectionBackground());
      iconLabel.setIcon(sicon);
    } else {
      textLabel.setOpaque(false);
      textLabel.setForeground(table.getForeground());
      textLabel.setBackground(table.getBackground());
      iconLabel.setIcon(nicon);
    }
    return panel;
  }
Esempio n. 5
0
 // Checks to see if you can sell
 private void updateSellButton() {
   if (totalAmount.getText().equalsIgnoreCase("Error")) {
     sellButton.setEnabled(false);
   } else {
     sellButton.setEnabled(true);
   }
 }
 private int getCompressionLevel() {
   String compressionType = selectedCompression.getText();
   if (compressionType.contains("fast")) {
     return ArchiveOutputUtil.LOW_COMPRESSION;
   } else if (compressionType.contains("medium")) {
     return ArchiveOutputUtil.MED_COMPRESSION;
   } else {
     return ArchiveOutputUtil.HIGH_COMPRESSION;
   }
 }
  //  Repaint the message at the new location
  public void paintComponent(Graphics page) {
    // use paintComponent method of its parent class
    // to have all graphics properties
    super.paintComponent(page);

    // change the page color and font
    page.setColor(Color.cyan);
    page.setFont(new Font("TimesRoman", Font.PLAIN, 24));

    page.drawString(message.getText(), (int) (location.getX()), (int) (location.getY()));
  }
 private void resetPanel() {
   cal =
       new GregorianCalendar(
           Integer.parseInt(yearSpi.getValue().toString()),
           monthBox.getSelectedIndex(),
           Integer.parseInt(lastLabel.getText()));
   startPoint_x = 20;
   startPoint_y = 10;
   panel.removeAll();
   panel.repaint();
   initCalPanel();
 }
 public void simpleEllipsify() {
   for (String k : keyValueComponentMap.keySet()) {
     JComponent comp = getComponent(k);
     if (comp instanceof JLabel) {
       JLabel l = (JLabel) comp;
       String s = l.getText();
       if (s.length() > 25) {
         s = s.substring(0, 20) + "...";
       }
       l.setText(s);
     }
   }
 }
Esempio n. 10
0
 private JPanel makeSlider(JLabel label, JSlider slider, JLabel value, String color) {
   JPanel p = new JPanel();
   p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
   label.setDisplayedMnemonic(label.getText().charAt(0));
   label.setLabelFor(slider);
   String tip = color + " color component slider";
   label.setToolTipText(tip);
   slider.setToolTipText(tip);
   value.setToolTipText(tip);
   p.add(label);
   slider.setMaximumSize(new Dimension(128, slider.getMaximumSize().height));
   slider.addChangeListener(this);
   p.add(slider);
   p.add(value);
   return p;
 }
Esempio n. 11
0
    /**
     * Edit row
     *
     * @param paramInfo param info
     * @param removeOnCancel Should remove param info if user presses cancel_
     * @return ok
     */
    public boolean editRow(ParamInfo paramInfo, boolean removeOnCancel) {

      List comps = new ArrayList();
      ParamField nameFld = new ParamField(null, true);
      nameFld.setText(paramInfo.getName());
      JPanel topPanel = GuiUtils.hbox(GuiUtils.lLabel("Parameter:  "), nameFld);
      topPanel = GuiUtils.inset(topPanel, 5);

      comps.add(GuiUtils.inset(new JLabel("Defined"), new Insets(5, 0, 0, 0)));
      comps.add(GuiUtils.filler());
      comps.add(GuiUtils.filler());

      final JLabel ctPreviewLbl = new JLabel("");
      final JLabel ctLbl = new JLabel("");
      if (paramInfo.hasColorTableName()) {
        ctLbl.setText(paramInfo.getColorTableName());
        ColorTable ct =
            getIdv().getColorTableManager().getColorTable(paramInfo.getColorTableName());
        if (ct != null) {
          ctPreviewLbl.setIcon(ColorTableCanvas.getIcon(ct));
        } else {
          ctPreviewLbl.setIcon(null);
        }
      }
      String cbxLabel = "";
      final ArrayList menus = new ArrayList();
      getIdv()
          .getColorTableManager()
          .makeColorTableMenu(
              new ObjectListener(null) {
                public void actionPerformed(ActionEvent ae, Object data) {
                  ctLbl.setText(data.toString());
                  ColorTable ct = getIdv().getColorTableManager().getColorTable(ctLbl.getText());
                  if (ct != null) {
                    ctPreviewLbl.setIcon(ColorTableCanvas.getIcon(ct));
                  } else {
                    ctPreviewLbl.setIcon(null);
                  }
                }
              },
              menus);

      JCheckBox ctUseCbx = new JCheckBox(cbxLabel, paramInfo.hasColorTableName());
      final JButton ctPopup = new JButton("Change");
      ctPopup.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              GuiUtils.showPopupMenu(menus, ctPopup);
            }
          });
      addEditComponents(
          comps,
          "Color Table:",
          ctUseCbx,
          GuiUtils.hbox(ctPopup, GuiUtils.vbox(ctLbl, ctPreviewLbl), 5));

      JCheckBox rangeUseCbx = new JCheckBox(cbxLabel, paramInfo.hasRange());
      JTextField minFld = new JTextField("" + paramInfo.getMin(), 4);
      JTextField maxFld = new JTextField("" + paramInfo.getMax(), 4);
      JPanel rangePanel = GuiUtils.hbox(minFld, maxFld, 5);
      addEditComponents(comps, "Range:", rangeUseCbx, rangePanel);

      JCheckBox unitUseCbx = new JCheckBox(cbxLabel, paramInfo.hasDisplayUnit());
      String unitLabel = "";
      Unit unit = null;
      if (paramInfo.hasDisplayUnit()) {
        unit = paramInfo.getDisplayUnit();
      }

      JComboBox unitFld = getIdv().getDisplayConventions().makeUnitBox(unit, null);
      //            JTextField unitFld = new JTextField(unitLabel, 15);
      addEditComponents(comps, "Unit:", unitUseCbx, unitFld);

      ContourInfo ci = paramInfo.getContourInfo();
      JCheckBox contourUseCbx = new JCheckBox(cbxLabel, ci != null);
      if (ci == null) {
        ci = new ContourInfo();
      }
      ContourInfoDialog contDialog =
          new ContourInfoDialog("Edit Contour Defaults", false, null, false);
      contDialog.setState(ci);
      addEditComponents(comps, "Contour:", contourUseCbx, contDialog.getContents());

      GuiUtils.tmpInsets = new Insets(5, 5, 5, 5);
      JComponent contents = GuiUtils.doLayout(comps, 3, GuiUtils.WT_NNY, GuiUtils.WT_N);

      contents = GuiUtils.topCenter(topPanel, contents);
      contents = GuiUtils.inset(contents, 5);
      while (true) {
        if (!GuiUtils.showOkCancelDialog(null, "Parameter Defaults", contents, null)) {
          if (removeOnCancel) {
            myParamInfos.remove(paramInfo);
            tableChanged();
          }
          return false;
        }
        String what = "";
        try {
          if (contourUseCbx.isSelected()) {
            what = "setting contour defaults";
            contDialog.doApply();
            ci.set(contDialog.getInfo());
            paramInfo.setContourInfo(ci);
          } else {
            paramInfo.clearContourInfo();
          }
          if (unitUseCbx.isSelected()) {
            what = "setting display unit";
            Object selected = unitFld.getSelectedItem();
            String unitName = TwoFacedObject.getIdString(selected);
            if ((unitName == null) || unitName.trim().equals("")) {
              paramInfo.setDisplayUnit(null);
            } else {
              paramInfo.setDisplayUnit(ucar.visad.Util.parseUnit(unitName));
            }
          } else {
            paramInfo.setDisplayUnit(null);
          }

          if (ctUseCbx.isSelected()) {
            paramInfo.setColorTableName(ctLbl.getText());
          } else {
            paramInfo.clearColorTableName();
          }

          if (rangeUseCbx.isSelected()) {
            what = "setting range";
            paramInfo.setRange(
                new Range(Misc.parseNumber(minFld.getText()), Misc.parseNumber(maxFld.getText())));
          } else {
            paramInfo.clearRange();
          }

          paramInfo.setName(nameFld.getText().trim());
          break;
        } catch (Exception exc) {
          errorMsg("An error occurred " + what + "\n " + exc.getMessage());
          //              exc.printStackTrace();
        }
      }
      repaint();
      saveData();
      return true;
    }
Esempio n. 12
0
 @Override
 public String getTipText() {
   return Objects.nonNull(iconlabel) ? iconlabel.getText() : "";
 }
Esempio n. 13
0
 public void actionPerformed(ActionEvent e) {
   String txt = lblInter.getText();
   for (int i = 0; i < check.length; i++)
     if (check[i].isSelected()) txt += check[i].getText();
   texta.setText(lblName.getText() + text0.getText() + '\n' + txt);
 }
Esempio n. 14
0
 public void itemStateChanged(ItemEvent e) {
   texta.setText(
       lblName.getText() + text0.getText() + '\n' + lblAcad.getText() + e.getItem());
 }
Esempio n. 15
0
 //     @Override public Dimension getPreferredSize() {
 //         Insets i = getInsets();
 //         Dimension d = iconlabel.getPreferredSize();
 //         d.width  += i.left + i.right;
 //         d.height += i.top + i.bottom;
 //         return d;
 //     }
 @Override
 public void setTipText(final String tipText) {
   String oldValue = iconlabel.getText();
   iconlabel.setText(tipText);
   firePropertyChange("tiptext", oldValue, tipText);
 }
Esempio n. 16
0
 public void valueChanged(ListSelectionEvent e) {
   Object[] values = ((JList) e.getSource()).getSelectedValues();
   String txtItem = "";
   for (int i = 0; i < values.length; i++) txtItem += values[i].toString();
   texta.setText(lblName.getText() + text0.getText() + '\n' + lblPlace.getText() + txtItem);
 }
Esempio n. 17
0
 public void actionPerformed(ActionEvent e) {
   texta.setText(lblName.getText() + text0.getText());
 }
Esempio n. 18
0
 public String getLabelText() {
   return label.getText();
 }
Esempio n. 19
0
 /**
  * Prints the given DTMG character through this <tt>CallPeerRenderer</tt>.
  *
  * @param dtmfChar the DTMF char to print
  */
 public void printDTMFTone(char dtmfChar) {
   dtmfLabel.setText(dtmfLabel.getText() + dtmfChar);
   if (dtmfLabel.getBorder() == null)
     dtmfLabel.setBorder(BorderFactory.createEmptyBorder(2, 1, 2, 5));
 }
Esempio n. 20
0
 public String getFriendLabel() {
   return peopleLabel.getText();
 }
Esempio n. 21
0
 /**
  * A helper function that obtains the total number of hours for the selected period.
  *
  * @return Total number of hours.
  * @throws InsufficientDataException Thrown if the total is zero.
  */
 private double checkTotal() throws InsufficientDataException {
   double total = Double.parseDouble(totalLabel.getText());
   if (total == 0) throw new InsufficientDataException("Cannot submit data with no logged hours.");
   return total;
 }
Esempio n. 22
0
 /**
  * Appen to the message label text
  *
  * @param msg The text to append
  */
 public void appendMessage(String msg) {
   msgLabel1.setText(msgLabel1.getText() + msg);
 }
Esempio n. 23
0
 public String toString() {
   return who.getText();
 }
  /** 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);
    }
  }