<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSwing%2FAbstractBorder</id>
		<title>Java Tutorial/Swing/AbstractBorder - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSwing%2FAbstractBorder"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Swing/AbstractBorder&amp;action=history"/>
		<updated>2026-04-07T14:43:44Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/Swing/AbstractBorder&amp;diff=4023&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Swing/AbstractBorder&amp;diff=4023&amp;oldid=prev"/>
				<updated>2010-06-01T04:57:28Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 04:57, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/Swing/AbstractBorder&amp;diff=4022&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Swing/AbstractBorder&amp;diff=4022&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:27Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Bottom Border ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.awt.ruponent;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import java.awt.Insets;&lt;br /&gt;
import javax.swing.border.AbstractBorder;&lt;br /&gt;
public class BottomBorder extends AbstractBorder {&lt;br /&gt;
  protected int thickness;&lt;br /&gt;
  protected Color lineColor;&lt;br /&gt;
  protected int gap;&lt;br /&gt;
  public BottomBorder(Color color) {&lt;br /&gt;
    this(color, 1, 1);&lt;br /&gt;
  }&lt;br /&gt;
  public BottomBorder(Color color, int thickness) {&lt;br /&gt;
    this(color, thickness, thickness);&lt;br /&gt;
  }&lt;br /&gt;
  public BottomBorder(Color color, int thickness, int gap) {&lt;br /&gt;
    lineColor = color;&lt;br /&gt;
    this.thickness = thickness;&lt;br /&gt;
    this.gap = gap;&lt;br /&gt;
  }&lt;br /&gt;
  public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {&lt;br /&gt;
    Color oldColor = g.getColor();&lt;br /&gt;
    int i;&lt;br /&gt;
    g.setColor(lineColor);&lt;br /&gt;
    for (i = 0; i &amp;lt; thickness; i++) {&lt;br /&gt;
      g.drawLine(x, y + height - i - 1, x + width, y + height - i - 1);&lt;br /&gt;
    }&lt;br /&gt;
    g.setColor(oldColor);&lt;br /&gt;
  }&lt;br /&gt;
  public Insets getBorderInsets(Component c) {&lt;br /&gt;
    return new Insets(0, 0, gap, 0);&lt;br /&gt;
  }&lt;br /&gt;
  public Insets getBorderInsets(Component c, Insets insets) {&lt;br /&gt;
    insets.left = 0;&lt;br /&gt;
    insets.top = 0;&lt;br /&gt;
    insets.right = 0;&lt;br /&gt;
    insets.bottom = gap;&lt;br /&gt;
    return insets;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the color of the border.&lt;br /&gt;
   */&lt;br /&gt;
  public Color getLineColor() {&lt;br /&gt;
    return lineColor;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the thickness of the border.&lt;br /&gt;
   */&lt;br /&gt;
  public int getThickness() {&lt;br /&gt;
    return thickness;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns whether or not the border is opaque.&lt;br /&gt;
   */&lt;br /&gt;
  public boolean isBorderOpaque() {&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
  public int getGap() {&lt;br /&gt;
    return gap;&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Rectangle border ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.awt.ruponent;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import java.awt.Insets;&lt;br /&gt;
import javax.swing.border.AbstractBorder;&lt;br /&gt;
public class RectangleBorder extends AbstractBorder {&lt;br /&gt;
  protected Insets thickness;&lt;br /&gt;
  protected Color lineColor;&lt;br /&gt;
  protected Insets gap;&lt;br /&gt;
  public RectangleBorder(Color color) {&lt;br /&gt;
    this(color, new Insets(1, 1, 1, 1));&lt;br /&gt;
  }&lt;br /&gt;
  public RectangleBorder(Color color, Insets thickness) {&lt;br /&gt;
    this(color, thickness, thickness);&lt;br /&gt;
  }&lt;br /&gt;
  public RectangleBorder(Color color, Insets thickness, Insets gap) {&lt;br /&gt;
    lineColor = color;&lt;br /&gt;
    this.thickness = thickness;&lt;br /&gt;
    this.gap = gap;&lt;br /&gt;
  }&lt;br /&gt;
  public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {&lt;br /&gt;
    Color oldColor = g.getColor();&lt;br /&gt;
 &lt;br /&gt;
    g.setColor(lineColor);&lt;br /&gt;
    // top&lt;br /&gt;
    for (int i = 0; i &amp;lt; thickness.top; i++) {&lt;br /&gt;
      g.drawLine(x, y + i, x + width, y + i);&lt;br /&gt;
    }&lt;br /&gt;
    // bottom&lt;br /&gt;
    for (int i = 0; i &amp;lt; thickness.bottom; i++) {&lt;br /&gt;
      g.drawLine(x, y + height - i - 1, x + width, y + height - i - 1);&lt;br /&gt;
    }&lt;br /&gt;
    // right&lt;br /&gt;
    for (int i = 0; i &amp;lt; thickness.right; i++) {&lt;br /&gt;
      g.drawLine(x + width - i - 1, y, x + width - i - 1, y + height);&lt;br /&gt;
    }&lt;br /&gt;
    // left&lt;br /&gt;
    for (int i = 0; i &amp;lt; thickness.left; i++) {&lt;br /&gt;
      g.drawLine(x + i, y, x + i, y + height);&lt;br /&gt;
    }&lt;br /&gt;
    g.setColor(oldColor);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the insets of the border.&lt;br /&gt;
   * &lt;br /&gt;
   * @param c&lt;br /&gt;
   *          the component for which this border insets value applies&lt;br /&gt;
   */&lt;br /&gt;
  public Insets getBorderInsets(Component c) {&lt;br /&gt;
    return gap;&lt;br /&gt;
  }&lt;br /&gt;
  public Insets getBorderInsets(Component c, Insets insets) {&lt;br /&gt;
    insets.left = gap.left;&lt;br /&gt;
    insets.top = gap.top;&lt;br /&gt;
    insets.right = gap.right;&lt;br /&gt;
    insets.bottom = gap.bottom;&lt;br /&gt;
    return insets;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the color of the border.&lt;br /&gt;
   */&lt;br /&gt;
  public Color getLineColor() {&lt;br /&gt;
    return lineColor;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the thickness of the border.&lt;br /&gt;
   */&lt;br /&gt;
  public Insets getThickness() {&lt;br /&gt;
    return thickness;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns whether or not the border is opaque.&lt;br /&gt;
   */&lt;br /&gt;
  public boolean isBorderOpaque() {&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
  public Insets getGap() {&lt;br /&gt;
    return gap;&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Right border ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
//com.amkai.borders;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import java.awt.Insets;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.awt.ruponent;&lt;br /&gt;
import javax.swing.border.AbstractBorder;&lt;br /&gt;
public class RightSideBorder extends AbstractBorder&lt;br /&gt;
{&lt;br /&gt;
    protected int thickness;&lt;br /&gt;
    protected Color lineColor;&lt;br /&gt;
    protected int gap;&lt;br /&gt;
    public RightSideBorder(Color color) {&lt;br /&gt;
        this(color, 1, 1);&lt;br /&gt;
    }&lt;br /&gt;
    public RightSideBorder(Color color, int thickness)  {&lt;br /&gt;
        this(color, thickness, thickness);&lt;br /&gt;
    }&lt;br /&gt;
    public RightSideBorder(Color color, int thickness, int gap)  {&lt;br /&gt;
        lineColor = color;&lt;br /&gt;
        this.thickness = thickness;&lt;br /&gt;
        this.gap = gap;&lt;br /&gt;
    }&lt;br /&gt;
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {&lt;br /&gt;
        Color oldColor = g.getColor();&lt;br /&gt;
        int i;&lt;br /&gt;
        g.setColor(lineColor);&lt;br /&gt;
        for(i = 0; i &amp;lt; thickness; i++)  {&lt;br /&gt;
          g.drawLine(x+width-i-1, y, x+width-i-1, y+height);&lt;br /&gt;
        }&lt;br /&gt;
        g.setColor(oldColor);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the insets of the border.&lt;br /&gt;
     * @param c the component for which this border insets value applies&lt;br /&gt;
     */&lt;br /&gt;
    public Insets getBorderInsets(Component c)       {&lt;br /&gt;
        return new Insets(0, 0, 0,gap);&lt;br /&gt;
    }&lt;br /&gt;
    public Insets getBorderInsets(Component c, Insets insets) {&lt;br /&gt;
        insets.left = 0;&lt;br /&gt;
        insets.top = 0;&lt;br /&gt;
        insets.right = gap;&lt;br /&gt;
        insets.bottom = 0;&lt;br /&gt;
        return insets;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the color of the border.&lt;br /&gt;
     */&lt;br /&gt;
    public Color getLineColor()     {&lt;br /&gt;
        return lineColor;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the thickness of the border.&lt;br /&gt;
     */&lt;br /&gt;
    public int getThickness()       {&lt;br /&gt;
        return thickness;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns whether or not the border is opaque.&lt;br /&gt;
     */&lt;br /&gt;
    public boolean isBorderOpaque() { &lt;br /&gt;
        return false; &lt;br /&gt;
    }&lt;br /&gt;
  public int getGap() {&lt;br /&gt;
    return gap;&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Shadow Popup Border ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 2001-2009 JGoodies Karsten Lentzsch. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 *&lt;br /&gt;
 *  o Redistributions of source code must retain the above copyright notice,&lt;br /&gt;
 *    this list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 *  o Redistributions in binary form must reproduce the above copyright notice,&lt;br /&gt;
 *    this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 *    and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 *  o Neither the name of JGoodies Karsten Lentzsch nor the names of&lt;br /&gt;
 *    its contributors may be used to endorse or promote products derived&lt;br /&gt;
 *    from this software without specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS IS&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;&lt;br /&gt;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,&lt;br /&gt;
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE&lt;br /&gt;
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,&lt;br /&gt;
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.awt.ruponent;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import java.awt.Image;&lt;br /&gt;
import java.awt.Insets;&lt;br /&gt;
import javax.swing.ImageIcon;&lt;br /&gt;
import javax.swing.JComponent;&lt;br /&gt;
import javax.swing.border.AbstractBorder;&lt;br /&gt;
/**&lt;br /&gt;
 * A border with a drop shadow intended to be used as the outer border&lt;br /&gt;
 * of popups. Can paint the screen background if used with heavy-weight&lt;br /&gt;
 * popup windows.&lt;br /&gt;
 *&lt;br /&gt;
 * @author Karsten Lentzsch&lt;br /&gt;
 * @author Andrej Golovnin&lt;br /&gt;
 * @version $Revision: 1.6 $&lt;br /&gt;
 *&lt;br /&gt;
 * @see ShadowPopup&lt;br /&gt;
 * @see ShadowPopupFactory&lt;br /&gt;
 */&lt;br /&gt;
final class ShadowPopupBorder extends AbstractBorder {&lt;br /&gt;
    /**&lt;br /&gt;
     * The drop shadow needs 5 pixels at the bottom and the right hand side.&lt;br /&gt;
     */&lt;br /&gt;
    private static final int SHADOW_SIZE = 5;&lt;br /&gt;
  /**&lt;br /&gt;
   * The singleton instance used to draw all borders.&lt;br /&gt;
   */&lt;br /&gt;
  private static ShadowPopupBorder instance = new ShadowPopupBorder();&lt;br /&gt;
  /**&lt;br /&gt;
   * The drop shadow is created from a PNG image with 8 bit alpha channel.&lt;br /&gt;
   */&lt;br /&gt;
  private static Image shadow&lt;br /&gt;
    = new ImageIcon(ShadowPopupBorder.class.getResource(&amp;quot;shadow.png&amp;quot;)).getImage();&lt;br /&gt;
&lt;br /&gt;
    // Instance Creation *****************************************************&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the singleton instance used to draw all borders.&lt;br /&gt;
   */&lt;br /&gt;
  public static ShadowPopupBorder getInstance() {&lt;br /&gt;
    return instance;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  /**&lt;br /&gt;
   * Paints the border for the specified component with the specified&lt;br /&gt;
     * position and size.&lt;br /&gt;
   */&lt;br /&gt;
  public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {&lt;br /&gt;
    // draw drop shadow&lt;br /&gt;
    g.drawImage(shadow, x +  5, y + height - 5, x + 10, y + height, 0, 6, 5, 11, null, c);&lt;br /&gt;
    g.drawImage(shadow, x + 10, y + height - 5, x + width - 5, y + height, 5, 6, 6, 11, null, c);&lt;br /&gt;
    g.drawImage(shadow, x + width - 5, y + 5, x + width, y + 10, 6, 0, 11, 5, null, c);&lt;br /&gt;
    g.drawImage(shadow, x + width - 5, y + 10, x + width, y + height - 5, 6, 5, 11, 6, null, c);&lt;br /&gt;
    g.drawImage(shadow, x + width - 5, y + height - 5, x + width, y + height, 6, 6, 11, 11, null, c);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the insets of the border.&lt;br /&gt;
   */&lt;br /&gt;
  public Insets getBorderInsets(Component c) {&lt;br /&gt;
    return new Insets(0, 0, SHADOW_SIZE, SHADOW_SIZE);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Reinitializes the insets parameter with this Border&amp;quot;s current Insets.&lt;br /&gt;
     * @param c the component for which this border insets value applies&lt;br /&gt;
     * @param insets the object to be reinitialized&lt;br /&gt;
     * @return the &amp;lt;code&amp;gt;insets&amp;lt;/code&amp;gt; object&lt;br /&gt;
     */&lt;br /&gt;
    public Insets getBorderInsets(Component c, Insets insets) {&lt;br /&gt;
        insets.left = insets.top = 0;&lt;br /&gt;
        insets.right = insets.bottom = SHADOW_SIZE;&lt;br /&gt;
        return insets;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Swing Abstract Border ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.awt.Container;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.awt.event.ItemEvent;&lt;br /&gt;
import java.awt.event.ItemListener;&lt;br /&gt;
import java.awt.event.WindowAdapter;&lt;br /&gt;
import java.awt.event.WindowEvent;&lt;br /&gt;
import javax.swing.ButtonGroup;&lt;br /&gt;
import javax.swing.ImageIcon;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JMenu;&lt;br /&gt;
import javax.swing.JMenuBar;&lt;br /&gt;
import javax.swing.JMenuItem;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
import javax.swing.JRadioButtonMenuItem;&lt;br /&gt;
import javax.swing.border.AbstractBorder;&lt;br /&gt;
import javax.swing.border.BevelBorder;&lt;br /&gt;
import javax.swing.border.rupoundBorder;&lt;br /&gt;
import javax.swing.border.EmptyBorder;&lt;br /&gt;
import javax.swing.border.EtchedBorder;&lt;br /&gt;
import javax.swing.border.LineBorder;&lt;br /&gt;
import javax.swing.border.MatteBorder;&lt;br /&gt;
import javax.swing.border.SoftBevelBorder;&lt;br /&gt;
import javax.swing.border.TitledBorder;&lt;br /&gt;
public class SwingBorder extends JFrame {&lt;br /&gt;
  Container frameContainer;&lt;br /&gt;
  JPanel panel = new JPanel();&lt;br /&gt;
  JMenuBar menuBar = new JMenuBar();&lt;br /&gt;
  JMenu fileMenu = new JMenu(&amp;quot;File&amp;quot;);&lt;br /&gt;
  JMenuItem fileExit = new JMenuItem(&amp;quot;Exit&amp;quot;);&lt;br /&gt;
  JMenu borderMenu = new JMenu(&amp;quot;Border&amp;quot;);&lt;br /&gt;
  String[] borderTypes = { &amp;quot;Bevel&amp;quot;, &amp;quot;Compound&amp;quot;, &amp;quot;Empty&amp;quot;, &amp;quot;Etched&amp;quot;, &amp;quot;Line&amp;quot;, &amp;quot;Matte&amp;quot;, &amp;quot;SoftBevel&amp;quot;,&lt;br /&gt;
      &amp;quot;Titled&amp;quot; };&lt;br /&gt;
  JRadioButtonMenuItem[] borders = new JRadioButtonMenuItem[borderTypes.length];&lt;br /&gt;
  AbstractBorder[] border = { new BevelBorder(BevelBorder.LOWERED),&lt;br /&gt;
      new CompoundBorder(new LineBorder(Color.blue, 10), new LineBorder(Color.red, 5)),&lt;br /&gt;
      new EmptyBorder(10, 10, 10, 10), new EtchedBorder(), new LineBorder(Color.blue, 10),&lt;br /&gt;
      new MatteBorder(new ImageIcon(&amp;quot;phone.gif&amp;quot;)), new SoftBevelBorder(BevelBorder.RAISED),&lt;br /&gt;
      new TitledBorder(&amp;quot;TitledBorder&amp;quot;) };&lt;br /&gt;
  ButtonGroup buttonGroup = new ButtonGroup();&lt;br /&gt;
  public SwingBorder() {&lt;br /&gt;
    super(&amp;quot;&amp;quot;);&lt;br /&gt;
    fileMenu.add(fileExit);&lt;br /&gt;
    for (int i = 0; i &amp;lt; borderTypes.length; ++i) {&lt;br /&gt;
      borders[i] = new JRadioButtonMenuItem(borderTypes[i]);&lt;br /&gt;
      buttonGroup.add(borders[i]);&lt;br /&gt;
      borderMenu.add(borders[i]);&lt;br /&gt;
    }&lt;br /&gt;
    menuBar.add(fileMenu);&lt;br /&gt;
    menuBar.add(borderMenu);&lt;br /&gt;
    setJMenuBar(menuBar);&lt;br /&gt;
    frameContainer = getContentPane();&lt;br /&gt;
    frameContainer.setLayout(new BorderLayout());&lt;br /&gt;
    frameContainer.add(&amp;quot;Center&amp;quot;, panel);&lt;br /&gt;
    setupEventHandlers();&lt;br /&gt;
    setSize(450, 450);&lt;br /&gt;
    setVisible(true);&lt;br /&gt;
  }&lt;br /&gt;
  void setupEventHandlers() {&lt;br /&gt;
    addWindowListener(new WindowHandler());&lt;br /&gt;
    fileExit.addActionListener(new MenuItemHandler());&lt;br /&gt;
    for (int i = 0; i &amp;lt; borders.length; ++i)&lt;br /&gt;
      borders[i].addItemListener(new ItemHandler());&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    SwingBorder app = new SwingBorder();&lt;br /&gt;
  }&lt;br /&gt;
  public class WindowHandler extends WindowAdapter {&lt;br /&gt;
    public void windowClosing(WindowEvent e) {&lt;br /&gt;
      System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public class MenuItemHandler implements ActionListener {&lt;br /&gt;
    public void actionPerformed(ActionEvent e) {&lt;br /&gt;
      String cmd = e.getActionCommand();&lt;br /&gt;
      if (cmd.equals(&amp;quot;Exit&amp;quot;))&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public class ItemHandler implements ItemListener {&lt;br /&gt;
    public void itemStateChanged(ItemEvent e) {&lt;br /&gt;
      JRadioButtonMenuItem button = (JRadioButtonMenuItem) e.getItem();&lt;br /&gt;
      String label = button.getText();&lt;br /&gt;
      for (int i = 0; i &amp;lt; borderTypes.length; ++i) {&lt;br /&gt;
        if (label.equals(borderTypes[i])) {&lt;br /&gt;
          panel.setBorder(border[i]);&lt;br /&gt;
          repaint();&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>