@Override
	public void draw(Graphics g) {
		
		int width = getWidth();
		int height = getHeight();
		
		if (width == -1 || height == -1)
			return;
		
		g.setClip(getRealX(), getRealY(), width, height);
		
		if (this.hasBackground())
			g.setColor(getBackground());
		else
			g.setColor(Color.darkGray);
		
		g.fillRect(getRealX(), getRealY(), width, height);
		
		if (this.hasBorder())
			g.setColor(getBorder().getColor());
		else
			g.setColor(new Color(150,150,150));
		
		g.drawRect(getRealX(), getRealY(), width-1, height-1);
		
		if (hasText()) {
			
			g.setColor(getTextColor());
			
			int x = getRealX() , y = getRealY();
			
			if (textcenterx) {
				x -= g.getFont().getWidth(getDisplayText())/2;
				
				if (hasWidth())
					x += getWidth()/2;
			}
			
			if (textcentery) {
				y -= g.getFont().getHeight(getDisplayText())/2;
				
				if (hasHeight())
					y += getHeight()/2;
			}
			
			g.drawString(getDisplayText(), x, y);
			
		}
		
		g.clearClip();
		
	}