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

📄 confirmpanel.java

📁 Java写的ERP系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
 * 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.apps;

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

import org.compiere.util.*;
import org.compiere.swing.*;

/**
 *  Application Confirm Panel.
 *  <code>
 *  if (e.getActionCommand().equals(ConfirmPanel.A_OK))
 *  </code>
 *  @author 	Jorg Janke
 *  @version 	$Id: ConfirmPanel.java,v 1.14 2003/02/14 06:44:13 jjanke Exp $
 */
public final class ConfirmPanel extends CPanel
{
	/**
	 *	Create Confirmation Panel with OK Button
	 */
	public ConfirmPanel()
	{
		this (false, false, false, false, false, true);
	}	//	ConfirmPanel

	/**
	 *	Create Confirmation Panel with OK and Cancel Button
	 *  @param withCancelButton with cancel
	 */
	public ConfirmPanel(boolean withCancelButton)
	{
		this (withCancelButton, false, false, false, false, true);
	}	//	ConfirmPanel

	/**
	 *	Create Confirmation Panel with different buttons
	 *  @param withCancelButton with cancel
	 *  @param withRefreshButton with refresh
	 *  @param withCustomizeButton with customize
	 *  @param withHistoryButton with history
	 *  @param withZoomButton with zoom
	 *  @param withText with text
	 */
	public ConfirmPanel(boolean withCancelButton,
		boolean withRefreshButton, boolean withCustomizeButton,
		boolean withHistoryButton, boolean withZoomButton,
		boolean withText)
	{
		super();
		BorderLayout mainLayout = new BorderLayout();
		this.setLayout(mainLayout);
		this.setName("confirmPanel");
		//
		CPanel okCancel = new CPanel(new FlowLayout(FlowLayout.RIGHT));
		okCancel.setOpaque(false);
		bCancel = createCancelButton(withText);
		okCancel.add(bCancel);
		bOK = createOKButton(withText);
		okCancel.add(bOK);
		setCancelVisible(withCancelButton);
		this.add(okCancel, BorderLayout.EAST);
		//
		if (withRefreshButton)
		{
			bRefresh = createRefreshButton(withText);
			addComponent(bRefresh);
		}
		if (withCustomizeButton)
		{
			bCustomize = createCustomizeButton(withText);
			addComponent(bCustomize);
		}
		if (withHistoryButton)
		{
			bHistory = createHistoryButton(withText);
			addComponent(bHistory);
		}
		if (withZoomButton)
		{
			bZoom = createZoomButton(withText);
			addComponent(bZoom);
		}
	}	//	ConfirmPanel

	/**	Additional Buttons Panel			*/
	private CPanel  m_addlButtons = null;

	private CButton bOK;
	private CButton bCancel;
	private CButton bRefresh;
	private CButton bCustomize;
	private CButton bHistory;
	private CButton bZoom;

	/**
	 *  Add Button to left side of confirmPanel
	 *  @param button button
	 */
	public void addComponent (Component button)
	{
		if (m_addlButtons == null)
		{
			m_addlButtons = new CPanel(new FlowLayout(FlowLayout.LEFT));
			this.add(m_addlButtons, BorderLayout.WEST);
		}
		m_addlButtons.add(button);
	}   //  addButton

	/**
	 *  Add Button to left side of confirmPanel
	 *  @param action action command
	 *  @param toolTipText tool tip text
	 *  @param icon icon
	 *  @param mnemonic mnemonic
	 *  @return JButton
	 */
	public JButton addButton (String action, String toolTipText, Icon icon, int mnemonic)
	{
		JButton b = new DialogButton (action, toolTipText, icon, mnemonic);
		addComponent (b);
		return b;
	}   //  addButton

	/**
	 *  Add Button to left side of confirmPanel
	 *  @param button button
	 *  @return JButton
	 */
	public JButton addButton (JButton button)
	{
		addComponent (button);
		return button;
	}   //  addButton

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

	/**	Action String OK        */
	public static final String A_OK = "OK";
	/**	Action String Cancel    */
	public static final String A_CANCEL = "Cancel";
	/**	Action String Refresh   */
	public static final String A_REFRESH = "Refresh";
	/**	Action String Customize */
	public static final String A_CUSTOMIZE = "Customize";
	/**	Action String History   */
	public static final String A_HISTORY = "History";
	/**	Action String Zoom      */
	public static final String A_ZOOM = "Zoom";

