Java Code Examples for javax.swing.BorderFactory#createCompoundBorder()

The following examples show how to use javax.swing.BorderFactory#createCompoundBorder() . 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: EditSpeciesService.java    From Shuffle-Move with GNU General Public License v3.0 6 votes vote down vote up
private void setBorderFor(JPanel c, boolean doBorder) {
   if (c != null) {
      ConfigManager manager = getUser().getPreferencesManager();
      int borderThick = manager.getIntegerValue(KEY_ROSTER_CELL_BORDER_THICK, DEFAULT_BORDER_WIDTH);
      borderThick = getUser().scaleBorderThickness(borderThick);
      int outlineThick = manager.getIntegerValue(KEY_ROSTER_CELL_OUTLINE_THICK, DEFAULT_BORDER_OUTLINE);
      outlineThick = getUser().scaleBorderThickness(outlineThick);
      int marginThick = manager.getIntegerValue(KEY_ROSTER_CELL_MARGIN_THICK, DEFAULT_BORDER_MARGIN);
      marginThick = getUser().scaleBorderThickness(marginThick);
      Border main;
      Border margin = new EmptyBorder(marginThick, marginThick, marginThick, marginThick);
      if (doBorder) {
         main = new LineBorder(Color.BLACK, borderThick);
      } else {
         main = new EmptyBorder(borderThick, borderThick, borderThick, borderThick);
      }
      Border greyOutline = new LineBorder(Color.gray, outlineThick);
      Border innerChunk = BorderFactory.createCompoundBorder(greyOutline, margin);
      Border outerChunk = BorderFactory.createCompoundBorder(main, margin);
      Border finalBorder = BorderFactory.createCompoundBorder(outerChunk, innerChunk);
      c.setBorder(finalBorder);
   }
}
 
Example 2
Source File: EditRosterService.java    From Shuffle-Move with GNU General Public License v3.0 6 votes vote down vote up
private void setBorderFor(JPanel c, boolean doBorder) {
   if (c != null) {
      ConfigManager manager = getUser().getPreferencesManager();
      int borderThick = manager.getIntegerValue(KEY_ROSTER_CELL_BORDER_THICK, DEFAULT_BORDER_WIDTH);
      borderThick = getUser().scaleBorderThickness(borderThick);
      int outlineThick = manager.getIntegerValue(KEY_ROSTER_CELL_OUTLINE_THICK, DEFAULT_BORDER_OUTLINE);
      outlineThick = getUser().scaleBorderThickness(outlineThick);
      int marginThick = manager.getIntegerValue(KEY_ROSTER_CELL_MARGIN_THICK, DEFAULT_BORDER_MARGIN);
      marginThick = getUser().scaleBorderThickness(marginThick);
      Border main;
      Border margin = new EmptyBorder(marginThick, marginThick, marginThick, marginThick);
      if (doBorder) {
         main = new LineBorder(Color.BLACK, borderThick);
      } else {
         main = new EmptyBorder(borderThick, borderThick, borderThick, borderThick);
      }
      Border greyOutline = new LineBorder(Color.gray, outlineThick);
      Border innerChunk = BorderFactory.createCompoundBorder(greyOutline, margin);
      Border outerChunk = BorderFactory.createCompoundBorder(main, margin);
      Border finalBorder = BorderFactory.createCompoundBorder(outerChunk, innerChunk);
      c.setBorder(finalBorder);
   }
}
 
Example 3
Source File: PaintPalletPanel.java    From Shuffle-Move with GNU General Public License v3.0 6 votes vote down vote up
private boolean setBorderFor(Indicator<SpeciesPaint> ind, boolean selected) {
   boolean changed = false;
   if (ind != null) {
      ConfigManager manager = getUser().getPreferencesManager();
      int thickness = manager.getIntegerValue(KEY_SELECT_PAINT_THICK, DEFAULT_SELECT_THICK);
      thickness = getUser().scaleBorderThickness(thickness);
      int outlineThick = manager.getIntegerValue(KEY_OUTLINE_PAINT_THICK, DEFAULT_OUTLINE_THICK);
      outlineThick = getUser().scaleBorderThickness(outlineThick);
      Border b;
      if (selected) {
         b = new LineBorder(getPaintSelectColor(), thickness);
      } else {
         b = new EmptyBorder(thickness, thickness, thickness, thickness);
      }
      Border greyOutline = new LineBorder(Color.gray, outlineThick);
      Border borderToSet = BorderFactory.createCompoundBorder(b, greyOutline);
      if (!borderToSet.equals(ind.getBorder())) {
         ind.setBorder(borderToSet);
         changed = true;
      }
   }
   return changed;
}
 
