📄 compierepanelui.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.plaf;
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import java.net.*;
/**
* Panel UI.
* The default properties can be set via
* <pre>
* CompierePanelUI.setDefaultBackground (new CompiereColor());
* </pre>
* The individual Panel can set the background type by setting the
* parameter via
* <pre>
* putClientProperty(CompierePanelUI.BACKGROUND, new CompiereColor());
* </pre>
* @see org.compiere.swing.CPanel
*
* @author Jorg Janke
* @version $Id: CompierePanelUI.java,v 1.11 2002/08/12 01:55:15 danb Exp $
*/
public class CompierePanelUI extends BasicPanelUI
{
/**
* Static Create UI
* @param c Vomponent
* @return Compiere Panel UI
*/
public static ComponentUI createUI (JComponent c)
{
// return new CompierePanelUI();
return s_panelUI;
} // createUI
/** UI */
private static CompierePanelUI s_panelUI = new CompierePanelUI();
/*************************************************************************/
/**
* Install Defaults
* @param p Panel
*/
protected void installDefaults (JPanel p)
{
super.installDefaults(p);
if (s_setDefault && p.getClientProperty(CompierePLAF.BACKGROUND) == null)
p.putClientProperty (CompierePLAF.BACKGROUND, s_default);
} // installDefaults
/*************************************************************************/
/**
* Update -
* This method is invoked by <code>JComponent</code> when the specified
* component is being painted.
*
* By default this method will fill the specified component with
* its background color (if its <code>opaque</code> property is
* <code>true</code>) and then immediately call <code>paint</code>.
*
* @param g the <code>Graphics</code> context in which to paint
* @param c the component being painted
*
* @see #paint
* @see javax.swing.JComponent#paintComponent
*/
public void update (Graphics g, JComponent c)
{
// CompiereUtils.printParents (c);
if (c.isOpaque())
updateIt (g, c);
paint (g, c); // does nothing
} // update
/**
* Print background based on CompiereColor or flat background if not found
* @param g
* @param c
*/
static void updateIt (Graphics g, JComponent c)
{
// System.out.print("Panel " + c.getName());
// System.out.print(" Bounds=" + c.getBounds().toString());
// System.out.print(" - Background: ");
// Get CompiereColor
CompiereColor bg = null;
try
{
bg = (CompiereColor)c.getClientProperty(CompierePLAF.BACKGROUND);
}
catch (Exception e)
{
System.err.println("CompierePanelUI - ClientProperty: " + e.getMessage());
}
// paint compiere background
if (bg != null)
{
// System.out.print(bg);
bg.paint (g, c);
}
else
{
// System.out.print(c.getBackground());
g.setColor(c.getBackground());
g.fillRect(0,0, c.getWidth(), c.getHeight());
}
// System.out.println();
} // updateIt
/*************************************************************************/
/** Default Background */
private static CompiereColor s_default = new CompiereColor();
/** Set Background to default language */
private static boolean s_setDefault = false;
/**
* Set Default Background
* @param bg Background Color
*/
public static void setDefaultBackground (CompiereColor bg)
{
if (bg == null)
return;
s_default.setColor(bg);
} // setBackground
/**
* Get Default Background
* @return Background
*/
public static CompiereColor getDefaultBackground()
{
return s_default;
} // getBackground
/**
* Set Default Background
* @param setDefault if trie, the background will be set to the default color
*/
public static void setSetDefault (boolean setDefault)
{
s_setDefault = setDefault;
} // setSetDefault
/**
* Is the Default Background set by default
* @return true if default background is set
*/
public static boolean isSetDefault()
{
return s_setDefault;
} // isSetDefault
} // CompierePanel
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -