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

📄 confirmpanel.java

📁 大家共享愉快, 共享愉快, 共享愉快, 共享愉快,共享愉快
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	 *  @return Product Attribute Button
	 */
	public static final CButton createPAttributeButton (String text)
	{
		AppsAction aa = new AppsAction (A_PATTRIBUTE, null, text);
		CButton button = (CButton)aa.getButton();
		button.setMargin(s_insets);
		return button;
	}	//	createPAttributeButton


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

	/**
	 *	Create New Button with label text - F2
	 *  @param text text
	 *  @return Product Attribute Button
	 */
	public static final CButton createNewButton (String text)
	{
		AppsAction aa = new AppsAction (A_NEW, KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), text);
		CButton button = (CButton)aa.getButton();
		button.setMargin(s_insets);
		return button;
	}	//	createNewButton

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

	/**	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 Reset   	*/
	public static final String A_RESET = "Reset";
	/**	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 Delete    */
	public static final String A_DELETE = "Delete";
	/**	Action String PAttribute	*/
	public static final String A_PATTRIBUTE = "PAttribute";
	/**	Action String New	*/
	public static final String A_NEW = "New";

	/**	Standard Insets used    */
	public static Insets 	s_insets = new Insets (0, 10, 0, 10);
	
	
	/**************************************************************************
	 *	Create Confirmation Panel with OK Button
	 */
	public ConfirmPanel()
	{
		this (false, 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, false, true);
	}	//	ConfirmPanel

	/**
	 *	Create Confirmation Panel with different buttons
	 *  @param withCancelButton with cancel
	 *  @param withRefreshButton with refresh
	 *  @param withResetButton with reset
	 *  @param withCustomizeButton with customize
	 *  @param withHistoryButton with history
	 *  @param withZoomButton with zoom
	 *  @param withText with text
	 */
	public ConfirmPanel(boolean withCancelButton,
		boolean withRefreshButton, 
		boolean withResetButton, 
		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 (withResetButton)
		{
			bReset = createResetButton(withText);
			addComponent(bReset);
		}
		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 bReset;
	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
	 *  @return JButton
	 */
	public CButton addButton (String action, String toolTipText, Icon icon)
	{
		AppsAction aa = new AppsAction(action, null, toolTipText);
		CButton b = (CButton)aa.getButton(); 
//			new DialogButton (action, toolTipText, icon);
		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

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

	/**
	 *	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

	/**
	 *	Get Reset Button
	 *  @return Button
	 */
	public CButton getResetButton()
	{
		return bReset;
	}	//	getResetButton
	
	/**
	 *	Get Customize Button
	 *  @return Button
	 */
	public CButton getCustomizeButton()
	{
		return bCustomize;
	}	//	getCustomizeButton

	/**
	 *	Get History Button
	 *  @return Button
	 */
	public CButton getHistoryButton()
	{
		return bHistory;
	}	//	getHistoryButton
	
	/**
	 *	Get Zoom Button
	 *  @return Button
	 */
	public CButton getZoomButton()
	{
		return bZoom;
	}	//	getZoomyButton

	/**
	 *	Get Refresh Button
	 *  @return Button
	 */
	public CButton getRefreshButton()
	{
		return bRefresh;
	}	//	getRefreshButton
	
	
	/**************************************************************************
	 *	Add Action Listener
	 *  <code>
	 *  if (e.getActionCommand().equals(ConfirmPanel.A_OK))
	 *  </code>
	 *  @param al listener
	 */
	public void addActionListener(ActionListener al)
	{
		((AppsAction)bOK.getAction()).setDelegate(al);
		((AppsAction)bCancel.getAction()).setDelegate(al);
		//
		if (bRefresh != null)
			((AppsAction)bRefresh.getAction()).setDelegate(al);
		if (bReset != null)
			((AppsAction)bReset.getAction()).setDelegate(al);
		if (bCustomize != null)
			((AppsAction)bCustomize.getAction()).setDelegate(al);
		if (bHistory != null)
			((AppsAction)bHistory.getAction()).setDelegate(al);
		if (bZoom != null)
			((AppsAction)bZoom.getAction()).setDelegate(al);
			
		//	Set OK as default Button
		JRootPane rootpane = null;
		if (al instanceof JDialog)
			rootpane = ((JDialog)al).getRootPane();
		else if (al instanceof JFrame)
			rootpane = ((JFrame)al).getRootPane();
		if (rootpane != null)
			rootpane.setDefaultButton(bOK);
	}	//	addActionListener

	/**
	 *  Enable all components
	 *  @param enabled trie if enabled
	 */
	public void setEnabled (boolean enabled)
	{
		super.setEnabled(enabled);
		bOK.setEnabled(enabled);
		bCancel.setEnabled(enabled);
		//
		if (bRefresh != null)
			bRefresh.setEnabled(enabled);
		if (bCustomize != null)
			bCustomize.setEnabled(enabled);
		if (bHistory != null)
			bHistory.setEnabled(enabled);
		if (bZoom != null)
			bZoom.setEnabled(enabled);
	}   //  setEnabled

}	//	ConfirmPanel

⌨️ 快捷键说明

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