Example 4
Source File: GUIUtils.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add a margin and border to a given component
 * 
 * @param component Component to add the margin to
 * @param margin Margin size
 * @return Created border
 */
public static Border addMarginAndBorder(JComponent component, int margin) {
  Border marginBorder = BorderFactory.createEmptyBorder(margin, margin, margin, margin);
  Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
  Border compoundBorder = BorderFactory.createCompoundBorder(etchedBorder, marginBorder);
  component.setBorder(compoundBorder);
  return compoundBorder;
}
 
Example 5
Source File: GUIUtils.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add a margin and border to a given component
 *
 * @param component Component to add the margin to
 * @param margin Margin size
 * @return Created border
 */
public static Border addMarginAndBorder(JComponent component, int margin) {
  Border marginBorder = BorderFactory.createEmptyBorder(margin, margin, margin, margin);
  Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
  Border compoundBorder = BorderFactory.createCompoundBorder(etchedBorder, marginBorder);
  component.setBorder(compoundBorder);
  return compoundBorder;
}
 
Example 6
Source File: RegexDialog.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
public static Border createBorder(String title) {
    TitledBorder titledBorder = BorderFactory.createTitledBorder(title);
    titledBorder.setBorder(BorderFactory.createEmptyBorder());

    return BorderFactory.createCompoundBorder(
            new EmptyBorder(10, 5, 5, 5),
            BorderFactory.createCompoundBorder(
                    titledBorder, BorderFactory.createEmptyBorder(5, 5, 5, 5)));
}
 
Example 7
Source File: InternalWindow.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a TitleBar.
 */
TitleBar() {
	/*
	 * Compensate with negative empty border the borders that are not
	 * drawn anyway. Left and right borders are useful as padding so
	 * they are kept.
	 */
	insets = getInsets();
	border = BorderFactory.createCompoundBorder(getBorder(),
			BorderFactory.createEmptyBorder(-insets.top, 0, 0, 0));
	setBorder(border);
	cache = new ComponentPaintCache(this);
}
 
Example 8
Source File: TestResultRow.java    From tmc-intellij with MIT License 5 votes vote down vote up
private void createBorder() {
    logger.info("Creating border. @TestResultRow");

    Border innerPadding = BorderFactory.createEmptyBorder(5, 10, 5, 5);
    Border leftColorBar = BorderFactory.createMatteBorder(0, 6, 0, 0, borderColor);
    Border compoundBorder = BorderFactory.createCompoundBorder(leftColorBar, innerPadding);
    this.setBorder(compoundBorder);
}
 
Example 9
Source File: TracerOptionsPanel.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private static Border titledBorder(String title) {
    String titleBorder = org.graalvm.visualvm.uisupport.UISupport.
                         isWindowsLookAndFeel() ? " " : ""; //NOI18N
    Border inner = BorderFactory.createEmptyBorder(0, 12, 3, 3);
    Border outer = BorderFactory.createTitledBorder(titleBorder + title);
    return BorderFactory.createCompoundBorder(outer, inner);
}
 
Example 10
Source File: HistoryQuickSearchView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void internalInitComponents() {
	SgLayout sgl = new SgLayout(2, 5, 0, 0);
	sgl.setColSize(0, 100, SgLayout.SIZE_TYPE_WEIGHTED);
	sgl.setColSize(1, UiUtils.getFontRelativeSize(text("action.cancel").length()), SgLayout.SIZE_TYPE_ASKCOMPONENT);
	sgl.setRowSize(3, UiUtils.getFontRelativeSize(26), SgLayout.SIZE_TYPE_WEIGHTED);
	panelRoot = new JPanel(sgl);

	CompoundBorder panelBorder = BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(),
			BorderFactory.createEmptyBorder(5, 5, 5, 5));
	panelRoot.setBorder(panelBorder);

	panelRoot.add(new JLabel(text("phrase.typeFilenameToFilter")), sgl.cs(0, 0, 2, 1));
	edQuickSearch = new JTextField();
	edQuickSearch.addKeyListener(quickSearchKeyListener);
	JPanel pnlEditQuickSearch = new JPanel(new BorderLayout());
	pnlEditQuickSearch.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
	pnlEditQuickSearch.add(edQuickSearch, BorderLayout.CENTER);
	panelRoot.add(pnlEditQuickSearch, sgl.cs(0, 1, 2, 1));

	tblLabel = new JLabel("TBD");
	panelRoot.add(tblLabel, sgl.cs(0, 2, 2, 1));

	panelTablePlaceholder = new JPanel(new BorderLayout());
	panelRoot.add(panelTablePlaceholder, sgl.cs(0, 3, 2, 1));

	JXLabel hintLbl = new JXLabel(text("quicksearch.navigationHint"));
	hintLbl.setLineWrap(true);
	panelRoot.add(hintLbl, sgl.cs(0, 4));

	JPanel tmpPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
	panelRoot.add(tmpPanel, sgl.cs(1, 4));
	tmpPanel.add(btnCancel = new JButton());

	ctxMenu = new JPopupMenu();
	initTableComponent();

	lblNoDataToDisplay = new JLabel(text("term.noDataToDisplay"));
	lblNoDataToDisplay.setHorizontalAlignment(JLabel.CENTER);
}
 
