Java Code Examples for java.awt.Container#getLayout()
The following examples show how to use
java.awt.Container#getLayout() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NimbusLookAndFeel.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Package private method which returns either BorderLayout.NORTH, * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending * on the location of the toolbar in its parent. The toolbar might be * in PAGE_START, PAGE_END, CENTER, or some other position, but will be * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar * actually IS, with CENTER being NORTH. * * This code is used to determine where the border line should be drawn * by the custom toolbar states, and also used by NimbusIcon to determine * whether the handle icon needs to be shifted to look correct. * * Toollbars are unfortunately odd in the way these things are handled, * and so this code exists to unify the logic related to toolbars so it can * be shared among the static files such as NimbusIcon and generated files * such as the ToolBar state classes. */ static Object resolveToolbarConstraint(JToolBar toolbar) { //NOTE: we don't worry about component orientation or PAGE_END etc //because the BasicToolBarUI always uses an absolute position of //NORTH/SOUTH/EAST/WEST. if (toolbar != null) { Container parent = toolbar.getParent(); if (parent != null) { LayoutManager m = parent.getLayout(); if (m instanceof BorderLayout) { BorderLayout b = (BorderLayout)m; Object con = b.getConstraints(toolbar); if (con == SOUTH || con == EAST || con == WEST) { return con; } return NORTH; } } } return NORTH; }
Example 2
Source File: GridBagInfoProvider.java From netbeans with Apache License 2.0 | 6 votes |
public GridBagInfoProvider(Container container, LayoutSupportManager layoutManager) { this.container = container; this.layoutManager = layoutManager; LayoutManager containerLayout = container.getLayout(); if (!(containerLayout instanceof GridBagLayout)) { throw new IllegalArgumentException(); } try { tempXField = GridBagConstraints.class.getDeclaredField("tempX"); // NOI18N tempXField.setAccessible(true); tempYField = GridBagConstraints.class.getDeclaredField("tempY"); // NOI18N tempYField.setAccessible(true); tempHeightField = GridBagConstraints.class.getDeclaredField("tempHeight"); // NOI18N tempHeightField.setAccessible(true); tempWidthField = GridBagConstraints.class.getDeclaredField("tempWidth"); // NOI18N tempWidthField.setAccessible(true); } catch (NoSuchFieldException nsfex) { FormUtils.LOGGER.log(Level.INFO, nsfex.getMessage(), nsfex); } containerEmphColor = deriveEmphColor(container); }
Example 3
Source File: NimbusLookAndFeel.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Package private method which returns either BorderLayout.NORTH, * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending * on the location of the toolbar in its parent. The toolbar might be * in PAGE_START, PAGE_END, CENTER, or some other position, but will be * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar * actually IS, with CENTER being NORTH. * * This code is used to determine where the border line should be drawn * by the custom toolbar states, and also used by NimbusIcon to determine * whether the handle icon needs to be shifted to look correct. * * Toollbars are unfortunately odd in the way these things are handled, * and so this code exists to unify the logic related to toolbars so it can * be shared among the static files such as NimbusIcon and generated files * such as the ToolBar state classes. */ static Object resolveToolbarConstraint(JToolBar toolbar) { //NOTE: we don't worry about component orientation or PAGE_END etc //because the BasicToolBarUI always uses an absolute position of //NORTH/SOUTH/EAST/WEST. if (toolbar != null) { Container parent = toolbar.getParent(); if (parent != null) { LayoutManager m = parent.getLayout(); if (m instanceof BorderLayout) { BorderLayout b = (BorderLayout)m; Object con = b.getConstraints(toolbar); if (con == SOUTH || con == EAST || con == WEST) { return con; } return NORTH; } } } return NORTH; }
Example 4
Source File: NimbusLookAndFeel.java From Java8CN with Apache License 2.0 | 6 votes |
/** * Package private method which returns either BorderLayout.NORTH, * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending * on the location of the toolbar in its parent. The toolbar might be * in PAGE_START, PAGE_END, CENTER, or some other position, but will be * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar * actually IS, with CENTER being NORTH. * * This code is used to determine where the border line should be drawn * by the custom toolbar states, and also used by NimbusIcon to determine * whether the handle icon needs to be shifted to look correct. * * Toollbars are unfortunately odd in the way these things are handled, * and so this code exists to unify the logic related to toolbars so it can * be shared among the static files such as NimbusIcon and generated files * such as the ToolBar state classes. */ static Object resolveToolbarConstraint(JToolBar toolbar) { //NOTE: we don't worry about component orientation or PAGE_END etc //because the BasicToolBarUI always uses an absolute position of //NORTH/SOUTH/EAST/WEST. if (toolbar != null) { Container parent = toolbar.getParent(); if (parent != null) { LayoutManager m = parent.getLayout(); if (m instanceof BorderLayout) { BorderLayout b = (BorderLayout)m; Object con = b.getConstraints(toolbar); if (con == SOUTH || con == EAST || con == WEST) { return con; } return NORTH; } } } return NORTH; }
Example 5
Source File: NimbusLookAndFeel.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Package private method which returns either BorderLayout.NORTH, * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending * on the location of the toolbar in its parent. The toolbar might be * in PAGE_START, PAGE_END, CENTER, or some other position, but will be * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar * actually IS, with CENTER being NORTH. * * This code is used to determine where the border line should be drawn * by the custom toolbar states, and also used by NimbusIcon to determine * whether the handle icon needs to be shifted to look correct. * * Toollbars are unfortunately odd in the way these things are handled, * and so this code exists to unify the logic related to toolbars so it can * be shared among the static files such as NimbusIcon and generated files * such as the ToolBar state classes. */ static Object resolveToolbarConstraint(JToolBar toolbar) { //NOTE: we don't worry about component orientation or PAGE_END etc //because the BasicToolBarUI always uses an absolute position of //NORTH/SOUTH/EAST/WEST. if (toolbar != null) { Container parent = toolbar.getParent(); if (parent != null) { LayoutManager m = parent.getLayout(); if (m instanceof BorderLayout) { BorderLayout b = (BorderLayout)m; Object con = b.getConstraints(toolbar); if (con == SOUTH || con == EAST || con == WEST) { return con; } return NORTH; } } } return NORTH; }
Example 6
Source File: NimbusLookAndFeel.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Package private method which returns either BorderLayout.NORTH, * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending * on the location of the toolbar in its parent. The toolbar might be * in PAGE_START, PAGE_END, CENTER, or some other position, but will be * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar * actually IS, with CENTER being NORTH. * * This code is used to determine where the border line should be drawn * by the custom toolbar states, and also used by NimbusIcon to determine * whether the handle icon needs to be shifted to look correct. * * Toollbars are unfortunately odd in the way these things are handled, * and so this code exists to unify the logic related to toolbars so it can * be shared among the static files such as NimbusIcon and generated files * such as the ToolBar state classes. */ static Object resolveToolbarConstraint(JToolBar toolbar) { //NOTE: we don't worry about component orientation or PAGE_END etc //because the BasicToolBarUI always uses an absolute position of //NORTH/SOUTH/EAST/WEST. if (toolbar != null) { Container parent = toolbar.getParent(); if (parent != null) { LayoutManager m = parent.getLayout(); if (m instanceof BorderLayout) { BorderLayout b = (BorderLayout)m; Object con = b.getConstraints(toolbar); if (con == SOUTH || con == EAST || con == WEST) { return con; } return NORTH; } } } return NORTH; }
Example 7
Source File: TrafficLight.java From mars-sim with GNU General Public License v3.0 | 6 votes |
@Override public void componentResized(ComponentEvent event) { final int SIZE = getWidth() <= getHeight() ? getWidth() : getHeight(); Container parent = getParent(); if ((parent != null) && (parent.getLayout() == null)) { if (SIZE < getMinimumSize().width || SIZE < getMinimumSize().height) { setSize(getMinimumSize()); } else if(square) { setSize(SIZE, SIZE); } else { setSize(getWidth(), getHeight()); } } else { if (SIZE < getMinimumSize().width || SIZE < getMinimumSize().height) { setPreferredSize(getMinimumSize()); } else if(square) { setPreferredSize(new Dimension(SIZE, SIZE)); } else { setPreferredSize(new Dimension(getWidth(), getHeight())); } } calcInnerBounds(); init(getInnerBounds().width, getInnerBounds().height); }
Example 8
Source File: PolicyTool.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Add a component to the PolicyTool window */ void addNewComponent(Container container, JComponent component, int index, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int fill, Insets is) { if (container instanceof JFrame) { container = ((JFrame)container).getContentPane(); } else if (container instanceof JDialog) { container = ((JDialog)container).getContentPane(); } // add the component at the specified gridbag index container.add(component, index); // set the constraints GridBagLayout gbl = (GridBagLayout)container.getLayout(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = gridx; gbc.gridy = gridy; gbc.gridwidth = gridwidth; gbc.gridheight = gridheight; gbc.weightx = weightx; gbc.weighty = weighty; gbc.fill = fill; if (is != null) gbc.insets = is; gbl.setConstraints(component, gbc); }
Example 9
Source File: MotifOptionPaneUI.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates and returns a Container containin the buttons. The buttons * are created by calling <code>getButtons</code>. */ protected Container createButtonArea() { Container b = super.createButtonArea(); if(b != null && b.getLayout() instanceof ButtonAreaLayout) { ((ButtonAreaLayout)b.getLayout()).setCentersChildren(false); } return b; }
Example 10
Source File: PolicyTool.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Add a component to the PolicyTool window */ void addNewComponent(Container container, JComponent component, int index, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int fill, Insets is) { if (container instanceof JFrame) { container = ((JFrame)container).getContentPane(); } else if (container instanceof JDialog) { container = ((JDialog)container).getContentPane(); } // add the component at the specified gridbag index container.add(component, index); // set the constraints GridBagLayout gbl = (GridBagLayout)container.getLayout(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = gridx; gbc.gridy = gridy; gbc.gridwidth = gridwidth; gbc.gridheight = gridheight; gbc.weightx = weightx; gbc.weighty = weighty; gbc.fill = fill; if (is != null) gbc.insets = is; gbl.setConstraints(component, gbc); }
Example 11
Source File: MotifOptionPaneUI.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Creates and returns a Container containin the buttons. The buttons * are created by calling <code>getButtons</code>. */ protected Container createButtonArea() { Container b = super.createButtonArea(); if(b != null && b.getLayout() instanceof ButtonAreaLayout) { ((ButtonAreaLayout)b.getLayout()).setCentersChildren(false); } return b; }
Example 12
Source File: PolicyTool.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Add a component to the PolicyTool window */ void addNewComponent(Container container, JComponent component, int index, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int fill, Insets is) { if (container instanceof JFrame) { container = ((JFrame)container).getContentPane(); } else if (container instanceof JDialog) { container = ((JDialog)container).getContentPane(); } // add the component at the specified gridbag index container.add(component, index); // set the constraints GridBagLayout gbl = (GridBagLayout)container.getLayout(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = gridx; gbc.gridy = gridy; gbc.gridwidth = gridwidth; gbc.gridheight = gridheight; gbc.weightx = weightx; gbc.weighty = weighty; gbc.fill = fill; if (is != null) gbc.insets = is; gbl.setConstraints(component, gbc); }
Example 13
Source File: PolicyTool.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Add a component to the PolicyTool window */ void addNewComponent(Container container, JComponent component, int index, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int fill, Insets is) { if (container instanceof JFrame) { container = ((JFrame)container).getContentPane(); } else if (container instanceof JDialog) { container = ((JDialog)container).getContentPane(); } // add the component at the specified gridbag index container.add(component, index); // set the constraints GridBagLayout gbl = (GridBagLayout)container.getLayout(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = gridx; gbc.gridy = gridy; gbc.gridwidth = gridwidth; gbc.gridheight = gridheight; gbc.weightx = weightx; gbc.weighty = weighty; gbc.fill = fill; if (is != null) gbc.insets = is; gbl.setConstraints(component, gbc); }
Example 14
Source File: PolicyTool.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Add a component to the PolicyTool window */ void addNewComponent(Container container, JComponent component, int index, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int fill, Insets is) { if (container instanceof JFrame) { container = ((JFrame)container).getContentPane(); } else if (container instanceof JDialog) { container = ((JDialog)container).getContentPane(); } // add the component at the specified gridbag index container.add(component, index); // set the constraints GridBagLayout gbl = (GridBagLayout)container.getLayout(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = gridx; gbc.gridy = gridy; gbc.gridwidth = gridwidth; gbc.gridheight = gridheight; gbc.weightx = weightx; gbc.weighty = weighty; gbc.fill = fill; if (is != null) gbc.insets = is; gbl.setConstraints(component, gbc); }
Example 15
Source File: MotifOptionPaneUI.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates and returns a Container containin the buttons. The buttons * are created by calling <code>getButtons</code>. */ protected Container createButtonArea() { Container b = super.createButtonArea(); if(b != null && b.getLayout() instanceof ButtonAreaLayout) { ((ButtonAreaLayout)b.getLayout()).setCentersChildren(false); } return b; }
Example 16
Source File: TextPanel.java From osp with GNU General Public License v3.0 | 5 votes |
/** * Sets the text. * * The position is ignored if the location is set to a corner. * * @param _text */ public void setText(String _text) { _text = TeXParser.parseTeX(_text); if(text==_text) { return; } text = _text; if(text==null) { text = ""; //$NON-NLS-1$ } final Container c = this.getParent(); if(c==null) { return; } Runnable runner = new Runnable() { public synchronized void run() { if(c.getLayout() instanceof OSPLayout) { ((OSPLayout) c.getLayout()).quickLayout(c, TextPanel.this); repaint(); } else { c.validate(); } } }; if(SwingUtilities.isEventDispatchThread()) { runner.run(); } else { SwingUtilities.invokeLater(runner); } }
Example 17
Source File: MotifOptionPaneUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Creates and returns a Container containin the buttons. The buttons * are created by calling <code>getButtons</code>. */ protected Container createButtonArea() { Container b = super.createButtonArea(); if(b != null && b.getLayout() instanceof ButtonAreaLayout) { ((ButtonAreaLayout)b.getLayout()).setCentersChildren(false); } return b; }
Example 18
Source File: MotifOptionPaneUI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Creates and returns a Container containin the buttons. The buttons * are created by calling <code>getButtons</code>. */ protected Container createButtonArea() { Container b = super.createButtonArea(); if(b != null && b.getLayout() instanceof ButtonAreaLayout) { ((ButtonAreaLayout)b.getLayout()).setCentersChildren(false); } return b; }
Example 19
Source File: SpringUtilities.java From javamelody with Apache License 2.0 | 4 votes |
private static SpringLayout.Constraints getConstraintsForCell(int row, int col, Container parent, int cols) { final SpringLayout layout = (SpringLayout) parent.getLayout(); final Component c = parent.getComponent(row * cols + col); return layout.getConstraints(c); }
Example 20
Source File: MiscUtil.java From energy2d with GNU Lesser General Public License v3.0 | 4 votes |
private static SpringLayout.Constraints getConstraintsForCell(int r, int c, Container parent, int cols) { SpringLayout layout = (SpringLayout) parent.getLayout(); Component component = parent.getComponent(r * cols + c); return layout.getConstraints(component); }