本文整理汇总了Java中javax.swing.JComponent.getComponents方法的典型用法代码示例。如果您正苦于以下问题:Java JComponent.getComponents方法的具体用法?Java JComponent.getComponents怎么用?Java JComponent.getComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComponent
的用法示例。
在下文中一共展示了JComponent.getComponents方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: started
import javax.swing.JComponent; //导入方法依赖的package包/类
void started() {
started = true;
((CardLayout) progress.getLayout()).show(progress, "progress");
progress.invalidate();
//disable all elements in the dialog:
List<JComponent> todo = new LinkedList<JComponent>();
todo.add(this);
while (!todo.isEmpty()) {
JComponent c = todo.remove(0);
if (c == progress) continue;
c.setEnabled(false);
for (Component child : c.getComponents()) {
if (child instanceof JComponent) todo.add((JComponent) child);
}
}
}
示例2: addBorderSetter
import javax.swing.JComponent; //导入方法依赖的package包/类
private void addBorderSetter(final JComponent s) {
if (s instanceof JTextField || s instanceof JSlider || s instanceof JComboBox || s instanceof AbstractButton) {
s.setFocusable(true);// sliders and combo boxes not normally focusable
s.addFocusListener(this);
// log.info("added border setter for "+s.getClass().getSimpleName());
} else if (s instanceof Container) {
Component[] components = s.getComponents();
for (Component c : components) {
// log.info("possibly adding border setter for "+c.getClass().getSimpleName());
if (c instanceof JComponent) {
addBorderSetter((JComponent) c);
}
}
}
}
示例3: getMenuItemsList
import javax.swing.JComponent; //导入方法依赖的package包/类
/**
*
* @param component
* @return all menu items in the menu component
*/
public static ArrayList<NbMenuItem> getMenuItemsList(JComponent component) {
Component items[] = component.getComponents();
ArrayList<NbMenuItem> list = new ArrayList<NbMenuItem>();
for (Component menuItem : items) {
if (menuItem instanceof JSeparator) {
// System.out.println("adding separator");//DEBUG
NbMenuItem separator = new NbMenuItem();
separator.setSeparator(true);
list.add(separator);
} else {
if (menuItem instanceof JMenu) {
NbMenuItem mitem = new NbMenuItem((JMenuItem) menuItem);
mitem.setName(mitem.getName());
mitem.setSubmenu (getMenuItemsList((JComponent)menuItem));
list.add(mitem);
} else if (menuItem instanceof JMenuItem) {//if()
NbMenuItem item = new NbMenuItem((JMenuItem) menuItem);
item.setName(item.getName());
list.add(item);
} else {
System.out.println("getMenuItemsList unknown:" + menuItem.toString());
}
}
}
return list;
}
示例4: setMenuBarEnabled
import javax.swing.JComponent; //导入方法依赖的package包/类
private void setMenuBarEnabled(JComponent menu, boolean enabled, String... items) {
java.awt.Component[] menubar_components = menu instanceof JMenu?((JMenu)menu).getMenuComponents():menu.getComponents();
List<String> list = null;
if(items!=null&&items.length>0)
list = Arrays.asList(items);
for(java.awt.Component menu_component:menubar_components)
if(menu_component instanceof JMenuItem) {
if(list==null||list.contains(((JMenuItem) menu_component).getActionCommand()))
menu_component.setEnabled(enabled);
else if(menu_component instanceof JMenu)
setMenuBarEnabled((JMenu)menu_component, enabled, items);
}
}
示例5: getMenuBarItem
import javax.swing.JComponent; //导入方法依赖的package包/类
private JMenuItem getMenuBarItem(JComponent menu, String item) {
java.awt.Component[] menubar_components = menu instanceof JMenu?((JMenu)menu).getMenuComponents():menu.getComponents();
for(java.awt.Component menu_component:menubar_components)
if(menu_component instanceof JMenuItem) {
JMenuItem menuItem = (JMenuItem) menu_component;
if(menuItem.getActionCommand().equals(item))
return menuItem;
else if(menu_component instanceof JMenu) {
JMenuItem subMenuItem = getMenuBarItem((JMenu)menu_component, item);
if(subMenuItem!=null)
return subMenuItem;
}
}
return null;
}
示例6: iterateOverOpaqueLayersComponents
import javax.swing.JComponent; //导入方法依赖的package包/类
private static void iterateOverOpaqueLayersComponents(JComponent j){
if (j instanceof JPanel || j instanceof JOptionPane) {
Component[] componentes = j.getComponents();
for (Component componente : componentes) {
setOpaqueLayerRecursive(componente);
}
}
}
示例7: setInheritsPopupMenu
import javax.swing.JComponent; //导入方法依赖的package包/类
/**
* Allows to show context popup for all components recursively.
*
* @param component the root component of the tree
* @param value whether or not the popup menu is inherited
*/
private static void setInheritsPopupMenu(JComponent component, boolean value) {
component.setInheritsPopupMenu(value);
for (Object object : component.getComponents()) {
if (object instanceof JComponent) {
setInheritsPopupMenu((JComponent) object, value);
}
}
}
示例8: recursiveSetEnable
import javax.swing.JComponent; //导入方法依赖的package包/类
/**
* Enable or disable the childs of the given component
*
* @param enable true or false !
* @param comp the component
*/
public static void recursiveSetEnable(final boolean enable, final JComponent comp) {
for (final Component c : comp.getComponents()) {
c.setEnabled(enable);
if (c instanceof JComponent) {
recursiveSetEnable(enable, (JComponent) c);
}
}
}
示例9: installUI
import javax.swing.JComponent; //导入方法依赖的package包/类
public void installUI(JComponent c) {
super.installUI(c);
//Fetch the "no properties" string - it's not going to change
//for the life of the session
// noPropsString = NbBundle.getMessage(MarginViewportUI.class,
// "CTL_NoProperties"); //NOI18N
//Set an appropriate font and color. Only really relevant on OS-X to
//keep the font consistent with other NB fonts
Color fg = UIManager.getColor("controlShadow"); //NOI18N
if (fg == null) {
fg = Color.LIGHT_GRAY;
}
c.setForeground(fg);
Color bg = UIManager.getColor("Tree.background"); //NOI18N
if (bg == null) {
bg = Color.WHITE;
}
c.setBackground(bg);
Font f = UIManager.getFont("Tree.font"); //NOI18N
if (f == null) {
f = UIManager.getFont("controlFont"); //NOI18N
}
if (f != null) {
c.setFont(f);
}
c.addContainerListener(this);
Component[] kids = c.getComponents();
for (int i = 0; i < kids.length; i++) {
//Should almost always be empty anyway, if not only one component,
//but for completeness...
kids[i].addComponentListener(this);
}
}