Example 11
Source File: BorderBuilders.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected Border createInstanceImpl() {
    Border outside = outsideBorder == null || outsideBorder.isUIResource() ?
                     null : outsideBorder.createInstance();
    Border inside = insideBorder == null || insideBorder.isUIResource() ?
                     null : insideBorder.createInstance();
    if (outside == null && inside == null) {
        return BorderFactory.createEmptyBorder();
    } else if (outside == null || inside == null) {
        if (outside == null) return inside;
        else return outside;
    } else {
        return BorderFactory.createCompoundBorder(outside, inside);
    }
}
 
Example 12
Source File: ToggleProfilingPointAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void setProfilingPointFactory(ProfilingPointFactory ppFactory, int index) {
    this.ppFactory = ppFactory;

    if (ppFactory != null) {
        label.setText(ppFactory.getType());
        label.setIcon(ppFactory.getIcon());
    } else {
        label.setText(NO_ACTION_NAME);
        label.setIcon(NO_ACTION_ICON);
    }

    Component selected = null;

    if ((index >= 0) && (index < previewPanel.getComponentCount())) {
        selected = previewPanel.getComponent(index);
    }

    for (Component c : previewPanel.getComponents()) {
        if (c == selected) {
            Border empt1 = BorderFactory.createEmptyBorder(2, 2, 2, 2);
            Border sel = BorderFactory.createMatteBorder(1, 1, 1, 1, SystemColor.textHighlight);
            Border empt2 = BorderFactory.createEmptyBorder(0, 2, 0, 2);
            Border comp1 = BorderFactory.createCompoundBorder(empt2, sel);
            Border comp2 = BorderFactory.createCompoundBorder(comp1, empt1);
            ((JComponent) c).setBorder(comp2);
        } else {
            ((JComponent) c).setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
        }
    }
}
 
Example 13
Source File: ApplicationContextGuiFactory.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param name title string
 * @return a new titled border
 * @deprecated use FormUtils.createTitledBorder instead.
 */
@Deprecated
public static Border createTitledBorder(String name) {
	Border margin = BorderFactory.createEmptyBorder(10, 10, 10, 10);
	Border title = BorderFactory.createTitledBorder(name);
	
	return BorderFactory.createCompoundBorder(title, margin);
}
 
Example 14
Source File: DefaultOutlineCellRenderer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Overridden to combine the expansion border (whose insets determine how
 * much a child tree node is shifted to the right relative to the ancestor
 * root node) with whatever border is set, as a CompoundBorder.  The expansion
 * border is also responsible for drawing the expansion icon.
 * @param b the border to be rendered for this component
 */
@Override
public final void setBorder (Border b) {
    b = new RestrictedInsetsBorder(b);
    if (!swingRendering) {
        super.setBorder(b);
        return ;
    }
    if (b == expansionBorder) {
        super.setBorder(b);
    } else {
        super.setBorder(BorderFactory.createCompoundBorder (b, expansionBorder));
    }
}
 
