Java Code Examples for com.intellij.ui.components.JBLabel#setFont()

The following examples show how to use com.intellij.ui.components.JBLabel#setFont() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UsageViewImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void addButtonAction(int index, @Nonnull Action action) {
  JButton button = new JButton(action);
  add(button, index);
  DialogUtil.registerMnemonic(button);

  if (getBorder() == null) setBorder(IdeBorderFactory.createBorder(SideBorder.TOP));
  update();
  Object s = action.getValue(Action.LONG_DESCRIPTION);
  if (s instanceof String) {
    JBLabel label = new JBLabel((String)s);
    label.setEnabled(false);
    label.setFont(JBUI.Fonts.smallFont());
    add(JBUI.Borders.emptyLeft(-1).wrap(label));
  }
  s = action.getValue(Action.SHORT_DESCRIPTION);
  if (s instanceof String) {
    button.setToolTipText((String)s);
  }
  invalidate();
  if (getParent() != null) {
    getParent().validate();
  }
}
 
Example 2
Source File: EarlyAccessProgramConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static JComponent createWarningPanel() {
  VerticalLayoutPanel panel = JBUI.Panels.verticalPanel();
  panel.setBackground(LightColors.RED);
  panel.setBorder(new CompoundBorder(JBUI.Borders.customLine(JBColor.GRAY), JBUI.Borders.empty(5)));

  JBLabel warnLabel = new JBLabel("WARNING", AllIcons.General.BalloonWarning, SwingConstants.LEFT);
  warnLabel.setFont(UIUtil.getFont(UIUtil.FontSize.BIGGER, warnLabel.getFont()).deriveFont(Font.BOLD));
  panel.addComponent(warnLabel);
  JTextArea textArea = new JTextArea(IdeBundle.message("eap.configurable.warning.text"));
  textArea.setLineWrap(true);
  textArea.setFont(JBUI.Fonts.label());
  textArea.setOpaque(false);
  textArea.setEditable(false);
  panel.addComponent(textArea);
  return panel;
}
 
Example 3
Source File: Switcher.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private static JPanel createTopPanel(@Nonnull JBCheckBox showOnlyEditedFilesCheckBox, @Nonnull String title, boolean isMovable) {
  JPanel topPanel = new CaptionPanel();
  JBLabel titleLabel = new JBLabel(title);
  titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
  topPanel.add(titleLabel, BorderLayout.WEST);
  topPanel.add(showOnlyEditedFilesCheckBox, BorderLayout.EAST);

  Dimension size = topPanel.getPreferredSize();
  size.height = JBUIScale.scale(29);
  size.width = titleLabel.getPreferredSize().width + showOnlyEditedFilesCheckBox.getPreferredSize().width + JBUIScale.scale(50);
  topPanel.setPreferredSize(size);
  topPanel.setMinimumSize(size);
  topPanel.setBorder(JBUI.Borders.empty(5, 8));

  if (isMovable) {
    WindowMoveListener moveListener = new WindowMoveListener(topPanel);
    topPanel.addMouseListener(moveListener);
    topPanel.addMouseMotionListener(moveListener);
  }

  return topPanel;
}
 
Example 4
Source File: FlutterLogView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
@Override
public JComponent createCustomComponent(@NotNull Presentation presentation) {
  panel = new JPanel();

  label = new JBLabel();
  label.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
  label.setForeground(UIUtil.getInactiveTextColor());
  label.setBorder(JBUI.Borders.emptyRight(10));
  panel.add(label);

  logTree.addListener(this, FlutterLogView.this);

  return panel;
}
 
Example 5
Source File: FlutterLogView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
@Override
public JComponent createCustomComponent(@NotNull Presentation presentation) {
  panel = new JPanel();

  label = new JBLabel();
  label.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
  label.setForeground(UIUtil.getInactiveTextColor());
  label.setBorder(JBUI.Borders.emptyRight(10));
  panel.add(label);

  logTree.addListener(this, FlutterLogView.this);

  return panel;
}
 
Example 6
Source File: ReferencesPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
protected JBLabel createLabel(@Nonnull String text, @Nullable Icon icon) {
  JBLabel label = new JBLabel(text, icon, SwingConstants.LEFT);
  label.setFont(getLabelsFont());
  label.setIconTextGap(0);
  label.setHorizontalAlignment(SwingConstants.LEFT);
  return label;
}
 
