Java Code Examples for javax.swing.JComponent#setBorder()
The following examples show how to use
javax.swing.JComponent#setBorder() .
These examples are extracted from open source projects.
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 Project: javamelody File: ShadowPopupFactory.java License: Apache License 2.0 | 6 votes |
/** * Hides and disposes of the <code>Popup</code>. Once a <code>Popup</code> * has been disposed you should no longer invoke methods on it. A * <code>dispose</code>d <code>Popup</code> may be reclaimed and later used * based on the <code>PopupFactory</code>. As such, if you invoke methods * on a <code>disposed</code> <code>Popup</code>, indeterminate * behavior will result.<p> * * In addition to the superclass behavior, we reset the stored * horizontal and vertical drop shadows - if any. */ @Override public void hide() { if (contents == null) { return; } final JComponent parent = (JComponent) contents.getParent(); popup.hide(); if (parent != null && parent.getBorder() == SHADOW_BORDER) { parent.setBorder(oldBorder); parent.setOpaque(oldOpaque); oldBorder = null; if (heavyWeightContainer != null) { parent.putClientProperty(PROP_HORIZONTAL_BACKGROUND, null); parent.putClientProperty(PROP_VERTICAL_BACKGROUND, null); heavyWeightContainer = null; } } owner = null; contents = null; popup = null; recycle(this); }
Example 2
Source Project: openAGV File: StandardContentDialog.java License: Apache License 2.0 | 6 votes |
/** * Creates new form StandardDialog. * * @param parent Die Komponente, zu der der Dialog zentriert wird * @param content der Inhalt * @param modal ob der Dialog modal sein soll * @param options welche Schaltflächen angezeigt werden sollen */ public StandardContentDialog(Component parent, DialogContent content, boolean modal, int options) { super(JOptionPane.getFrameForComponent(parent), modal); initComponents(); initButtons(options); JComponent component = content.getComponent(); if (component.getBorder() == null) { component.setBorder(new EmptyBorder(4, 4, 4, 4)); } getContentPane().add(component, BorderLayout.CENTER); setTitle(content.getDialogTitle()); content.initFields(); pack(); setLocationRelativeTo(parent); fContent = content; getRootPane().setDefaultButton(okButton); }
Example 3
Source Project: snap-desktop File: TitledPanel.java License: GNU General Public License v3.0 | 6 votes |
public TitledPanel(JComponent titleComponent, JComponent bodyComponent, boolean isCollapsible, boolean isInitiallyCollapsed) { super(new BorderLayout()); final JPanel titleArea = new JPanel(new BorderLayout()); if (titleComponent != null) { titleArea.add(titleComponent, BorderLayout.WEST); } titleArea.add(getSeparator(), BorderLayout.CENTER); if (isCollapsible) { titleArea.add(getCollapseButton(bodyComponent, isInitiallyCollapsed), BorderLayout.EAST); bodyComponent.setVisible(!isInitiallyCollapsed); } add(titleArea, BorderLayout.NORTH); if (bodyComponent != null) { bodyComponent.setBorder(new EmptyBorder(0, 30, 0, 0)); add(bodyComponent, BorderLayout.CENTER); } setBorder(new EmptyBorder(4, 8, 4, 8)); }
Example 4
Source Project: opt4j File: DefaultTasksPanel.java License: MIT License | 6 votes |
@Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); Task task = executionEnvironment.getTasks().get(row); if (task.getException() == null) { c.setForeground(Color.BLACK); } else { c.setForeground(Color.RED); } if (c instanceof JComponent) { JComponent jc = (JComponent) c; jc.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0)); char[] chars = this.getValueAt(row, column).toString().toCharArray(); int length = jc.getFontMetrics(jc.getFont()).charsWidth(chars, 0, chars.length); if (this.getColumnModel().getColumn(column).getWidth() < length) { jc.setToolTipText(format.formatTooltip(this.getValueAt(row, column).toString())); } else { jc.setToolTipText(null); } } return c; }
Example 5
Source Project: material-ui-swing File: MaterialPopupMenuUI.java License: MIT License | 5 votes |
@Override public void uninstallUI(JComponent c) { c.setFont (null); c.setBackground (null); c.setForeground (null); c.setBorder (null); c.setCursor(null); super.uninstallUI(c); }
Example 6
Source Project: otto-intellij-plugin File: ShowUsagesAction.java License: Apache License 2.0 | 5 votes |
@NotNull private JComponent createHintComponent(@NotNull String text, @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition, final Editor editor, @NotNull final Runnable cancelAction, final int maxUsages, @NotNull final FindUsagesOptions options) { JComponent label = HintUtil.createInformationLabel(suggestSecondInvocation(options, handler, text + " ")); InplaceButton button = createSettingsButton(handler, popupPosition, editor, maxUsages, cancelAction); JPanel panel = new JPanel(new BorderLayout()) { @Override public void addNotify() { mySearchEverywhereRunnable = new Runnable() { @Override public void run() { searchEverywhere(options, handler, editor, popupPosition, maxUsages); } }; super.addNotify(); } @Override public void removeNotify() { mySearchEverywhereRunnable = null; super.removeNotify(); } }; button.setBackground(label.getBackground()); panel.setBackground(label.getBackground()); label.setOpaque(false); label.setBorder(null); panel.setBorder(HintUtil.createHintBorder()); panel.add(label, BorderLayout.CENTER); panel.add(button, BorderLayout.EAST); return panel; }
Example 7
Source Project: beautyeye File: BEInternalFrameUI.java License: Apache License 2.0 | 5 votes |
/** * Strip content border. * * @param c the c */ private void stripContentBorder(Object c) { if (c instanceof JComponent) { JComponent contentComp = (JComponent) c; Border contentBorder = contentComp.getBorder(); if (contentBorder == null || contentBorder instanceof UIResource) { contentComp.setBorder(handyEmptyBorder); } } }
Example 8
Source Project: pumpernickel File: AnimationController.java License: MIT License | 5 votes |
private static void setInsetFocusBorder(JComponent jc) { Border oldBorder = jc.getBorder(); Border newBorder = new FocusInsetBorder(jc); if (oldBorder == null) { jc.setBorder(oldBorder); } else { jc.setBorder(new CompoundBorder(oldBorder, newBorder)); } }
Example 9
Source Project: settlers-remake File: SettlersDynamicLabelUi.java License: MIT License | 5 votes |
@Override public void installUI(JComponent c) { super.installUI(c); c.setForeground(foregroundColor); c.setBorder(border); c.setFont(UIDefaults.FONT); }
Example 10
Source Project: audiveris File: UIUtil.java License: GNU Affero General Public License v3.0 | 5 votes |
/** * Nullify the border of this JComponent, as well as its subcomponents. * * @param comp top of hierarchy */ public static void suppressBorders (JComponent comp) { if (!(comp instanceof JButton) && !(comp instanceof JToggleButton)) { comp.setBorder(null); } suppressBorders((Container) comp); }
Example 11
Source Project: arcusplatform File: Table.java License: Apache License 2.0 | 5 votes |
@Override public boolean stopCellEditing() { try { return super.stopCellEditing(); } catch(Exception e) { JComponent c = (JComponent) getComponent(); c.setBorder(new LineBorder(Color.RED)); Oculus.warn("Invalid value for cell: " + e.getMessage() + "\nClick 'esc' to stop editing", e); return false; } }
Example 12
Source Project: stendhal File: StyledMenuItemUI.java License: GNU General Public License v2.0 | 5 votes |
@Override public void installUI(JComponent component) { super.installUI(component); component.setBorder(style.getBorder()); component.setOpaque(false); component.setFont(style.getFont()); component.setForeground(style.getForeground()); }
Example 13
Source Project: netbeans File: NotificationImpl.java License: Apache License 2.0 | 5 votes |
public void initDecorations() { if (null != detailsText) { balloonComp = createDetails(detailsText, al); detailsComp = createDetails(detailsText, al); } JComponent titleComp = createTitle(title, icon); JComponent balloon = createContent(titleComp, balloonComp); balloon.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0)); balloonComp = balloon; titleComp = createTitle(title, icon); detailsComp = createContent(titleComp, detailsComp, createPriority(priority), createCategory(category), createDate(dateCreated)); }
Example 14
Source Project: raccoon4 File: OverviewBuilder.java License: Apache License 2.0 | 4 votes |
@Override protected JPanel assemble() { border = new EmptyBorder(10, 5, 5, 5); titleStrip = new TitleStrip("", "", TitleStrip.BLANK); URL feed = null; try { feed = Bookmarks.SHOUTBOXFEED.toURL(); } catch (MalformedURLException e) { } AbstractPanelBuilder shouts = new SyndicationBuilder(Messages.getString(ID + ".shoutfeed"), feed).withBorder(border); titleStrip.setSubTitle(Messages.getString(ID + ".waitadb")); versionPanel = new JPanel(false); versionPanel.setVisible(false); adbPanel = new JPanel(false); adbPanel.setVisible(false); JComponent plugPanel; if (showPlug()) { InfoBuilder plug = new InfoBuilder(Messages.getString(ID + ".plug.title")) .withTitleColor(Color.RED.darker()); plugPanel = plug.build(globals); plug.setInfo(MessageFormat.format( Messages.getString(ID + ".plug.message"), Bookmarks.FEATURELIST, Bookmarks.ORDER)); plugPanel.setBorder(border); } else { plugPanel = Box.createVerticalBox(); } JPanel ret = new JPanel(); ret.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; ret.add(titleStrip, gbc); gbc.gridy++; ret.add(plugPanel, gbc); gbc.gridy++; ret.add(versionPanel, gbc); gbc.gridy++; ret.add(adbPanel, gbc); gbc.gridy++; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1; gbc.weighty = 1; ret.add(shouts.build(globals), gbc); DatabaseManager dbm = globals.get(DatabaseManager.class); PlayProfileDao dao = dbm.get(PlayProfileDao.class); PlayProfile pp = dao.get(); if (pp != null) { titleStrip.setTitle(MessageFormat.format( Messages.getString(ID + ".welcome"), pp.getAlias())); } globals.get(BridgeManager.class).addBridgeListener(this); dao.addDataSetListener(new DatasetListenerProxy(this)); new VersionWorker(this).execute(); return ret; }
Example 15
Source Project: Cognizant-Intelligent-Test-Scripter File: AbstractRenderer.java License: Apache License 2.0 | 4 votes |
protected void setEmpty(JComponent comp) { comp.setBorder(errorBorder); comp.setToolTipText(empty); }
Example 16
Source Project: orbit-image-analysis File: LookAndFeelTweaks.java License: GNU General Public License v3.0 | 4 votes |
public static void setBorder(JComponent component) { if (component instanceof JPanel) { component.setBorder(PANEL_BORDER); } }
Example 17
Source Project: magarena File: ImageHelper.java License: GNU General Public License v3.0 | 4 votes |
public static void setDebugBorder(final JComponent component) { component.setBorder(BorderFactory.createDashedBorder(debugBorderPaint)); }
Example 18
Source Project: visualvm File: TracerOptionsPanel.java License: GNU General Public License v2.0 | 4 votes |
private static void createBorder(JComponent component, Border border) { Border cBorder = component.getBorder(); if (cBorder == null) component.setBorder(border); else component.setBorder(BorderFactory.createCompoundBorder(border, cBorder)); }
Example 19
Source Project: magarena File: CardsJTable.java License: GNU General Public License v3.0 | 4 votes |
/****************************************************************** * TRANSLUCENT THEME ******************************************************************/ // // default cell renderer // private Component prepareThemedRenderer(TableCellRenderer renderer, int row, int column) { final Component cell = super.prepareRenderer(renderer, row, column); final MagicCardDefinition card = tableModel.getCardDef(row); final boolean isRowSelected = isRowSelected(row); /* Set text color. */ cell.setForeground(card.isInvalid() ? Color.GRAY : ColorHelper.getOppositeColor(defaultForeColor) ); /* default cell properties */ final int ordinal = convertColumnIndexToModel(column); if (CardTableColumn.values()[ordinal] != CardTableColumn.Cost) { if (cell instanceof JComponent) { final JComponent jc = (JComponent) cell; jc.setBorder(isRowSelected ? SELECTED_BORDER : NO_FOCUS_BORDER); jc.setOpaque(false); } } /* Highlight row on mouse over. */ if (row == mouseOverRow) { cell.setForeground(MagicStyle.getRolloverColor()); } return cell; }
Example 20
Source Project: mzmine3 File: GUIUtils.java License: GNU General Public License v2.0 | 2 votes |
/** * Add a margin to a given component * * @param component Component to add the margin to * @param margin Margin size * @return Created border */ public static Border addMargin(JComponent component, int margin) { Border marginBorder = BorderFactory.createEmptyBorder(margin, margin, margin, margin); component.setBorder(marginBorder); return marginBorder; }