Example 15
Source File: RendererPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void configure(Color foreground, Color background, boolean isSelected, boolean hasFocus, int nestingDepth, int rowHeight, int rowWidth) {
    if (isRoot && node.isExpandable() || node.getType().equals(TreeListNode.Type.CLOSED)) {
        foreground = isSelected ? expandableRootSelectedForeground : expandableRootForeground;
        background = isSelected ? expandableRootSelectedBackground : expandableRootBackground;
    } else if (node.getType().equals(TreeListNode.Type.TITLE)) {
        foreground = isSelected ? expandableRootSelectedForeground : colorManager.getDefaultBackground();
        background = isSelected ? colorManager.getTitleSelectedBackground() : colorManager.getTitleBackground();
    }
    int maxWidth = rowWidth - depth * EMPTY_ICON.getIconWidth() - (TreeList.INSETS_LEFT + nestingDepth * rowHeight / 2) - TreeList.INSETS_RIGHT;
    if (expander == null) {
        maxWidth += EMPTY_ICON.getIconWidth();
    }
    JComponent inner = node.getComponent(foreground, background, isSelected, hasFocus, maxWidth > 0 ? maxWidth : 0);
    if (node.isExpandable() || !isRoot || node.getType().equals(TreeListNode.Type.CLOSED)) {
        inner.setBorder(INNER_BORDER);
    }
    add(inner, BorderLayout.CENTER);

    setBackground(background);
    setForeground(foreground);
    
    if (null != expander) {
        expander.setEnabled(node.isLoaded());
        expander.setIcon(node.isLoaded() ? node.isExpanded() ? getExpandedIcon() : getCollapsedIcon() : EMPTY_ICON);
        expander.setPressedIcon(expander.getIcon());
    }
    Border border = null;
    if (hasFocus) {
        if (isSelected) {
            border = UIManager.getBorder("List.focusSelectedCellHighlightBorder"); // NOI18N
        }
        if (border == null) {
            border = UIManager.getBorder("List.focusCellHighlightBorder"); // NOI18N
        }
    }
    if (null == border) {
        border = NO_FOCUS_BORDER;
    }
    border = BorderFactory.createCompoundBorder(border,
            BorderFactory.createEmptyBorder(TreeList.INSETS_TOP, TreeList.INSETS_LEFT + nestingDepth * rowHeight / 2,
            TreeList.INSETS_BOTTOM, TreeList.INSETS_RIGHT));

    try {
        setBorder(border);
    } catch (NullPointerException npe) {
        //workaround for 175940
        Logger.getLogger(RendererPanel.class.getName()).log(Level.INFO, "Bug #175940", npe);
    }

    configureAccessibility(this, true);
}
 
Example 16
Source File: MainFrame.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
/**
 * Creates the status bar.
 */
private void createStatusBar() {
  this.statusPanel = new JPanel();
  // statusPanel.setBorder(BorderFactory.createLineBorder(Color.gray));
  this.statusPanel.setLayout(new BoxLayout(this.statusPanel, BoxLayout.X_AXIS));
  this.statusBar = new JTextField();
  Border innerCompound = BorderFactory.createCompoundBorder(BorderFactory.createBevelBorder(
      BevelBorder.LOWERED, Color.lightGray, Color.darkGray), BorderFactory.createEmptyBorder(0,
      3, 0, 3));
  Border leftCompoundBorder = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(
      0, 0, 0, 1), innerCompound);
  Border middleCompoundBorder = BorderFactory.createCompoundBorder(BorderFactory
      .createEmptyBorder(0, 1, 0, 1), innerCompound);
  Border rightCompoundBorder = BorderFactory.createCompoundBorder(BorderFactory
      .createEmptyBorder(0, 1, 0, 0), innerCompound);
  // statusBar.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
  this.statusBar.setBorder(leftCompoundBorder);
  this.statusBar.setEditable(false);
  this.statusBar.setBackground(this.getBackground());
  this.statusBar.setText("Starting up.");
  this.statusBar.setToolTipText("Status Bar");
  this.statusPanel.add(this.statusBar);
  this.fileStatus = new JTextField();
  // fileStatus.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
  this.fileStatus.setBorder(rightCompoundBorder);
  this.fileStatus.setMaximumSize(new Dimension(500, 25));
  this.fileStatus.setEditable(false);
  // fileStatus.setBackground(new Color(204, 204, 255));
  // fileStatus.setBackground(new Color(164, 147, 255));
  // statusPanel.add(fileStatus);
  this.aeStatus = new JTextField();
  this.aeStatus.setBorder(middleCompoundBorder);
  this.aeStatus.setMaximumSize(new Dimension(500, 25));
  this.aeStatus.setEditable(false);
  this.statusPanel.add(this.aeStatus);
  this.caretStatus = new JTextField();
  this.caretStatus.setBorder(rightCompoundBorder);
  this.caretStatus.setMaximumSize(new Dimension(500, 25));
  // caretStatus.setBackground(new Color(204, 255, 204));
  this.caretStatus.setEditable(false);
  this.caretStatus.setToolTipText("Position of cursor or extent of selection");
  this.statusPanel.add(this.caretStatus);
  // setCaretStatus(0, 0);
  // setFileStatusMessage();
  setAEStatusMessage();
}
 
