当前位置: 首页>>代码示例>>Java>>正文


Java JPanel.getComponents方法代码示例

本文整理汇总了Java中javax.swing.JPanel.getComponents方法的典型用法代码示例。如果您正苦于以下问题:Java JPanel.getComponents方法的具体用法?Java JPanel.getComponents怎么用?Java JPanel.getComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JPanel的用法示例。


在下文中一共展示了JPanel.getComponents方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Limpar_Campos_Tela

import javax.swing.JPanel; //导入方法依赖的package包/类
public static void Limpar_Campos_Tela(JPanel tela) {
    for (Component componente : tela.getComponents()) {
        if (componente instanceof JPanel) {
            Limpar_Campos_Tela((JPanel) componente);
        }
        if (componente instanceof JTextField) {
            ((JTextField) componente).setText("");
        }
        if (componente instanceof JFormattedTextField) {
            ((JFormattedTextField) componente).setText("");
        }
        if(componente instanceof JScrollPane){
            JViewport viewport = ((JScrollPane)componente).getViewport(); 
            JTable table = (JTable)viewport.getView();
            
            DefaultTableModel model = (DefaultTableModel) table.getModel();
            model.getDataVector().removeAllElements();
            model.fireTableDataChanged();
        }
    }
}
 
开发者ID:iuryamicussi,项目名称:TrabalhoCrisParte2,代码行数:22,代码来源:Generica.java

示例2: unconfigureMenu

