Java Code Examples for com.intellij.ui.components.JBScrollPane#setBorder()

The following examples show how to use com.intellij.ui.components.JBScrollPane#setBorder() . 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: NewItemWithTemplatesPopupPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public NewItemWithTemplatesPopupPanel(List<T> templatesList, ListCellRenderer<T> renderer) {
  setBackground(JBUI.CurrentTheme.NewClassDialog.panelBackground());

  myTemplatesListModel = new MyListModel(templatesList);
  myTemplatesList = createTemplatesList(myTemplatesListModel, renderer);

  ScrollingUtil.installMoveUpAction(myTemplatesList, (JComponent)TargetAWT.to(myTextField));
  ScrollingUtil.installMoveDownAction(myTemplatesList, (JComponent)TargetAWT.to(myTextField));

  JBScrollPane scrollPane = new JBScrollPane(myTemplatesList);
  scrollPane.setBorder(JBUI.Borders.empty());
  scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  templatesListHolder = new Box(BoxLayout.Y_AXIS);
  Border border = JBUI.Borders
          .merge(JBUI.Borders.emptyTop(JBUI.CurrentTheme.NewClassDialog.fieldsSeparatorWidth()), JBUI.Borders.customLine(JBUI.CurrentTheme.NewClassDialog.bordersColor(), 1, 0, 0, 0), true);

  templatesListHolder.setBorder(border);
  templatesListHolder.add(scrollPane);

  add(templatesListHolder, BorderLayout.CENTER);
}
 
Example 2
Source File: CourseTabFactory.java    From tmc-intellij with MIT License 5 votes vote down vote up
public void createCourseSpecificTab(
        ObjectFinder finder,
        ProjectOpener opener,
        String course,
        JTabbedPane tabbedPaneBase,
        CourseAndExerciseManager courseAndExerciseManager) {
    logger.info("Creating course specific tab. @CourseTabFactory");
    final JBScrollPane panel = new JBScrollPane();
    final JBList list = new JBList();
    list.setCellRenderer(new ProjectListRenderer());

    DefaultListModel defaultListModel = new DefaultListModel();
    panel.setBorder(BorderFactory.createTitledBorder(""));

    ProjectListManagerHolder.get()
            .addExercisesToList(finder, course, defaultListModel, courseAndExerciseManager);

    if (defaultListModel.getSize() <= 0) {
        return;
    }

    list.setName(course);
    list.setModel(defaultListModel);

    MouseListener mouseListener = createMouseListenerForWindow(opener, panel, list);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.addMouseListener(mouseListener);

    panel.setName(course);
    panel.setViewportView(list);

    ProjectListManagerHolder.get().addList(list);
    tabbedPaneBase.addTab(course, panel);
    tabbedPaneBase.addMouseListener(tabMouseListener(tabbedPaneBase));
    setScrollBarToBottom(course, tabbedPaneBase, panel);
}
 