Example 17
Source File: TracerOptionsPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static Border titledBorder(String title) {
    String titleBorder = UIUtils.isWindowsLookAndFeel() ? " " : ""; //NOI18N
    Border inner = BorderFactory.createEmptyBorder(0, 12, 3, 3);
    Border outer = BorderFactory.createTitledBorder(titleBorder + title);
    return BorderFactory.createCompoundBorder(outer, inner);
}
 
Example 18
Source File: LibraryTreePanel.java    From osp with GNU General Public License v3.0 4 votes vote down vote up
MetadataComboBoxEditor() {
	super(BoxLayout.X_AXIS);
	keyEditField = new MetadataEditField(keyFieldWidth) {
		protected String getDefaultText() {
			return metadata==emptyMetadata? ToolsRes.getString("LibraryTreePanel.Metadata.Name"): null; //$NON-NLS-1$
		}
  	protected Font getEmptyFont() {
  		return font.deriveFont(Font.BOLD+Font.ITALIC);
  	}     	
  	protected Font getDefaultFont() {
  		return font.deriveFont(Font.BOLD);
  	}      	
	};
  entryFields.add(keyEditField);

	keyEditField.setHorizontalAlignment(SwingConstants.RIGHT);
	keyEditField.setFont(keyEditField.getDefaultFont());
	
	valueEditField = new MetadataEditField(0) {
		protected String getDefaultText() {
			return metadata==emptyMetadata? ToolsRes.getString("LibraryTreePanel.Metadata.Value"): null; //$NON-NLS-1$
		}
  	protected Font getEmptyFont() {
  		return font.deriveFont(Font.ITALIC);
  	}     	
  	protected Font getDefaultFont() {
  		return font.deriveFont(Font.PLAIN);
  	}      	
	};
  entryFields.add(valueEditField);
	
	Border border = BorderFactory.createCompoundBorder(keyEditField.getBorder(), BorderFactory.createEmptyBorder(0, 1, 0, 1));
	keyEditField.setBorder(border);
	valueEditField.setBorder(border);

	spacer = new JLabel();
	spacer.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
	add(keyEditField);
	add(spacer);
	add(valueEditField);
}
 
Example 19
Source File: ContextView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @author  Tim Boudreau
 * @author  Marian Petras
 */
public ContextView(ResultModel resultModel,
        ExplorerManager explorerManager) {
    Border b = BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(        //outside border
                            0, 0, 1, 0, 
                            UIManager.getColor("controlShadow")),   //NOI18N
            BorderFactory.createEmptyBorder(        //inside border
                            5, 5, 1, 5));
    lblPath.setBorder(b);
    
    editorPane.setEditable(false);
    editorPane.getCaret().setBlinkRate(0);
    
    editorScroll = new JScrollPane(editorPane);
    editorScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    editorScroll.setBorder(BorderFactory.createEmptyBorder());
    
    JPanel fileViewPanel = new JPanel();
    fileViewPanel.setLayout(new BorderLayout());
    fileViewPanel.add(lblPath, BorderLayout.NORTH);
    fileViewPanel.add(editorScroll, BorderLayout.CENTER);
    
    Box messagePanel = Box.createVerticalBox();
    messagePanel.add(Box.createVerticalGlue());
    messagePanel.add(lblMessage);
    messagePanel.add(Box.createVerticalGlue());
    lblMessage.setAlignmentX(0.5f);
    lblMessage.setHorizontalAlignment(SwingConstants.CENTER);
    lblMessage.setEnabled(false);
    
    setLayout(cardLayout = new CardLayout());
    add(fileViewPanel, FILE_VIEW);
    add(messagePanel, MESSAGE_VIEW);
    
    setResultModel(resultModel);

    this.explorerManager = explorerManager;
    explorerManager.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("selectedNodes")) {
                updateForSelection();
            }
        }
    });
}
 
Example 20
Source File: SeaGlassTableUI.java    From seaglass with Apache License 2.0 2 votes vote down vote up
/**
 * DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
private Border getSelectedRowBorder() {
    return BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, getSelectedRowBottomHighlight()),
                                              BorderFactory.createEmptyBorder(1, 5, 0, 5));
}