Right border : Border « Swing JFC « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JavaFX
25.JDK 6
26.JDK 7
27.JNDI LDAP
28.JPA
29.JSP
30.JSTL
31.Language Basics
32.Network Protocol
33.PDF RTF
34.Reflection
35.Regular Expressions
36.Scripting
37.Security
38.Servlets
39.Spring
40.Swing Components
41.Swing JFC
42.SWT JFace Eclipse
43.Threads
44.Tiny Application
45.Velocity
46.Web Services SOA
47.XML
Java » Swing JFC » Border 




Right border
  
//com.amkai.borders;

import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Color;
import java.awt.Component;

import javax.swing.border.AbstractBorder;

public class RightSideBorder extends AbstractBorder
{
    protected int thickness;
    protected Color lineColor;
    protected int gap;

    public RightSideBorder(Color color) {
        this(color, 11);
    }

    public RightSideBorder(Color color, int thickness)  {
        this(color, thickness, thickness);
    }

    public RightSideBorder(Color color, int thickness, int gap)  {
        lineColor = color;
        this.thickness = thickness;
        this.gap = gap;
    }

    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
        Color oldColor = g.getColor();
        int i;

        g.setColor(lineColor);
        for(i = 0; i < thickness; i++)  {
          g.drawLine(x+width-i-1, y, x+width-i-1, y+height);
        }
        g.setColor(oldColor);
    }

    /**
     * Returns the insets of the border.
     @param c the component for which this border insets value applies
     */
    public Insets getBorderInsets(Component c)       {
        return new Insets(000,gap);
    }

    public Insets getBorderInsets(Component c, Insets insets) {
        insets.left = 0;
        insets.top = 0;
        insets.right = gap;
        insets.bottom = 0;
        return insets;
    }

    /**
     * Returns the color of the border.
     */
    public Color getLineColor()     {
        return lineColor;
    }

    /**
     * Returns the thickness of the border.
     */
    public int getThickness()       {
        return thickness;
    }

    /**
     * Returns whether or not the border is opaque.
     */
    public boolean isBorderOpaque() { 
        return false
    }

  public int getGap() {
    return gap;
  }

}

   
    
  














Related examples in the same category
1.Border Demo Border Demo
2.Different Swing bordersDifferent Swing borders
3.demonstrate the custom CurvedBorder classdemonstrate the custom CurvedBorder class
4.An example of the MatteBorder classAn example of the MatteBorder class
5.A simple demonstration of the LineBorder class built with rounded cornersA simple demonstration of the LineBorder class built with rounded corners
6.An example of using a titled border on a labelAn example of using a titled border on a label
7.Borders with a BevelBorder used on JLabels as a highlightBorders with a BevelBorder used on JLabels as a highlight
8.MatteBorder DemoMatteBorder Demo
9.TitledBorder DemoTitledBorder Demo
10.Custom Border SampleCustom Border Sample
11.How to create the borderHow to create the border
12.Solid border button border 3D borderSolid border button border 3D border
13.Oval borderOval border
14.Border of all kindsBorder of all kinds
15.EtchedBorderEtchedBorder
16.Red Green BorderRed Green Border
17.TitledBorderTitledBorder
18.TitledBorder 3TitledBorder 3
19.BevelBorder 2BevelBorder 2
20.Icon MatteBorderIcon MatteBorder
21.Soft BevelBorderSoft BevelBorder
22.Another TitledBorder 1Another TitledBorder 1
23.BevelBorderBevelBorder
24.EmptyBorderEmptyBorder
25.LineBorder DemoLineBorder Demo
26.CompoundBorder DemoCompoundBorder Demo
27.Adding a Title to a Border
28.Create a title border from another border
29.Change border text Justification alignment style
30.Bottom Border
31.Rectangle border
32.Set title position
33.Flex Border
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.