Example 3
Source File: DialogWrapper.java    From consulo with Apache License 2.0 5 votes vote down vote up
private ErrorText(int horizontalAlignment) {
  setLayout(new BorderLayout());
  myLabel.setBorder(JBUI.Borders.empty(16, 13, 16, 13));
  myLabel.setHorizontalAlignment(horizontalAlignment);
  JBScrollPane pane = new JBScrollPane(myLabel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  pane.setBorder(JBUI.Borders.empty());
  pane.setBackground(null);
  pane.getViewport().setBackground(null);
  pane.setOpaque(false);
  add(pane, BorderLayout.CENTER);
}
 
Example 4
Source File: ScrollPaneFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static JScrollPane createScrollPane(Component view, boolean withoutBorder) {
  JBScrollPane scrollPane = new JBScrollPane(view);
  if (withoutBorder) {
    scrollPane.setBorder(IdeBorderFactory.createEmptyBorder()); // set empty border, because setting null doesn't always take effect
    scrollPane.setViewportBorder(IdeBorderFactory.createEmptyBorder());
  }
  return scrollPane;
}
 
Example 5
Source File: CourseCard.java    From tmc-intellij with MIT License 4 votes vote down vote up
/**
 * This method is called from within the constructor to initialize the form. WARNING: Do NOT
 * modify this code. The content of this method is always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    titleLabel = new JLabel();
    nameLabel = new JLabel();
    infoScrollPane = new JBScrollPane();
    informationLabel = new JTextArea();

    setBackground(new Color(255, 255, 255));
    setMaximumSize(new Dimension(332, 73));
    setMinimumSize(new Dimension(332, 73));
    setPreferredSize(new Dimension(346, 107));

    titleLabel.setFont(new Font("Ubuntu", 1, 18)); // NOI18N

    nameLabel.setForeground(new Color(150, 150, 150));

    infoScrollPane.setBackground(new Color(255, 255, 255));
    infoScrollPane.setBorder(BorderFactory.createEmptyBorder(2, 10, 2, 10));
    infoScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    infoScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    infoScrollPane.setViewportBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    infoScrollPane.setHorizontalScrollBar(null);
    infoScrollPane.setPreferredSize(new Dimension(106, 30));

    informationLabel.setEditable(false);
    informationLabel.setBackground(new Color(255, 255, 255));
    informationLabel.setLineWrap(true);
    informationLabel.setWrapStyleWord(true);
    informationLabel.setAutoscrolls(false);
    informationLabel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    informationLabel.setMaximumSize(null);
    infoScrollPane.setViewportView(informationLabel);

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addGroup(
                            layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addGroup(
                                            layout.createParallelGroup(
                                                GroupLayout.Alignment.LEADING)
                                                    .addGroup(
                                                            layout.createSequentialGroup()
                                                                    .addComponent(titleLabel)
                                                                    .addPreferredGap(
                                                                            LayoutStyle
                                                                                    .ComponentPlacement
                                                                                    .RELATED,
                                                                            155,
                                                                            Short.MAX_VALUE)
                                                                    .addComponent(nameLabel))
                                                    .addComponent(
                                                            infoScrollPane,
                                                            GroupLayout.DEFAULT_SIZE,
                                                            GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE))
                                    .addContainerGap()));
    layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addGroup(
                            layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addGroup(
                                            layout.createParallelGroup(
                                                GroupLayout.Alignment.BASELINE)
                                                    .addComponent(titleLabel)
                                                    .addComponent(nameLabel))
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(
                                            infoScrollPane,
                                            GroupLayout.PREFERRED_SIZE,
                                            40,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap(
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
}
 
Example 6
Source File: ScrollPaneFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static JScrollPane createScrollPane(Component view, @MagicConstant(flagsFromClass = SideBorder.class) int borders) {
  JBScrollPane scrollPane = new JBScrollPane(view);
  scrollPane.setBorder(IdeBorderFactory.createBorder(borders));
  return scrollPane;

}
 
Example 7
Source File: DetailsPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
DetailsPanel(@Nonnull VcsLogData logData,
             @Nonnull VcsLogColorManager colorManager,
             @Nonnull Disposable parent) {
  myLogData = logData;
  myColorManager = colorManager;

  myScrollPane = new JBScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  myMainContentPanel = new ScrollablePanel() {
    @Override
    public boolean getScrollableTracksViewportWidth() {
      boolean expanded = false;
      for (Component c : getComponents()) {
        if (c instanceof CommitPanel && ((CommitPanel)c).isExpanded()) {
          expanded = true;
          break;
        }
      }
      return !expanded;
    }

    @Override
    public Dimension getPreferredSize() {
      Dimension preferredSize = super.getPreferredSize();
      int height = Math.max(preferredSize.height, myScrollPane.getViewport().getHeight());
      JBScrollPane scrollPane = UIUtil.getParentOfType(JBScrollPane.class, this);
      if (scrollPane == null || getScrollableTracksViewportWidth()) {
        return new Dimension(preferredSize.width, height);
      }
      else {
        return new Dimension(Math.max(preferredSize.width, scrollPane.getViewport().getWidth()), height);
      }
    }

    @Override
    public Color getBackground() {
      return CommitPanel.getCommitDetailsBackground();
    }

    @Override
    protected void paintChildren(Graphics g) {
      if (StringUtil.isNotEmpty(myEmptyText.getText())) {
        myEmptyText.paint(this, g);
      }
      else {
        super.paintChildren(g);
      }
    }
  };
  myEmptyText = new StatusText(myMainContentPanel) {
    @Override
    protected boolean isStatusVisible() {
      return StringUtil.isNotEmpty(getText());
    }
  };
  myMainContentPanel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false));

  myMainContentPanel.setOpaque(false);
  myScrollPane.setViewportView(myMainContentPanel);
  myScrollPane.setBorder(IdeBorderFactory.createEmptyBorder());
  myScrollPane.setViewportBorder(IdeBorderFactory.createEmptyBorder());

  myLoadingPanel = new JBLoadingPanel(new BorderLayout(), parent, ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS) {
    @Override
    public Color getBackground() {
      return CommitPanel.getCommitDetailsBackground();
    }
  };
  myLoadingPanel.add(myScrollPane);

  setLayout(new BorderLayout());
  add(myLoadingPanel, BorderLayout.CENTER);

  myEmptyText.setText("Commit details");
}