Example 7
Source File: DetailsPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void rebuildCommitPanels(int[] selection) {
  myEmptyText.setText("");

  int selectionLength = selection.length;

  // for each commit besides the first there are two components: Separator and CommitPanel
  int existingCount = (myMainContentPanel.getComponentCount() + 1) / 2;
  int requiredCount = Math.min(selectionLength, MAX_ROWS);
  for (int i = existingCount; i < requiredCount; i++) {
    if (i > 0) {
      myMainContentPanel.add(new SeparatorComponent(0, OnePixelDivider.BACKGROUND, null));
    }
    myMainContentPanel.add(new CommitPanel(myLogData, myColorManager));
  }

  // clear superfluous items
  while (myMainContentPanel.getComponentCount() > 2 * requiredCount - 1) {
    myMainContentPanel.remove(myMainContentPanel.getComponentCount() - 1);
  }

  if (selectionLength > MAX_ROWS) {
    myMainContentPanel.add(new SeparatorComponent(0, OnePixelDivider.BACKGROUND, null));
    JBLabel label = new JBLabel("(showing " + MAX_ROWS + " of " + selectionLength + " selected commits)");
    label.setFont(VcsHistoryUtil.getCommitDetailsFont());
    label.setBorder(CommitPanel.getDetailsBorder());
    myMainContentPanel.add(label);
  }

  mySelection = Ints.asList(Arrays.copyOf(selection, requiredCount));

  repaint();
}
 
Example 8
Source File: RecentLocationsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static JLabel createTitle(boolean showChanged) {
  JBLabel title = new JBLabel();
  title.setFont(title.getFont().deriveFont(Font.BOLD));
  updateTitleText(title, showChanged);
  return title;
}
 
Example 9
Source File: DaemonTooltipWithActionRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
private JComponent createKeymapHint(String shortcutRunAction) {
  JBLabel fixHint = new JBLabel(shortcutRunAction) {
    @Override
    public Color getForeground() {
      return getKeymapColor();
    }
  };
  fixHint.setBorder(JBUI.Borders.empty());
  fixHint.setFont(getActionFont());
  return fixHint;
}
 
Example 10
Source File: GoToHashOrRefPopup.java    From consulo with Apache License 2.0 4 votes vote down vote up
public GoToHashOrRefPopup(@Nonnull final Project project,
                          @Nonnull VcsLogRefs variants,
                          Collection<VirtualFile> roots,
                          @Nonnull Function<String, Future> onSelectedHash,
                          @Nonnull Function<VcsRef, Future> onSelectedRef,
                          @Nonnull VcsLogColorManager colorManager,
                          @Nonnull Comparator<VcsRef> comparator) {
  myOnSelectedHash = onSelectedHash;
  myOnSelectedRef = onSelectedRef;
  myTextField =
    new TextFieldWithProgress(project, new VcsRefCompletionProvider(project, variants, roots, colorManager, comparator)) {
      @Override
      public void onOk() {
        if (myFuture == null) {
          final Future future = ((mySelectedRef == null || (!mySelectedRef.getName().equals(getText().trim())))
                                 ? myOnSelectedHash.fun(getText().trim())
                                 : myOnSelectedRef.fun(mySelectedRef));
          myFuture = future;
          showProgress();
          ApplicationManager.getApplication().executeOnPooledThread(() -> {
            try {
              future.get();
              okPopup();
            }
            catch (CancellationException ex) {
              cancelPopup();
            }
            catch (InterruptedException ex) {
              cancelPopup();
            }
            catch (ExecutionException ex) {
              LOG.error(ex);
              cancelPopup();
            }
          });
        }
      }
    };
  myTextField.setAlignmentX(Component.LEFT_ALIGNMENT);

  JBLabel label = new JBLabel("Enter hash or branch/tag name:");
  label.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
  label.setAlignmentX(Component.LEFT_ALIGNMENT);

  JPanel panel = new JPanel();
  BoxLayout layout = new BoxLayout(panel, BoxLayout.PAGE_AXIS);
  panel.setLayout(layout);
  panel.add(label);
  panel.add(myTextField);
  panel.setBorder(new EmptyBorder(2, 2, 2, 2));

  myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, myTextField.getPreferableFocusComponent())
    .setCancelOnClickOutside(true).setCancelOnWindowDeactivation(true).setCancelKeyEnabled(true).setRequestFocus(true).createPopup();
  myPopup.addListener(new JBPopupListener.Adapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      if (!event.isOk()) {
        if (myFuture != null) {
          myFuture.cancel(true);
        }
      }
      myFuture = null;
      myTextField.hideProgress();
    }
  });
}