javax.swing.JComponent#setBorder ( )源码实例Demo

下面列出了javax.swing.JComponent#setBorder ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: javamelody   文件: ShadowPopupFactory.java
/**
 * 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);
}
 
源代码2 项目: openAGV   文件: StandardContentDialog.java
/**
 * 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);
}
 
源代码3 项目: snap-desktop   文件: TitledPanel.java
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));
}
 
源代码4 项目: opt4j   文件: DefaultTasksPanel.java
@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;
}
 
源代码5 项目: material-ui-swing   文件: MaterialPopupMenuUI.java
@Override
public void uninstallUI(JComponent c) {

	c.setFont (null);
	c.setBackground (null);
	c.setForeground (null);
	c.setBorder (null);
	c.setCursor(null);

	super.uninstallUI(c);
}
 
源代码6 项目: otto-intellij-plugin   文件: ShowUsagesAction.java
@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 + "&nbsp;"));
  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;
}
 
源代码7 项目: beautyeye   文件: BEInternalFrameUI.java
/**
 * 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);
		}
	}
}
 
源代码8 项目: pumpernickel   文件: AnimationController.java
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));
	}
}
 
源代码9 项目: settlers-remake   文件: SettlersDynamicLabelUi.java
@Override
public void installUI(JComponent c) {
	super.installUI(c);
	c.setForeground(foregroundColor);
	c.setBorder(border);
	c.setFont(UIDefaults.FONT);
}
 
源代码10 项目: audiveris   文件: UIUtil.java
/**
 * 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);
}
 
源代码11 项目: arcusplatform   文件: Table.java
@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;
   }
}
 
源代码12 项目: stendhal   文件: StyledMenuItemUI.java
@Override
public void installUI(JComponent component) {
	super.installUI(component);

	component.setBorder(style.getBorder());
	component.setOpaque(false);
	component.setFont(style.getFont());
	component.setForeground(style.getForeground());
}
 
源代码13 项目: netbeans   文件: NotificationImpl.java
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));
}
 
源代码14 项目: raccoon4   文件: OverviewBuilder.java
@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;
}
 
protected void setEmpty(JComponent comp) {
    comp.setBorder(errorBorder);
    comp.setToolTipText(empty);
}
 
源代码16 项目: orbit-image-analysis   文件: LookAndFeelTweaks.java
public static void setBorder(JComponent component) {
  if (component instanceof JPanel) {
    component.setBorder(PANEL_BORDER);
  }
}
 
源代码17 项目: magarena   文件: ImageHelper.java
public static void setDebugBorder(final JComponent component) {
    component.setBorder(BorderFactory.createDashedBorder(debugBorderPaint));
}
 
源代码18 项目: visualvm   文件: TracerOptionsPanel.java
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));
}
 
源代码19 项目: magarena   文件: CardsJTable.java
/******************************************************************
 * 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;
}
 
源代码20 项目: mzmine3   文件: GUIUtils.java
/**
 * 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;
}