	/** Action String Process   */
	public static final String A_PROCESS = "Process";
	/** Action String Print     */
	public static final String A_PRINT = "Print";
	/** Action String Export    */
	public static final String A_EXPORT = "Export";
	/** Action String Help      */
	public static final String A_HELP = "Help";
	/**	Action String Cancel    */
	public static final String A_DELETE = "Delete";

	/**	Standard Insets used    */
	public static Insets 	s_insets = new Insets (0, 10, 0, 10);

	/**
	 *	Create OK Button with label text
	 *  @param text text
	 *  @return OK Button
	 */
	public static final CButton createOKButton (String text)
	{
		CButton okButton = new DialogButton (A_OK, text, Env.getImageIcon("Ok24.gif"), KeyEvent.VK_O);
		okButton.setDefaultCapable(true);
		return okButton;
	}	//	createOKButton

	/**
	 *	Create OK Button with Standard text
	 *  @param withText with text
	 *  @return OK Button
	 */
	public static final CButton createOKButton (boolean withText)
	{
		if (withText)
			return createOKButton(Msg.getMsg(Env.getCtx(), A_OK));
		return createOKButton(null);
	}	//	createOKButton

	/**
	 *	Get OK Button
	 *  @return OK Button
	 */
	public CButton getOKButton()
	{
		return bOK;
	}	//	getOKButton


	/**
	 *	Create Cancel Button wlth label text and register ESC and Alt-X as KeyStroke
	 *  @param text text
	 *  @return Cancel Button
	 */
	public static final CButton createCancelButton (String text)
	{
		CButton cancel = new DialogButton (A_CANCEL, text, Env.getImageIcon("Cancel24.gif"), KeyEvent.VK_X);
		//	ESC = Ignore
		cancel.getInputMap(CButton.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), A_CANCEL);
		cancel.getActionMap().put(A_CANCEL, cancel.getAction());
		return cancel;
	}	//	createCancelButton

	/**
	 *	Create Cancel Button wlth Standard text
	 *  @param withText with text
	 *  @return Button
	 */
	public static final CButton createCancelButton(boolean withText)
	{
		if (withText)
			return createCancelButton(Msg.getMsg(Env.getCtx(), A_CANCEL));
		return createCancelButton(null);
	}	//	createCancelButton

	/**
	 *	Get Cancel Button
	 *  @return Cancel Button
	 */
	public CButton getCancelButton()
	{
		return bCancel;
	}	//	getCancelButton


	/**
	 *	Show OK button
	 *  @param value true for visible
	 */
	public void setOKVisible (boolean value)
	{
		bOK.setVisible(value);
		bOK.setEnabled(value);
	}	//	setOKVisible

	/**
	 *	Is OK Visible
	 *  @return true of OK visisble
	 */
	public boolean isOKVisible()
	{
		return bOK.isVisible();
	}	//	isOKVisible

	/**
	 *	Show Cancel button
	 *  @param value trie for visible
	 */
	public void setCancelVisible (boolean value)
	{
		bCancel.setVisible(value);
		bCancel.setEnabled(value);
	}	//	setCancelVisible

	/**
	 *	Is Cancel Visible
	 *  @return true if Canvel is visible
	 */
	public boolean isCancelVisible()
	{
		return bCancel.isVisible();
	}	//	isCancelVisible


	/**
	 *	Create Refresh Button wlth label text
	 *  @param text text
	 *  @return button
	 */
	public static final CButton createRefreshButton (String text)
	{
		CButton refresh = new DialogButton (A_REFRESH, text, Env.getImageIcon("Refresh24.gif"), 0);
		//	F5 = Refresh
		refresh.getInputMap(CButton.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), A_REFRESH);
		refresh.getActionMap().put(A_REFRESH, refresh.getAction());
		return refresh;
	}	//	createRefreshButton

	/**
	 *	Create Refresh Button wlth Standard text
	 *  @param withText with text
	 *  @return Button
	 */
	public static final CButton createRefreshButton (boolean withText)
	{
		if (withText)
			return createRefreshButton(Msg.getMsg(Env.getCtx(), "Refresh"));
		return createRefreshButton(null);
	}	//	createRefreshButton

	/**
	 *	Get Refresh Button
	 *  @return Button
	 */
	public CButton getRefreshButton()
	{
		return bRefresh;
	}	//	getRefreshButton


	/**
	 *	Create Customize Button wlth label text
	 *  @param text text
	 *  @return button
	 */
	public static final CButton createCustomizeButton (String text)
	{
		return new DialogButton (A_CUSTOMIZE, text, Env.getImageIcon("Preference24.gif"), 0);
	}	//	createCustomizeButton

⌨️ 快捷键说明

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