void (JPanel panel, GridBagConstraints gc) { gc.gridx = 0; gc.gridwidth = 1; gc.weightx = 0.0; gc.anchor = GridBagConstraints.LINE_START; if (StringUtil.isNotEmpty(myLabelText)) { if (myLabelOnTop || myTopRightComponent != null) { gc.insets = JBUI.insetsBottom(4); gc.gridx = 1; JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS)); if (myLabelOnTop) { topPanel.add(label); } if (myTopRightComponent != null) { topPanel.add(new Box.Filler(JBUI.size(UIUtil.DEFAULT_HGAP, 0), JBUI.size(UIUtil.DEFAULT_HGAP, 0), JBUI.size(Integer.MAX_VALUE))); topPanel.add(myTopRightComponent); } panel.add(topPanel, gc); gc.gridy++; } if (!myLabelOnTop) { gc.gridx = 0; switch (myAnchor) { case Top -> { gc.anchor = GridBagConstraints.PAGE_START; gc.insets = JBUI.insets(4, 0, 0, 8); } case Center -> { gc.anchor = GridBagConstraints.LINE_START; gc.insets = JBUI.insetsRight(8); } case Bottom -> { gc.anchor = GridBagConstraints.PAGE_END; gc.insets = JBUI.insets(0, 0, 4, 8); } } panel.add(label, gc); } } gc.gridx += myLabelOnTop ? 0 : 1; gc.weightx = 1.0; gc.insets = JBInsets.emptyInsets(); gc.fill = myResizeY ? GridBagConstraints.BOTH : myResizeX ? GridBagConstraints.HORIZONTAL: GridBagConstraints.NONE; gc.weighty = myResizeY ? 1.0 : 0.0; if (splitColumns) { panel.add(myComponent, gc); } if (StringUtil.isNotEmpty(myHTDescription) || !myCommentBelow) { JPanel componentPanel = new JPanel(); componentPanel.setLayout(new BoxLayout(componentPanel, BoxLayout.X_AXIS)); if (!splitColumns) { componentPanel.add(myComponent); } if (StringUtil.isNotEmpty(myHTDescription)) { ContextHelpLabel lbl = StringUtil.isNotEmpty(myHTLinkText) && myHTAction != null ? ContextHelpLabel.createWithLink(null, myHTDescription, myHTLinkText, myHTAction) : ContextHelpLabel.create(myHTDescription); JBUI.Borders.emptyLeft(7).wrap(lbl); componentPanel.add(lbl); ComponentValidator.getInstance(myComponent).ifPresent(v -> { JLabel iconLabel = new JLabel(); JBUI.Borders.emptyLeft(7).wrap(iconLabel); iconLabel.setVisible(false); componentPanel.add(iconLabel); iconLabel.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { myComponent.dispatchEvent(convertMouseEvent(e)); e.consume(); } @Override public void mouseExited(MouseEvent e) { myComponent.dispatchEvent(convertMouseEvent(e)); e.consume(); } }); myComponent.addPropertyChangeListener("JComponent.outline", evt -> { if (evt.getNewValue() == null) { iconLabel.setVisible(false); lbl.setVisible(true); } else if ("warning".equals(evt.getNewValue())) { iconLabel.setIcon(AllIcons.General.BalloonWarning); iconLabel.setVisible(true); lbl.setVisible(false); } else if ("error".equals(evt.getNewValue())) { iconLabel.setIcon(AllIcons.General.BalloonError); iconLabel.setVisible(true); lbl.setVisible(false); } componentPanel.revalidate(); componentPanel.repaint(); }); }); panel.add(componentPanel, gc); } else if (!myCommentBelow) { if (splitColumns) { gc.gridx ++; gc.weightx = 0; gc.fill = GridBagConstraints.NONE; gc.weighty = 0.0; panel.add(comment, gc); } else { comment.setBorder(getCommentBorder()); componentPanel.add(comment); panel.add(componentPanel, gc); } } } else if (!splitColumns) { panel.add(myComponent, gc); } if (!splitColumns && !myResizeX) { gc.gridx ++; gc.weightx = 1.0; gc.fill = GridBagConstraints.REMAINDER; panel.add(new JPanel(), gc); } gc.fill = GridBagConstraints.HORIZONTAL; gc.weighty = 0.0; if (myCommentBelow) { gc.gridx = 1; gc.gridy++; gc.weightx = 0.0; gc.anchor = GridBagConstraints.NORTHWEST; gc.insets = JBInsets.emptyInsets(); comment.setBorder(getCommentBorder()); panel.add(comment, gc); if (!myResizeX) { gc.gridx ++; gc.weightx = 1.0; gc.fill = GridBagConstraints.REMAINDER; panel.add(new JPanel(), gc); } } myComponent.putClientProperty(DECORATED_PANEL_PROPERTY, this); gc.gridy++; }