List of usage examples for javax.swing JComponent getBorder
public Border getBorder()
null
if no border is currently set. From source file:Main.java
/** * GUI utility (change border title)/*from ww w. j a v a 2s. c om*/ * * @param panel * bborder component * @param title * new title */ public static void borderTitle(JComponent panel, String title) { Border b = panel.getBorder(); if (b instanceof TitledBorder) ((TitledBorder) b).setTitle(title); }
From source file:Main.java
public static void addBorderSpaces(JComponent com) { com.setBorder(//from w ww . ja va2 s . com BorderFactory.createCompoundBorder(com.getBorder(), BorderFactory.createEmptyBorder(2, 4, 2, 4))); }
From source file:Main.java
private static void trySetBorderFont(Font font, Component component) { if (component instanceof JComponent) { JComponent jc = (JComponent) component; if (jc.getBorder() instanceof TitledBorder) { TitledBorder titledBorder = (TitledBorder) jc.getBorder(); titledBorder.setTitleFont(font); }/*from ww w.ja v a2s.c o m*/ } }
From source file:Main.java
public static void setMargin(final JComponent component, final Insets newMargin) { final Border currentBorder = component.getBorder(); final Border empty = new EmptyBorder(newMargin.top, newMargin.left, newMargin.bottom, newMargin.right); if (currentBorder == null || currentBorder instanceof EmptyBorder) { component.setBorder(empty);/*from w w w. ja v a 2s . c o m*/ } else if (currentBorder instanceof CompoundBorder) { final CompoundBorder current = (CompoundBorder) currentBorder; final Border insideBorder = current.getInsideBorder(); component.setBorder(new CompoundBorder(empty, insideBorder)); } else { component.setBorder(new CompoundBorder(empty, currentBorder)); } }
From source file:LayeredPaneDemo.java
public void paint(Graphics g, JComponent c) { super.paint(g, c); if (c.getBorder() != null) c.getBorder().paintBorder(c, g, 0, 0, c.getWidth(), c.getHeight()); }
From source file:net.sourceforge.squirrel_sql.fw.gui.debug.DebugEventListener.java
private void setBorder(JComponent source, AWTEvent event) { Border border = source.getBorder(); switch (event.getID()) { case MouseEvent.MOUSE_ENTERED: if (border != null) { source.setBorder(new DebugBorder(border)); }// ww w .j a va2s . c o m break; case MouseEvent.MOUSE_EXITED: if (border != null && border instanceof DebugBorder) { source.setBorder(((DebugBorder) border).getDelegate()); } break; } }
From source file:pcgen.gui2.tabs.SummaryInfoTab.java
private void highlightBorder(final JComponent comp) { final Border oldBorder = comp.getBorder(); Border highlightBorder = BorderFactory.createLineBorder(Color.GREEN, 3); comp.setBorder(highlightBorder);/* w w w . j a v a 2 s .c o m*/ SwingUtilities.invokeLater(() -> { try { Thread.sleep(500); } catch (InterruptedException e) { // Ignored as we'll exit shortly anyway. } comp.setBorder(oldBorder); }); }