1 2 package com.memoire.vainstall.xui; 3 4 import java.awt.*; 5 import javax.swing.*; 6 import javax.swing.border.*; 7 8 public class XuiPanel extends JPanel 9 { 10 public XuiPanel() 11 { 12 super(); 13 setBackground(new Color(128,192,192)); 14 setForeground(new Color( 64, 96, 96)); 15 setBorder(null); 16 setOpaque(true); 17 } 18 19 public void paint(Graphics _g) 20 { 21 ((Graphics2D)_g).setRenderingHint 22 (RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); 23 super.paint(_g); 24 } 25 26 public void paintComponent(Graphics _g) 27 { 28 if(!isOpaque()) return; 29 30 Color bg=getBackground(); 31 Color fg=getForeground(); 32 33 int rb=bg.getRed(); 34 int gb=bg.getGreen(); 35 int bb=bg.getBlue(); 36 int rf=fg.getRed(); 37 int gf=fg.getGreen(); 38 int bf=fg.getBlue(); 39 40 int w=getWidth(); 41 int h=getHeight(); 42 43 int jmin=0; 44 int jmax=h; 45 46 Rectangle clip=_g.getClipBounds(); 47 if(clip!=null) 48 { 49 jmin=clip.y; 50 jmax=clip.y+clip.height; 51 } 52 53 for(int j=jmin; j<jmax; j++) 54 { 55 _g.setColor(new Color(Math.min(255,rb+(rf-rb)*j/(h-1)+j%2), 56 Math.min(255,gb+(gf-gb)*j/(h-1)+j%3), 57 Math.min(255,bb+(bf-bb)*j/(h-1)+j%4))); 58 _g.drawLine(0,j,w-1,j); 59 } 60 } 61 } 62 | Popular Tags |