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


Java JComponent.getParent方法代码示例

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


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

示例1: drawSelectedComponent

import javax.swing.JComponent; //导入方法依赖的package包/类
private void drawSelectedComponent(Graphics2D g2, JComponent selected, RADComponent rad) {
    if(selected == null) return;
    if(selected.getParent() == null || !selected.getParent().isVisible()) return;
    // draw normal border around toplevel menus
    if (selected instanceof JMenu && selected.getParent() instanceof JMenuBar) {
        JMenuItem menu = (JMenuItem) selected;
        Point location = SwingUtilities.convertPoint(menu, new Point(0, 0), this);
        g2.translate(location.x, location.y);
        // #114610: keep drop rectangle guidelines consistent when menu component is inserted from menu-bar into submenu
        g2.setStroke((currentTargetType == DropTargetType.INTO_SUBMENU) ? DROP_TARGET_LINE_STROKE : SELECTION_STROKE);
        g2.setColor(SELECTION_COLOR);
        g2.drawRect(0, 0, menu.getWidth() - 1, menu.getHeight() - 1);
        g2.translate(-location.x, -location.y);
    }
    
    // style only menuitems and menus that aren't also toplevel menus
    // don't do subrect drawing if doing a drag
    if (selected instanceof JMenuItem && !(selected.getParent() instanceof JMenuBar) && currentTargetComponent == null) {
        JMenuItem item = (JMenuItem) selected;
        drawSubselectedItem(g2, item);
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DropTargetLayer.java

示例2: addMenuItems

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
 * Add specific menu items for a given component.
 *
 * @param comp The specific {@code JComponent}.
 * @return This {@code QuickActionMenu}.
 */
public QuickActionMenu addMenuItems(JComponent comp) {
    if (comp instanceof UnitLabel) {
        createUnitMenu((UnitLabel)comp);
    } else if (comp instanceof GoodsLabel) {
        createGoodsMenu((GoodsLabel)comp);
    } else if (comp instanceof MarketLabel) {
        createMarketMenu((MarketLabel)comp);
    } else if (comp instanceof ASingleTilePanel) {
        createTileMenu((ASingleTilePanel)comp);
    } else if (comp.getParent() instanceof ASingleTilePanel) {
        // Also check the parent to show the popup in the
        // center of the colony panel tile.
        createTileMenu((ASingleTilePanel)comp.getParent());
    }
    return this;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:23,代码来源:QuickActionMenu.java

示例3: ComponentIcon

import javax.swing.JComponent; //导入方法依赖的package包/类
/** Create an icon.
* @param comp a component, which must be unattached to a container
*             and should not be used for other purposes
*/
public ComponentIcon(JComponent comp) {
    if (comp.getParent() != null) {
        throw new IllegalArgumentException();
    }

    this.comp = comp;

    Dimension size = comp.getPreferredSize();

    // Careful! If you have e.g. a JLabel with empty text, width = 0 => exceptions.
    // Must make sure it is at least a reasonable size.
    comp.setSize(Math.max(size.width, 16), Math.max(size.height, 16));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:SystemAction.java

示例4: activateFilter

import javax.swing.JComponent; //导入方法依赖的package包/类
public void activateFilter() {
    JComponent panel = getBottomPanel();
    
    if (filterPanel == null) {
        filterPanel = FilterUtils.createFilterPanel(getResultsComponent(), getExcludesFilter(), getFilterOptions());
        panel.add(filterPanel);
        Container parent = panel.getParent();
        parent.invalidate();
        parent.revalidate();
        parent.repaint();
    }
    
    panel.setVisible(true);
    
    filterPanel.setVisible(true);
    filterPanel.requestFocusInWindow();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DataView.java

示例5: activateSearch

import javax.swing.JComponent; //导入方法依赖的package包/类
public void activateSearch() {
    JComponent panel = getBottomPanel();
    
    if (searchPanel == null) {
        SearchUtils.TreeHelper searchHelper = getSearchHelper();
        if (searchHelper == null) searchPanel = SearchUtils.createSearchPanel(getResultsComponent(), getSearchOptions());
        else searchPanel = SearchUtils.createSearchPanel((ProfilerTreeTable)getResultsComponent(), searchHelper, getSearchOptions());
        panel.add(searchPanel);
        Container parent = panel.getParent();
        parent.invalidate();
        parent.revalidate();
        parent.repaint();
    }
    
    panel.setVisible(true);
    
    searchPanel.setVisible(true);
    searchPanel.requestFocusInWindow();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:DataView.java

示例6: testHierarchy

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
 * Test the hierarchy between the two components
 * 
 * @param source
 * @param listen
 * @return boolean
 */
private boolean testHierarchy(JComponent source, JComponent listen) {
    if (source == listen) {
        return true;
    }
    if (source.getParent() == null || !(source.getParent() instanceof JComponent)) {
        return false;
    }
    return testHierarchy((JComponent) source.getParent(), listen);
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:17,代码来源:HierarchyMouseDispatcher.java

示例7: computeBounds

import javax.swing.JComponent; //导入方法依赖的package包/类
/** Variation of the method for computing the bounds
 * for the concrete view component. As the component can possibly
 * be placed in a scroll pane it's first necessary
 * to translate the cursor bounds and also translate
 * back the resulting popup bounds.
 * @param popup  popup panel to be displayed
 * @param view component over which the popup is displayed.
 * @param cursorBounds the bounds of the caret or mouse cursor
 *    relative to the upper-left corner of the visible view.
 * @param placement where to place the popup panel according to
 *    the cursor position.
 * @return bounds of popup panel relative to the upper-left corner
 *    of the underlying view component.
 *    <CODE>null</CODE> if there is no place to display popup.
 */
protected static Rectangle computeBounds(JComponent popup,
JComponent view, Rectangle cursorBounds, Placement placement, HorizontalBounds horizontalBounds) {
    
    if (horizontalBounds == null) horizontalBounds = ViewPortBounds;
    
    Rectangle ret;
    Component viewParent = view.getParent();
    
    if (viewParent instanceof JLayeredPane) {
        viewParent = viewParent.getParent();
    }
    
    if (viewParent instanceof JViewport) {
        Rectangle viewBounds = ((JViewport)viewParent).getViewRect();

        Rectangle translatedCursorBounds = (Rectangle)cursorBounds.clone();
        if (placement != FixedPoint) {
            translatedCursorBounds.translate(-viewBounds.x, -viewBounds.y);
        }

        ret = computeBounds(popup, viewBounds.width, viewBounds.height,
            translatedCursorBounds, placement, horizontalBounds);
        
        if (ret != null) { // valid bounds
            ret.translate(viewBounds.x, viewBounds.y);
        }
        
    } else { // not in scroll pane
        ret = computeBounds(popup, view.getWidth(), view.getHeight(),
            cursorBounds, placement);
    }
    
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:50,代码来源:PopupManager.java

示例8: setContent

import javax.swing.JComponent; //导入方法依赖的package包/类
private void setContent(JComponent component) {
    if(component.getParent() == null) {
        //not shown
        removeAll();
        add(component, BorderLayout.CENTER);
        revalidate();
        repaint();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:CssStylesTC.java

示例9: exportDone

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void exportDone(JComponent source, Transferable data,
                          int action) {
    try {
        CargoLabel label = (CargoLabel)data.getTransferData(DefaultTransferHandler.flavor);
        if (source.getParent() instanceof CargoPanel) {
            TradeRouteInputPanel.this.cargoPanel.remove(label);
            int[] indices = TradeRouteInputPanel.this.stopList
                .getSelectedIndices();
            for (int stopIndex : indices) {
                TradeRouteStop stop = TradeRouteInputPanel.this
                    .stopListModel.get(stopIndex);
                List<GoodsType> cargo = new ArrayList<>(stop.getCargo());
                for (int index = 0; index < cargo.size(); index++) {
                    if (cargo.get(index) == label.getType()) {
                        cargo.remove(index);
                        break;
                    }
                }
                stop.setCargo(cargo);
            }
            TradeRouteInputPanel.this.stopList.revalidate();
            TradeRouteInputPanel.this.stopList.repaint();
            TradeRouteInputPanel.this.cargoPanel.revalidate();
            TradeRouteInputPanel.this.cargoPanel.repaint();
        }
    } catch (IOException|UnsupportedFlavorException ex) {
        logger.log(Level.WARNING, "CargoHandler export", ex);
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:34,代码来源:TradeRouteInputPanel.java

示例10: getIndexPositionOfProjectWindowTab

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
 * Returns the current index position of the project window tab.
 * @return the index position of project window tab
 */
private int getIndexPositionOfProjectWindowTab() {
	int indexPosFound = 0;
	if (this.pwt!=null) {
		JComponent component = this.pwt.getJComponentForVisualization();
		if (component.getParent()!=null) {
			JTabbedPane jTabbedPane = (JTabbedPane) component.getParent();	
			indexPosFound = jTabbedPane.indexOfComponent(this.pwt.getJComponentForVisualization());
		}
	}
	return indexPosFound;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:16,代码来源:TimeModelController.java

示例11: buildInfoPanel

import javax.swing.JComponent; //导入方法依赖的package包/类
/** Adjust the info panel by retrieving upper and lower info subpanels from the selected tab. */
protected void buildInfoPanel() {
    JComponent upperInfoPanel = null;
    JComponent lowerInfoPanel = null;
    ResourceTab tab = getSelectedTab();
    if (tab != null) {
        upperInfoPanel = tab.getUpperInfoPanel();
        lowerInfoPanel = tab.getLowerInfoPanel();
    }
    JPanel infoPanel = (JPanel) getInfoPanel();
    String key;
    if (lowerInfoPanel == null || !lowerInfoPanel.isEnabled()) {
        // if we switch from split to single, freeze the divider location
        if (upperInfoPanel != null && upperInfoPanel.getParent() == getSplitInfoPanel()) {
            this.frozenDividerPos = getSplitInfoPanel().getDividerLocation();
        }
        getSingleInfoPanel().removeAll();
        if (upperInfoPanel != null) {
            getSingleInfoPanel().add(upperInfoPanel, BorderLayout.CENTER);
            getSingleInfoPanel().validate();
            getSingleInfoPanel().repaint();
        }
        key = this.SINGLE_INFO_KEY;
    } else {
        JSplitPane splitInfoPanel = getSplitInfoPanel();
        int dividerPos = this.frozenDividerPos;
        this.frozenDividerPos = 0;
        if (dividerPos == 0) {
            dividerPos = splitInfoPanel.getDividerLocation();
        }
        splitInfoPanel.setTopComponent(upperInfoPanel);
        splitInfoPanel.setBottomComponent(lowerInfoPanel);
        splitInfoPanel.setDividerLocation(dividerPos);
        key = this.SPLIT_INFO_KEY;
    }
    ((CardLayout) infoPanel.getLayout()).show(infoPanel, key);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:38,代码来源:ResourceDisplay.java

示例12: getPreferredSize

import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public Dimension getPreferredSize(JComponent c) {
	if (c.getParent() instanceof JToolBar) {
		return new Dimension((int) super.getPreferredSize(c).getWidth() + 6,
				(int) super.getPreferredSize(c).getHeight() + 6);
	} else {
		return new Dimension((int) super.getPreferredSize(c).getWidth() + 10, (int) super.getPreferredSize(c)
				.getHeight() + 6);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:11,代码来源:ButtonUI.java

示例13: ShowDlgTexto

import javax.swing.JComponent; //导入方法依赖的package包/类
public static String ShowDlgTexto(JComponent form, String texto) {
    DlgExecutor dlg = new DlgExecutor((Frame) form.getParent(), true);
    dlg.Texto.setText(texto);
    //dlg.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    dlg.setLocationRelativeTo(form);
    dlg.setVisible(true);

    if (dlg.getResultado() == JOptionPane.OK_OPTION) {
        return dlg.Texto.getText();
    }
    return texto;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:13,代码来源:Dialogos.java

示例14: paint

import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public synchronized void paint(Graphics g, JComponent c) {
	// without this, checkboxes and radio buttons have a fixed bg color instead of using the bg
	// color of the container they are in
	if (c.getParent() != null) {
		c.setBackground(c.getParent().getBackground());
	}
	super.paint(g, c);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:10,代码来源:RadioButtonUI.java

示例15: removeCustomElements

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
 * This method can be used to remove all custom components
 * for menus and for the toolbar.
 */
private void removeCustomElements() {
	
	// --- Remove custom toolbar/menu elements --------
	for (int i = 0; i < customJComponent.size(); i++) {
		JComponent component = customJComponent.get(i);
		Container container = component.getParent();
		if (container!=null) container.remove(component);
	}
	customJComponent = new Vector<JComponent>();
	
	// --- Remove custom tab elements -----------------
	for (int i = customProjectWindowTab.size()-1; i>-1; i--) {
		ProjectWindowTab pwt = customProjectWindowTab.get(i);
		pwt.remove();
	}
	customProjectWindowTab = new Vector<ProjectWindowTab>();
	
	// --- Remove custom environment types ------------
	for (int i = customEnvironmentTypes.size()-1; i>-1; i--) {
		EnvironmentType envType = customEnvironmentTypes.get(i);
		if (envType.equals(this.project.getEnvironmentModelType())) {
			this.project.setEnvironmentModelName("none");
		}
		project.getEnvironmentsComboBoxModel().removeElement(envType);
		Application.getGlobalInfo().removeEnvironmentType(envType);
	}
	customEnvironmentTypes = new Vector<EnvironmentType>();
	
	// --- Remove custom ontology visualizations ------
	for (int i = customOntologyClassVisualisation.size()-1; i>-1; i--) {
		OntologyClassVisualisation ontoClVis = customOntologyClassVisualisation.get(i);
		OntologyVisualisationConfiguration.unregisterOntologyClassVisualisation(ontoClVis);
	}
	customOntologyClassVisualisation = new Vector<OntologyClassVisualisation>();
	
	// --- Refresh the main window --------------------
	if (Application.getMainWindow()!=null) {
		Application.getMainWindow().validate();
		Application.getMainWindow().repaint();
	}
	
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:47,代码来源:PlugIn.java


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