KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > swing > border > LineBorder

javax.swing.border
Class LineBorder

java.lang.Object
  extended by javax.swing.border.AbstractBorder
      extended by javax.swing.border.LineBorder
All Implemented Interfaces:
Serializable, Border
Direct Known Subclasses:
BorderUIResource.LineBorderUIResource
See Also:
Top Examples, Source Code, XMLEncoder

public static Border createBlackLineBorder()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1392]How to create a black border after an image is loaded on the JPanel?
By wengfattpang { at } yahoo { dot } com on 2005/04/14 01:23:39  Rate
I wanna to create a a black border after my image is loaded on the JPanel. 
  
  
 This is how I do but it does not work. 
  
  
 class DisplayPanel extends JPanel 
  {  
   Image displayImage; 
  
  
   public DisplayPanel ( String file )  
    {  
        
       setBorder ( new LineBorder ( Color.black )  ) ; 
       displayImage = Toolkit.getDefaultToolkit (  ) .getImage ( file ) ; 
  
  
     MediaTracker mt = new MediaTracker ( this ) ; 
     mt.addImage ( displayImage, 1 ) ; 
     try  {  
       mt.waitForAll (  ) ; 
      }  catch  ( Exception e )   {  
       System.out.println ( "Exception while loading." ) ; 
      }  
  
  
     if  ( displayImage.getWidth ( this )  == -1 )   {  
       System.out.println ( "No *.jpg file" ) ; 
       System.exit ( 0 ) ; 
        }  
       else  {  
       repaint (  ) ; 
      }  
    }  
  
  
   public void paint ( Graphics g )   {  
       Graphics2D g2D =  ( Graphics2D )  g; 
  
  
       BufferedImage bi =  ( BufferedImage )  createImage ( getWidth (  ) , getHeight (  )  ) ; 
  
  
     // Draw into the memory buffer. 
     for  ( int i = 0; i  <  getWidth (  ) ; i = i + displayImage.getWidth ( this )  )  
      {  
       for  ( int j = 0; j  <  getHeight (  ) ; j = j + displayImage.getHeight ( this )  )  
        {  
       bi.createGraphics (  ) .drawImage ( displayImage, i, j, this ) ; 
        }  
      }  
     // Draw the buffered Image on to the screen 
     g2D.drawImage ( bi, 0, 0, this ) ; 
    }  
  }  
 


public static Border createGrayLineBorder()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Insets getBorderInsets(Component c)
See Also:
AbstractBorder, Border
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Insets getBorderInsets(Component c,
                              Insets insets)
See Also:
AbstractBorder
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Color getLineColor()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean getRoundedCorners()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getThickness()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isBorderOpaque()
See Also:
AbstractBorder, Border
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public LineBorder(Color color)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public LineBorder(Color color,
                  int thickness)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public LineBorder(Color color,
                  int thickness,
                  boolean roundedCorners)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected Color lineColor
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void paintBorder(Component c,
                        Graphics g,
                        int x,
                        int y,
                        int width,
                        int height)
See Also:
AbstractBorder, Border
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected boolean roundedCorners
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected int thickness
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags