/** * Adds contact entry labels. * * @param nameLabelGridWidth the grid width of the contact entry name label */ private void addLabels(int nameLabelGridWidth) { remove(nameLabel); remove(rightLabel); remove(displayDetailsLabel); if (treeNode != null && !(treeNode instanceof GroupNode)) constraints.insets = new Insets(0, 0, V_GAP, H_GAP); else constraints.insets = new Insets(0, 0, 0, H_GAP); constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 0; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridheight = 1; constraints.gridwidth = nameLabelGridWidth; this.add(nameLabel, constraints); constraints.anchor = GridBagConstraints.NORTHEAST; constraints.fill = GridBagConstraints.VERTICAL; constraints.gridx = nameLabelGridWidth + 1; constraints.gridy = 0; constraints.gridheight = 3; constraints.weightx = 0f; constraints.weighty = 1f; this.add(rightLabel, constraints); if (treeNode != null && treeNode instanceof ContactNode) { constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridwidth = nameLabelGridWidth; constraints.gridheight = 1; this.add(displayDetailsLabel, constraints); } else if (treeNode != null && treeNode instanceof GroupNode) { constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridwidth = nameLabelGridWidth; constraints.gridheight = 1; this.add(displayDetailsLabel, constraints); } }
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(); }
/** * Initializes the display details component for the given <tt>UIContact</tt>. * * @param displayDetails the display details to show */ private void initDisplayDetails(String displayDetails) { remove(displayDetailsLabel); displayDetailsLabel.setText(""); if (displayDetails != null && displayDetails.length() > 0) { // Replace all occurrences of new line with slash. displayDetails = Html2Text.extractText(displayDetails); displayDetails = displayDetails.replaceAll("\n|<br>|<br/>", " / "); displayDetailsLabel.setText(displayDetails); } constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridwidth = 1; constraints.gridheight = 1; this.add(displayDetailsLabel, constraints); }