All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.tidalwave.swing.RoundedPanel Maven / Gradle / Ivy

There is a newer version: 2.13.61
Show newest version
/***********************************************************************************************************************
 *
 * OpenBlueSky - NetBeans Platform Enhancements
 * Copyright (C) 2006-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
 *
 ***********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations under the License.
 *
 ***********************************************************************************************************************
 *
 * WWW: http://openbluesky.kenai.com
 * SCM: https://kenai.com/hg/openbluesky~src
 *
 **********************************************************************************************************************/
package it.tidalwave.swing;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JPanel;

/*******************************************************************************
 * 
 * @author  Fabrizio Giudici
 * @version $Id$
 *
 ******************************************************************************/
public class RoundedPanel extends JPanel
  {
    private int radius = 20;
    
    public RoundedPanel()
      {
      }
    
    public RoundedPanel (final int radius)
      {
        this.radius = radius;
      }
    
    @Override
    public void paint (final Graphics g)
      {
        final Graphics2D g2 = (Graphics2D)g;
        final Object antiAliasingSave = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setColor(getBackground());
        g.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, radius, radius);
        paintComponents(g);
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAliasingSave);
      }
  }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy