⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctabbedpane.java

📁 Java写的ERP系统
💻 JAVA
字号:
/******************************************************************************
 * The contents of this file are subject to the   Compiere License  Version 1.1
 * ("License"); You may not use this file except in compliance with the License
 * You may obtain a copy of the License at http://www.compiere.org/license.html
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * The Original Code is                  Compiere  ERP & CRM  Business Solution
 * The Initial Developer of the Original Code is Jorg Janke  and ComPiere, Inc.
 * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
 * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
 * Contributor(s): ______________________________________.
 *****************************************************************************/
package org.compiere.swing;

import java.awt.*;
import javax.swing.*;
import javax.swing.JTabbedPane;

import org.compiere.plaf.*;
import org.compiere.util.*;

/**
 *  Compiere Color Tabbed Pane
 *
 *  @author     Jorg Janke
 *  @version    $Id: CTabbedPane.java,v 1.10 2002/09/01 22:34:37 jjanke Exp $
 */
public class CTabbedPane extends JTabbedPane
{
	/**
	 * Creates an empty <code>TabbedPane</code> with a default
	 * tab placement of <code>JTabbedPane.TOP</code> and default
	 * tab layout policy of <code>JTabbedPane.WRAP_TAB_LAYOUT</code>.
	 * @see #addTab
	 */
	public CTabbedPane()
	{
		super();
		init();
	}   //  CTabbedPane

	/**
	 * Creates an empty <code>TabbedPane</code> with the specified tab placement
	 * of either: <code>JTabbedPane.TOP</code>, <code>JTabbedPane.BOTTOM</code>,
	 * <code>JTabbedPane.LEFT</code>, or <code>JTabbedPane.RIGHT</code>, and a
	 * default tab layout policy of <code>JTabbedPane.WRAP_TAB_LAYOUT</code>.
	 *
	 * @param tabPlacement the placement for the tabs relative to the content
	 */
	public CTabbedPane(int tabPlacement)
	{
		super(tabPlacement);
		init();
	}   //  CTabbedPane

	/**
	 * Creates an empty <code>TabbedPane</code> with the specified tab placement
	 * and tab layout policy.  Tab placement may be either:
	 * <code>JTabbedPane.TOP</code>, <code>JTabbedPane.BOTTOM</code>,
	 * <code>JTabbedPane.LEFT</code>, or <code>JTabbedPane.RIGHT</code>.
	 * Tab layout policy may be either: <code>JTabbedPane.WRAP_TAB_LAYOUT</code>
	 * or <code>JTabbedPane.SCROLL_TAB_LAYOUT</code>.
	 *
	 * @param tabPlacement the placement for the tabs relative to the content
	 * @param tabLayoutPolicy the policy for laying out tabs when all tabs will not fit on one run
	 * @exception IllegalArgumentException if tab placement or tab layout policy are not
	 *            one of the above supported values
	 */
	public CTabbedPane(int tabPlacement, int tabLayoutPolicy)
	{
		super (tabPlacement, tabLayoutPolicy);
		init();
	}   //  CTabbedPane

	/**
	 * Creates an empty <code>TabbedPane</code> with a defaults and Color
	 * @param bg Color
	 */
	public CTabbedPane (CompiereColor bg)
	{
		super();
		init();
		setBackgroundColor (bg);
	}   //  CTabbedPane

	/**
	 *  Common Init
	 */
	private void init()
	{
		setOpaque(false);
		setFont(CompierePLAF.getFont_Label());
		setForeground(CompierePLAF.getTextColor_Label());
	}   //  init

	/*************************************************************************/

	/**
	 *  Set Background - ignored by UI -
	 *  @param bg ignored
	 */
	public void setBackground (Color bg)
	{
		if (bg.equals(getBackground()))
			return;
		super.setBackground (bg);
		//  ignore calls from javax.swing.LookAndFeel.installColors(LookAndFeel.java:61)
		if (!Trace.getCallerClass(1).startsWith("javax"))
			setBackgroundColor (new CompiereColor(bg));
	}   //  setBackground

	/**
	 *  Set Standard Background
	 */
	public void setBackgroundColor ()
	{
		setBackgroundColor (null);
	}   //  setBackground

	/**
	 *  Set Background
	 *  @param bg CompiereColor for Background, if null set standard background
	 */
	public void setBackgroundColor (CompiereColor bg)
	{
		if (bg == null)
			bg = CompierePanelUI.getDefaultBackground();
		setOpaque(true);
		putClientProperty(CompierePLAF.BACKGROUND, bg);
		super.setBackground (bg.getFlatColor());
		//
		repaint();
	}   //  setBackground

	/**
	 *  Get Background
	 *  @return Color for Background
	 */
	public CompiereColor getBackgroundColor ()
	{
		try
		{
			return (CompiereColor)getClientProperty(CompierePLAF.BACKGROUND);
		}
		catch (Exception e)
		{
			System.err.println("CPanel - ClientProperty: " + e.getMessage());
		}
		return null;
	}   //  getBackgroundColor

	/*************************************************************************/

	/**
	 * Insert tab.
	 * If the component is a JPanel, the backround is set to the default
	 * CompiereColor (and Opaque) if nothing was defined.
	 * Redquired as otherwise a gray background would be pained.
	 * <p>
	 * Inserts a <code>component</code>, at <code>index</code>,
	 * represented by a <code>title</code> and/or <code>icon</code>,
	 * either of which may be <code>null</code>. If <code>icon</code>
	 * is non-<code>null</code> and it implements
	 * <code>ImageIcon</code> a corresponding disabled icon will automatically
	 * be created and set on the tabbedpane.
	 * Uses java.util.Vector internally, see <code>insertElementAt</code>
	 * for details of insertion conventions.
	 *
	 * @param title the title to be displayed in this tab
	 * @param icon the icon to be displayed in this tab
	 * @param component The component to be displayed when this tab is clicked.
	 * @param tip the tooltip to be displayed for this tab
	 * @param index the position to insert this new tab
	 */
	public void insertTab (String title, Icon icon, Component component, String tip, int index)
	{
		super.insertTab (title, icon, component, tip, index);
		//  Set component background
		if (component instanceof JPanel)
		{
			JPanel p = (JPanel)component;
			if (p.getClientProperty(CompierePLAF.BACKGROUND) == null)
			{
				CompiereColor.setBackground(p);
				p.setOpaque(true);
			}
		}
	}   //  insertTab

	/**
	 *  String representation
	 *  @return String representation
	 */
	public String toString()
	{
		StringBuffer sb = new StringBuffer ("CTabbedPane [");
		sb.append(super.toString());
		CompiereColor bg = getBackgroundColor();
		if (bg != null)
			sb.append(bg.toString());
		sb.append("]");
		return sb.toString();
	}   //  toString

}   //  CTabbedPane

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -