List of usage examples for java.awt Container getParent
public Container getParent()
From source file:de.codesourcery.jasm16.ide.ui.viewcontainers.EditorContainer.java
@Override public void setBlockAllUserInput(boolean yesNo) { if (panel != null) { Container parent = panel.getParent(); while (parent != null && !(parent instanceof JFrame)) { parent = parent.getParent(); }//from w w w . j a v a2s . c o m if (parent != null && parent instanceof JFrame) { UIUtils.setBlockAllUserInput((JFrame) parent, yesNo); } } }
From source file:edu.ku.brc.stats.StatGroupTable.java
/** * Constructor with the localized name of the Group * @param name name of the group (already been localized) * @param useSeparator use non-border separator titles *//*from w w w .ja v a2 s. com*/ public StatGroupTable(final String name, final String[] columnNames, final boolean useSeparator, final int numRows) { this.name = name; this.useSeparator = useSeparator; this.skinItem = SkinsMgr.getSkinItem("StatGroup"); if (progressIcon == null) { progressIcon = IconManager.getIcon("Progress", IconManager.IconSize.Std16); } setLayout(new BorderLayout()); setBackground(Color.WHITE); model = new StatGroupTableModel(this, columnNames); //table = numRows > SCROLLPANE_THRESOLD ? (new SortableJTable(new SortableTableModel(model))) : (new JTable(model)); if (numRows > SCROLLPANE_THRESOLD) { table = new SortableJTable(new SortableTableModel(model)) { protected void configureEnclosingScrollPane() { Container p = getParent(); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; // Make certain we are the viewPort's view and not, for // example, the rowHeaderView of the scrollPane - // an implementor of fixed columns might do this. JViewport viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) { return; } // scrollPane.setColumnHeaderView(getTableHeader()); //scrollPane.getViewport().setBackingStoreEnabled(true); scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder")); } } } }; } else { table = new JTable(model) { protected void configureEnclosingScrollPane() { Container p = getParent(); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; // Make certain we are the viewPort's view and not, for // example, the rowHeaderView of the scrollPane - // an implementor of fixed columns might do this. JViewport viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) { return; } // scrollPane.setColumnHeaderView(getTableHeader()); //scrollPane.getViewport().setBackingStoreEnabled(true); scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder")); } } } }; } table.setShowVerticalLines(false); table.setShowHorizontalLines(false); if (SkinsMgr.shouldBeOpaque(skinItem)) { table.setOpaque(false); setOpaque(false); } else { table.setOpaque(true); setOpaque(true); } table.addMouseMotionListener(new TableMouseMotion()); table.addMouseListener(new LinkListener()); if (table.getColumnModel().getColumnCount() == 1) { table.getColumnModel().getColumn(0) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.CENTER, 1)); } else { table.getColumnModel().getColumn(0) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.LEFT, 2)); table.getColumnModel().getColumn(1) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.RIGHT, 2)); } //table.setRowSelectionAllowed(true); if (numRows > SCROLLPANE_THRESOLD) { scrollPane = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); if (table instanceof SortableJTable) { ((SortableJTable) table).installColumnHeaderListeners(); } scrollPane.setOpaque(false); scrollPane.getViewport().setOpaque(false); scrollPane.setBorder(BorderFactory.createEmptyBorder()); //scrollPane.getViewport().setBorder(BorderFactory.createEmptyBorder()); } if (useSeparator) { setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); CellConstraints cc = new CellConstraints(); if (StringUtils.isNotEmpty(name)) { builder.addSeparator(name, cc.xy(1, 1)); } builder.add(scrollPane != null ? scrollPane : table, cc.xy(1, 2)); builder.getPanel().setOpaque(false); add(builder.getPanel()); } else { setBorder(BorderFactory.createEmptyBorder(15, 2, 2, 2)); setBorder(BorderFactory.createCompoundBorder(new CurvedBorder(new Color(160, 160, 160)), getBorder())); add(scrollPane != null ? scrollPane : table, BorderLayout.CENTER); } }
From source file:net.sf.firemox.clickable.target.card.VirtualCard.java
/** * Update the layout of this card, and also generate a new random angle. *//*from w w w . j a v a 2 s . c o m*/ public void updateLayout() { // Update the bounds if (updateSizes()) { // Update the layout doLayout(); Container parent = getParent(); if (parent != null) { parent.doLayout(); parent = parent.getParent(); if (parent != null) { parent.repaint(); } } } }
From source file:com.projity.pm.graphic.spreadsheet.common.CommonSpreadSheet.java
protected void configureEnclosingScrollPane() { super.configureEnclosingScrollPane(); Container p = getParent(); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; JViewport viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) return; configureScrollPaneHeaders(scrollPane); Border border = scrollPane.getBorder(); if (border == null || border instanceof UIResource) { scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder")); }/* w w w .j av a 2 s. co m*/ } } }
From source file:edu.ucla.stat.SOCR.chart.Chart.java
/**This class method returns the frame that contains a given component*/ static JFrame getFrame(Container component) { JFrame frame = null;/*from www . j a v a2s . c om*/ while ((component = component.getParent()) != null) { if (component instanceof JFrame) frame = (JFrame) component; } return frame; }
From source file:com.pironet.tda.TDA.java
private JFrame getFrame() { Container owner = this.getParent(); while (owner != null && !(owner instanceof JFrame)) { owner = owner.getParent(); }//from www . j av a 2 s.c o m return (owner != null ? (JFrame) owner : null); }
From source file:openlr.mapviewer.gui.MapViewerGui.java
/** * Sets the application cursor./*from w w w. jav a 2 s . c o m*/ * * @param requester * the requester * @param cursor * the cursor */ public static void setApplicationCursor(final Container requester, final Cursor cursor) { Container current = requester; while (current.getParent() != null) { current = current.getParent(); } current.setCursor(cursor); }
From source file:openlr.mapviewer.gui.MapViewerGui.java
/** * Gets the application cursor./*from w w w . j av a2 s . co m*/ * * @param requester * the requester * @return the application cursor */ public static Cursor getApplicationCursor(final Container requester) { Container current = requester; while (current.getParent() != null) { current = current.getParent(); } return current.getCursor(); }
From source file:org.broad.igv.ui.panel.PanTool.java
public PanTool(DataPanel owner) { super(owner, Cursor.getDefaultCursor()); this.dragCursor = IGV.fistCursor; setName("Pan"); if (owner != null) { verticalScrollBar = owner.getVerticalScrollbar(); Container parentContainer = owner.getParent(); if (parentContainer != null) { Container parentOfParent = parentContainer.getParent(); if ((parentOfParent != null) && (parentOfParent instanceof JViewport)) { //viewport = (JViewport) parentOfParent; }/* w ww . ja va 2 s . c om*/ } } }
From source file:org.eclipse.jubula.rc.swing.components.AUTSwingHierarchy.java
/** * Adds the parent(s) of the given container to the hierarchy recursivly. <br> * Recursion stops if the top level container is reached or a parent container is already known. * @param hierarchyContainer the responding SwingHierarchyContainer of container * @param container the container from the AUT *//*from ww w . j a va 2s .c o m*/ private void addToHierarchyUp(SwingHierarchyContainer hierarchyContainer, Container container) { checkDispatchThread(); if (log.isInfoEnabled()) { log.info("addToHierarchyUp: " //$NON-NLS-1$ + hierarchyContainer + "," + container); //$NON-NLS-1$ } registerAsContainerListener(container); Container parent = container.getParent(); if (parent != null) { // root not reached SwingHierarchyContainer hierarchyParent = getHierarchyContainer(container); if (hierarchyParent == null) { // unknown SwingHierarchyContainer for parent: // create new hierarchy container, name it, // add current SwingHierarchyContainer to parent hierarchy, // update map m_hierarchyMap // register listener // recursion hierarchyParent = new SwingHierarchyContainer(new SwingComponent(parent)); hierarchyParent.add(hierarchyContainer); hierarchyContainer.setParent(hierarchyParent); name(hierarchyParent); addToHierachyMap(hierarchyParent); addToHierarchyUp(hierarchyParent, parent); } } }