import javax.swing.JPanel; //导入方法依赖的package包/类
private void unconfigureMenu(final JMenu menu) {
    if (hackedPopupFactory == null) return; // Issue 145981

    // restore the UI
    menu.getPopupMenu().setUI(menuPopupUIMap.get(menu));
    
    // restore all children
    JPanel popup = hackedPopupFactory.containerMap.get(menu);
    if(popup != null) {
        for(Component c : popup.getComponents()) {
            if(c instanceof JMenu) {
                unconfigureMenu((JMenu)c);
            } else {
                unconfigureMenuItem((JComponent) c);
            }
        }
        
        //hide the popup(s) if it's still visible
        if(menu.getPopupMenu() != null) {
            menu.getPopupMenu().setVisible(false);
        }
        popup.setVisible(false);
        //layers.remove(popup);
    }
    VisualDesignerJPanelPopup pop = hackedPopupFactory.getPopup(menu);
    if(pop != null) {
        pop.hide();
    }
    if(popup != null) {
        popup.setVisible(false);
    }
    menu.setPopupMenuVisible(false);
    hackedPopupFactory.containerMap.remove(menu);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:MenuEditLayer.java

示例3: setPanelBounds

import javax.swing.JPanel; //导入方法依赖的package包/类
/**
 * Sets the bounds of the given panel, depending on the child components on this panel.
 *
 * @param panel the new panel bounds
 */
private void setPanelBounds(JPanel panel){
	
	int xPos = panel.getX();
	int yPos = panel.getY();
	int maxX = 0;
	int maxY = 0;
	
	Component[] components = panel.getComponents();
	for (int i = 0; i < components.length; i++) {
		int currXMax = components[i].getX() + components[i].getWidth();
		int currYMax = components[i].getY() + components[i].getHeight();
		if (currXMax > maxX) maxX = currXMax;
		if (currYMax > maxY) maxY = currYMax;
	}
	
	maxX += 5;
	maxY += 2;
	panel.setBounds(xPos, yPos, maxX, maxY);

}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:26,代码来源:DynForm.java

示例4: fixOsxColorChooser

import javax.swing.JPanel; //导入方法依赖的package包/类
public static void fixOsxColorChooser(JColorChooser chooser) {

		if(!UIManager.getLookAndFeel().getName().equals("Mac OS X"))
			return;

		AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
		for(JPanel p : panels) {
			if(p!=null) {
				p.setOpaque(false);
				((JComponent) p.getParent()).setOpaque(false);
				for(Component c : p.getComponents()) {
					((JComponent) c).setBorder(null);
					((JComponent) c).setOpaque(false);
				}
			}
		}
	}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:18,代码来源:ViewUtils.java

示例5: validate

import javax.swing.JPanel; //导入方法依赖的package包/类
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:TestObject.java

示例6: configureMenu

import javax.swing.JPanel; //导入方法依赖的package包/类
void configureMenu(final JComponent parent, final JMenu menu) {
    // make sure it will draw it's border so we can have rollovers and selection
    menu.setBorderPainted(true);
    //install the wrapper icon if not a toplevel JMenu
    if(!isTopLevelMenu(menu)) {
        if(!(menu.getIcon() instanceof WrapperIcon)) {
            menu.setIcon(new WrapperIcon(menu.getIcon()));
        }
    }
    
    // configure the maps and popups
    JPopupMenu popup = menu.getPopupMenu();
    menuPopupUIMap.put(menu, popup.getUI());
    popup.setUI(new VisualDesignerPopupMenuUI(this, popup.getUI()));
    
    // get all of the components in this menu
    Component[] subComps = menu.getMenuComponents();
    // if this isn't the first time this menu has been opened then the sub components
    // will have been moved to the popupPanel already, so we will find them there instead.
    JPanel popupPanel = getPopupFactory().containerMap.get(menu);
    if(popupPanel != null) {
        subComps = popupPanel.getComponents();
    }
    
    RADVisualContainer menuRAD = (RADVisualContainer) formDesigner.getMetaComponent(menu);
    registerForm(menuRAD,menu);
    
    // recurse for sub-menus
    for(Component c : subComps) {
        if(c instanceof JMenu) {
            configureMenu(menu, (JMenu)c);
            RADComponent rad = formDesigner.getMetaComponent(c);
            registerForm((RADVisualContainer)rad,(JMenu)c);
        } else {
            configureMenuItem(menu, (JComponent) c);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:MenuEditLayer.java

示例7: rebuildOnScreenMenu

import javax.swing.JPanel; //导入方法依赖的package包/类
private void rebuildOnScreenMenu(RADVisualContainer menuRAD) {
    if(menuRAD == null) return;
    if(hackedPopupFactory == null) return;
    JMenu menu = (JMenu) formDesigner.getComponent(menuRAD);
    if(hackedPopupFactory.containerMap.containsKey(menu)) {
        JPanel popupContainer = hackedPopupFactory.containerMap.get(menu);
        if(popupContainer == null) return;
        for(Component c : popupContainer.getComponents()) {
            if(c instanceof JMenu) {
                unconfigureMenu((JMenu)c);
            } else {
                unconfigureMenuItem((JComponent)c);
            }
        }
        popupContainer.removeAll();
        // rebuild it
        for(RADVisualComponent child : menuRAD.getSubComponents()) {
            if(child != null) {
                JComponent jchild = (JComponent) formDesigner.getComponent(child);
                if(!isConfigured(jchild)) {
                    if(jchild instanceof JMenu) {
                        configureMenu(menu, (JMenu)jchild);
                    } else {
                        configureMenuItem(menu,jchild);
                    }
                }
                popupContainer.add(jchild);
            }
        }
        
        // repack it
        popupContainer.setSize(popupContainer.getLayout().preferredLayoutSize(popupContainer));
        validate();
        popupContainer.repaint();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:MenuEditLayer.java

示例8: getSelected

import javax.swing.JPanel; //导入方法依赖的package包/类
private List<AbstractButton> getSelected(JPanel container) {
    List<AbstractButton> selected = new ArrayList();
    for (Component c : container.getComponents())
        if (c instanceof AbstractButton && ((AbstractButton)c).isSelected())
            selected.add((AbstractButton)c);
    return selected;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:TracerOptionsPanel.java

示例9: constructPanel

import javax.swing.JPanel; //导入方法依赖的package包/类
private void constructPanel(String[] values) {
	// constructing editors
	editors = new PropertyValueCellEditor[types.length];
	for (int i = 0; i < types.length; i++) {
		editors[i] = PropertyPanel.instantiateValueCellEditor(types[i], operator);
	}

	// building panel
	panel = new JPanel();
	panel.setFocusable(true);
	panel.setLayout(new GridLayout(1, editors.length));
	for (int i = 0; i < types.length; i++) {
		Component editorComponent = editors[i].getTableCellEditorComponent(null, values[i], false, 0, 0);

		if (editorComponent instanceof JComboBox && ((JComboBox) editorComponent).isEditable()) {
			if (((JComboBox) editorComponent).isEditable()) {
				ComboBoxEditor editor = ((JComboBox) editorComponent).getEditor();
				if (editor instanceof BasicComboBoxEditor) {
					editor.getEditorComponent().addFocusListener(focusListener);
				}
			} else {
				editorComponent.addFocusListener(focusListener);
			}
		} else if (editorComponent instanceof JPanel) {
			JPanel editorPanel = (JPanel) editorComponent;
			Component[] components = editorPanel.getComponents();
			for (Component comp : components) {
				comp.addFocusListener(focusListener);
			}
		} else {

			editorComponent.addFocusListener(focusListener);
		}
		panel.add(editorComponent);
		panel.addFocusListener(focusListener);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:38,代码来源:ParameterTupelCellEditor.java

示例10: addControlButtons

import javax.swing.JPanel; //导入方法依赖的package包/类
@Override
protected void addControlButtons() {
    JPanel buttonPanel = getButtonPanel();
    Component[] buttons = buttonPanel.getComponents();
    buttonPanel.removeAll();
    for (int i=buttons.length-1; i>=0; i--) {
        buttonPanel.add(buttons[i]);
    }
    super.addControlButtons();
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:11,代码来源:FreeColFileChooserUI.java

示例11: validate

import javax.swing.JPanel; //导入方法依赖的package包/类
private static void validate(JPanel panel) {
    BorderLayout layout = (BorderLayout) panel.getLayout();
    for (Component component : panel.getComponents()) {
        String name = (String) layout.getConstraints(component);
        if (name == null)
            throw new Error("The component is not layed out: " + component);

        JLabel label = (JLabel) component;
        if (!name.equals(label.getText()))
            throw new Error("The component is layed out on " + name + ": " + component);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:Test6437265.java

示例12: goCmp

import javax.swing.JPanel; //导入方法依赖的package包/类
private void goCmp(JPanel panel) {
    for (Component cmp : panel.getComponents()) {
        if (cmp instanceof JButton && cmp != buttonBackspace) {
            cmp.setFont(font);
            cmp.setForeground(foregraundColor);
        } else {
            if (cmp instanceof JPanel) {
                goCmp((JPanel) cmp);
            }
        }
    }
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:13,代码来源:KeyboardQwertyRus.java

示例13: actionPerformed

import javax.swing.JPanel; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {

	// look up the panel invoking the pop up invoking the action
	AttributeStatisticsPanel asp = null;

	// the action should only be invoked by AttributePopupMenus
	Container parent = ((JComponent) e.getSource()).getParent();
	if ((parent instanceof AttributePopupMenu)) {
		asp = ((AttributePopupMenu) parent).getAttributeStatisticsPanel();
	} else {
		asp = (AttributeStatisticsPanel) SwingUtilities.getAncestorOfClass(AttributeStatisticsPanel.class, parent);
		if (asp == null) {
			// we are not inside a AttributesStatisticPanel
			return;
		}
	}

	ButtonBarCardPanel cardPanel = (ButtonBarCardPanel) SwingUtilities.getAncestorOfClass(ButtonBarCardPanel.class, asp);
	AbstractAttributeStatisticsModel model = asp.getModel();

	// select the plotter view
	cardPanel.selectCard("plot_view");

	// get the opened plotter
	JPanel outerPanel = (JPanel) cardPanel.getShownComponent();
	for (Component innerComp : outerPanel.getComponents()) {
		if (innerComp instanceof PlotterPanel) {
			PlotterPanel plotterPanel = (PlotterPanel) outerPanel.getComponent(0);
			PlotterConfigurationModel settings = plotterPanel.getPlotterSettings();

			// adjust settings
			if (model instanceof NominalAttributeStatisticsModel) {
				settings.setPlotter(PlotterConfigurationModel.BAR_CHART);
				settings.setParameterAsString(PlotterConfigurationSettings.AXIS_PLOT_COLUMN, model.getAttribute()
						.getName());
				settings.setParameterAsString(PlotterConfigurationSettings.GROUP_BY_COLUMN, model.getAttribute()
						.getName());
			} else if (model instanceof NumericalAttributeStatisticsModel
					|| model instanceof DateTimeAttributeStatisticsModel) {
				settings.setPlotter(PlotterConfigurationModel.HISTOGRAM_PLOT);
				settings.setParameterAsString(PlotterConfigurationSettings.NUMBER_OF_BINS, "10");
				settings.setParameterAsString(PlotterConfigurationSettings.AXIS_PLOT_COLUMNS, model.getAttribute()
						.getName());
			}
			break;
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:50,代码来源:OpenChartAction.java


注:本文中的javax.swing.JPanel.getComponents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。