List of usage examples for javax.swing.border Border Border
Border
From source file:net.sf.taverna.t2.workbench.ui.impl.UserRegistrationForm.java
/** * Adds a light gray or etched border to the top or bottom of a JComponent. * /*from w w w. j av a 2 s. c om*/ * @author David Withers * @param component */ protected void addDivider(JComponent component, final int position, final boolean etched) { component.setBorder(new Border() { private final Color borderColor = new Color(.6f, .6f, .6f); @Override public Insets getBorderInsets(Component c) { if (position == TOP) return new Insets(5, 0, 0, 0); else return new Insets(0, 0, 5, 0); } @Override public boolean isBorderOpaque() { return false; } @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { if (position == TOP) { if (etched) { g.setColor(borderColor); g.drawLine(x, y, x + width, y); g.setColor(WHITE); g.drawLine(x, y + 1, x + width, y + 1); } else { g.setColor(LIGHT_GRAY); g.drawLine(x, y, x + width, y); } } else { if (etched) { g.setColor(borderColor); g.drawLine(x, y + height - 2, x + width, y + height - 2); g.setColor(WHITE); g.drawLine(x, y + height - 1, x + width, y + height - 1); } else { g.setColor(LIGHT_GRAY); g.drawLine(x, y + height - 1, x + width, y + height - 1); } } } }); }
From source file:net.sf.taverna.t2.activities.spreadsheet.views.SpreadsheetImportConfigView.java
/** * Adds a light gray or etched border to the top or bottom of a JComponent. * * @param component/*from w w w .j a v a 2s. com*/ */ protected void addDivider(JComponent component, final int position, final boolean etched) { component.setBorder(new Border() { private final Color borderColor = new Color(.6f, .6f, .6f); public Insets getBorderInsets(Component c) { if (position == SwingConstants.TOP) { return new Insets(5, 0, 0, 0); } else { return new Insets(0, 0, 5, 0); } } public boolean isBorderOpaque() { return false; } public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { if (position == SwingConstants.TOP) { if (etched) { g.setColor(borderColor); g.drawLine(x, y, x + width, y); g.setColor(Color.WHITE); g.drawLine(x, y + 1, x + width, y + 1); } else { g.setColor(Color.LIGHT_GRAY); g.drawLine(x, y, x + width, y); } } else { if (etched) { g.setColor(borderColor); g.drawLine(x, y + height - 2, x + width, y + height - 2); g.setColor(Color.WHITE); g.drawLine(x, y + height - 1, x + width, y + height - 1); } else { g.setColor(Color.LIGHT_GRAY); g.drawLine(x, y + height - 1, x + width, y + height - 1); } } } }); }
From source file:org.gtdfree.GTDFree.java
private void flashMessage(String string, Point location) { if (flasher == null) { flasher = new JWindow(); flasher.addMouseListener(new MouseAdapter() { @Override/*from w w w.jav a2 s . c om*/ public void mouseClicked(MouseEvent e) { flasher.setVisible(false); } }); flasher.setContentPane(flasherText = new JLabel()); flasherText.setBorder(new Border() { Insets insets = new Insets(5, 11, 5, 11); @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { // } @Override public boolean isBorderOpaque() { return false; } @Override public Insets getBorderInsets(Component c) { return insets; } }); flasherText.setBackground(new Color(0xf3f3ad)); flasherText.setOpaque(true); } flasher.setVisible(false); flasherText.setText(string); flasher.pack(); flasher.setLocation(location.x - flasher.getWidth() / 2, location.y - flasher.getHeight()); if (flasher.getLocation().x < 0) { flasher.setLocation(0, flasher.getLocation().y); } if (flasher.getLocation().y < 0) { flasher.setLocation(flasher.getLocation().x, 0); } Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); if (flasher.getLocation().x + flasher.getWidth() > d.getWidth()) { flasher.setLocation((int) (d.getWidth() - flasher.getWidth()), flasher.getLocation().y); } if (flasher.getLocation().y + flasher.getHeight() > d.getHeight()) { flasher.setLocation(flasher.getLocation().x, (int) (d.getHeight() - flasher.getHeight())); } flasher.setVisible(true); new Thread() { @Override public synchronized void run() { try { wait(3000); } catch (InterruptedException e) { Logger.getLogger(this.getClass()).debug("Internal error.", e); //$NON-NLS-1$ } flasher.setVisible(false); } }.start(); }