`

How to disable all components in a panel(JPanel actually)

阅读更多
How to iterate all the components in a panel, and then operate on them? The following code can work as a reference or a clue of solving likewise problems.
public Container disableAllComponentsInPSIPPanel(Container container)
	{
		Container result = null;
		for(int i = 0; i < container.getComponentCount(); i++)
		{
			Component component = container.getComponent(i);
			if(component instanceof JFormattedTextField)
			{
				component.setEnabled(false);
			}
			if(component instanceof JCheckBox)
			{
				component.setEnabled(false);
			}
			if(component instanceof WideComboBox)
			{
				component.setEnabled(false);
				// ((WideComboBox)component).getSelectedItem();
			}
			if(component instanceof Container)
			{
				disableAllComponentsInPSIPPanel((Container) component);
			}
		}
		result = container;
		return result;
	}



When using this strip of code, you need just put in a JPanel instance. It's not so complex, right?



分享到:
评论

相关推荐

    How to disable_enable a timing check in a design.pdf

    后仿

    Android代码-屏蔽home按键

    As there are a lot questions about "how to disable home button in android?" on Stack Overflow, such as how to disable home button in android? Android - Is It possible to disable the click of home ...

    This shows how to disable control alt and delete by tricking

    This shows how to disable control alt and delete by tricking the computer into thinking that the screensaver is running.

    KBA_160615010248_2_how_to_disable_QC3_0_.pdf

    ### 如何关闭QC3.0 #### 背景与概述 QC3.0(Quick Charge 3.0)是高通公司推出的一种快速充电技术,旨在为移动设备提供更加快速、高效的充电体验。然而,在某些情况下,用户或制造商可能需要禁用这一功能,比如在...

    This is a straight forward example of how to disable any Win

    标题中的“如何禁用Win95/98窗口”表明这是一个关于操作系统,特别是Windows 95和98的教程,具体涉及的是系统界面的自定义和管理。在早期的Windows操作系统中,用户可能会出于安全、性能优化或者个性化需求,想要...

    VS错误提示:To disable deprecation, use _CRT_SECURE_NO_WARNINGS.

    Severity Code Description ... To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 解决方案:更改预处理定义 右击项目名,选择Properties 在c/c++下选择Preprocessor 点击图

    UE(官方下载)

    How to check your JavaScript source code for common mistakes without actually running the script or opening the web page Character properties at your fingertips Access the properties of a character ...

    voip源码:jvoiplib-1.4.1.zip

    * To compile the library on a unix-like platform, just start the configure script. Afterwards you just need to run 'make'. Note that you also need jthread-1.1.2 and jrtplib-3.3.0 to make the library...

    Find Reference 2 1.2.10

    You can use this to redirect all references to TextureA (using TextureA) to TextureB, the same applied for shader, materials, mesh... Beware that replace references is very powerful yet dangerous ...

    STC89C58RD +宏芯(driver)驱动

    2. How to change different IC (T100A/T101/T101A/T102)? Just execute the projcet "T10x.Uv2" which is the IC you want. 3. How to open auto-detection function? Release the //#define AUTO_DETECT tag in...

    VB编程资源大全(英文源码 控制)

    1.x/6.0 (Java) &lt;END&gt;&lt;br&gt;6 , ocxex.zip "This is a quick example I made to show you how to use Events and properties in a OCX."&lt;END&gt;&lt;br&gt;7 , news.exe This control aids as a complete Newsgroup ...

    Android代码-锁屏应用。

    As there are a lot questions about "how to disable home button in android?" on Stack Overflow, such as how to disable home button in android? Android - Is It possible to disable the click of home b

    Disable the Return Key in a TextBox

    标题"Disable the Return Key in a TextBox"正是讨论如何实现这一功能。 在Windows Forms环境下,TextBox控件通常会响应回车键,将焦点转移到下一个控件或执行与回车关联的事件。若要禁用这个功能,我们需要编写...

    Disable Input to a WebBrowser Control

    标题中的"Disable Input to a WebBrowser Control"是一个关于在Windows应用程序中如何禁用WebBrowser控件用户输入的技术问题。WebBrowser控件通常用于在桌面应用中嵌入网页浏览功能,但有时开发者可能需要在特定情况...

    Find Reference 2

    You can use this to redirect all references to TextureA (using TextureA) to TextureB, the same applied for shader, materials, mesh... Beware that replace references is very powerful yet dangerous ...

    微软内部资料-SQL性能优化2

    A reference to an invalid page (a page that is not in your working set) is referred to as a page fault. Assuming the page reference does not result in an access violation, a page fault can be either ...

    BURNINTEST--硬件检测工具

    Here is a summary of all changes that have been made in each version of BurnInTest. Release 5.3 build 1035 revision 4 WIN32 release 10 November 2008 - Lenovo China specific build. Lenovo system ...

    Howto (Almost) Everything In Active Directory via CSharp.pdf

    - 所有的UserAccountControl标志(all UserAccountControl flags)。 - 启用用户账户(enable a user account)。 - 禁用用户账户(disable a user account)。 - 解锁用户账户(unlock a user account)。 - 重置用户...

    VB编程资源大全(英文源码 其它)

    cube.zip This example demonstrates how to rotate a cube in visual basic.&lt;END&gt;&lt;br&gt;17 , sprite1.zip This is an Excellent example on how to use sprites in your program.&lt;END&gt;&lt;br&gt;18 , charcreate.zip...

    Senfore_DragDrop_v4.1

    This is believed to be a bug in the Windows clipboard and a work around hasn't been found yet. * Asynchronous targets appears to be broken in the current release. * When TDropFileTarget....

Global site tag (gtag.js) - Google Analytics