Round Corners

Author: Alexei Sokolov 

Very cool round corners based on RuzeeBorders by Steffen Rusitschka.

How to use it:

Add the following line to your HTML:

<head>
<script language="javascript" src="ruzeeborders.js"></script>
...
< /head>

You can get ruzeeborders.js here or here. Note: ruzeeborders.js is distributed under MIT license.

Then in your java code your can use four different border styles:

HTML yourDiv = new HTML("Cool");
Borders.simpleBorder(yourDiv, 5 /* radius */);

or

Borders.glowBorder(yourDiv, 5 /* radius */, 4 /* width */, "#35e" /* color */);

or

Borders.shadowBorder(yourDiv, 5 /*radius */, 4 /* width */);

or

Borders.fadeBorder(yourDiv, 5 /* radius */, 4 /* width */);

Also, draw a border but only on the left and top sides of your element:

Borders.simpleBorder(yourDiv, 5 /* radius */, Borders.LEFT + Borders.TOP);

You can leave your questions or comments here.

Source code:

Borders.java:

/*
Round Corners Widget for GWT
Copyright (C) 2006 Alexei Sokolov http://gwt.components.googlepages.com/

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

package com.gwt.components.client;

import com.google.gwt.user.client.ui.UIObject;

public class Borders {
    public static final int NONE = 0;
    public static final int LEFT = 1;
    public static final int TOP = 2;
    public static final int RIGHT = 4;
    public static final int BOTTOM = 8;
    public static final int ALL = LEFT + TOP + RIGHT + BOTTOM;
  
    public static native void simpleBorder(UIObject obj, int radius) /*-{
      var elem = obj.@com.google.gwt.user.client.ui.UIObject::getElement()();
       
      $wnd.rzCrSimpleBorder(radius).draw(elem);
    }-*/;

    public static native void simpleBorder(UIObject obj, int radius, int where) /*-{
      var elem = obj.@com.google.gwt.user.client.ui.UIObject::getElement()();
   
      $wnd.rzCrSimpleBorder(radius).draw(elem,
        @com.gwt.components.client.Borders::convertWhere(I)(where));
    }-*/;
   
    public static native void glowBorder(UIObject obj, int radius, int width, 
        String color) /*-{
      var elem = obj.@com.google.gwt.user.client.ui.UIObject::getElement()();
       
      $wnd.rzCrGlowBorder(radius, width, color).draw(elem);
    }-*/;

    public static native void glowBorder(UIObject obj, int radius, int width, 
        String color, int where) /*-{
      var elem = obj.@com.google.gwt.user.client.ui.UIObject::getElement()();
   
      $wnd.rzCrGlowBorder(radius, width, color).draw(elem,
        @com.gwt.components.client.Borders::convertWhere(I)(where));
    }-*/;
   
    public static native void shadowBorder(UIObject obj, int radius, int width) /*-{
      var elem = obj.@com.google.gwt.user.client.ui.UIObject::getElement()();
       
      $wnd.rzCrShadowBorder(radius, width).draw(elem);
    }-*/;

    public static native void shadowBorder(UIObject obj, int radius, int width, 
        int where) /*-{
      var elem = obj.@com.google.gwt.user.client.ui.UIObject::getElement()();
   
      $wnd.rzCrShadowBorder(radius, width).draw(elem,
        @com.gwt.components.client.Borders::convertWhere(I)(where));
    }-*/;

    public static native void fadeBorder(UIObject obj, int radius, int width) /*-{
      var elem = obj.@com.google.gwt.user.client.ui.UIObject::getElement()();
   
      $wnd.rzCrFadeBorder(radius, width).draw(elem);
    }-*/;

    public static native void fadeBorder(UIObject obj, int radius, int width, 
        int where) /*-{
      var elem = obj.@com.google.gwt.user.client.ui.UIObject::getElement()();

      $wnd.rzCrFadeBorder(radius, width).draw(elem,
        @com.gwt.components.client.Borders::convertWhere(I)(where));
    }-*/;
   
    public static native String convertWhere(int where) /*-{
      var result = "";
      if (where & @com.gwt.components.client.Borders::LEFT) {
        result += "l";
      }
      if (where & @com.gwt.components.client.Borders::TOP) {
        result += "t";
      }
      if (where & @com.gwt.components.client.Borders::RIGHT) {
        result += "r";
      }
      if (where & @com.gwt.components.client.Borders::BOTTOM) {
        result += "b";
      }
      return result;
    }-*/;
}