List of utility methods to do JComponent Container
Rectangle | getLocalInsetBounds(JComponent component) get Local Inset Bounds Insets insets = component.getInsets(); return new Rectangle(insets.left, insets.top, component.getWidth() - (insets.left + insets.right), component.getHeight() - (insets.top + insets.bottom)); |
Component | getMandatoryPanel(JComponent c) get Mandatory Panel Box box = Box.createHorizontalBox(); box.add(c); box.add(new JLabel(LABEL_MANDATORY)); return box; |
int | getMaxVisibleY(JComponent comp) get Max Visible Y final Rectangle rect = comp.getVisibleRect(); return rect.y + rect.height - 1; |
Object | getModelObject(JComponent c) get Model Object if (c instanceof JTree) { final TreePath path = ((JTree) c).getSelectionPath(); final Object pathComponent = path.getLastPathComponent(); if (pathComponent instanceof DefaultMutableTreeNode) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) pathComponent; final Object userObject = node.getUserObject(); return userObject; return null; |
JRootPane | getOutermostRootPane(Component c) If c is a JRootPane descendant return its outermost JRootPane ancestor. if (c instanceof RootPaneContainer && c.getParent() == null) { return ((RootPaneContainer) c).getRootPane(); JRootPane lastRootPane; for (; c != null; c = SwingUtilities.getRootPane(c)) { if (c instanceof JRootPane) { lastRootPane = (JRootPane) c; if (c.getParent().getParent() == null) { ... |
JRootPane | getOutermostRootPane(Component c) get Outermost Root Pane if (((c instanceof RootPaneContainer)) && (c.getParent() == null)) { return ((RootPaneContainer) c).getRootPane(); for (; c != null; c = SwingUtilities.getRootPane(c)) { if ((c instanceof JRootPane)) { JRootPane lastRootPane = (JRootPane) c; if (c.getParent().getParent() == null) { return lastRootPane; ... |
JPanel | getPanelFor(JComponent comp1, JComponent comp2) get Panel For JPanel panel = new JPanel(); panel.setLayout(new FlowLayout(FlowLayout.CENTER)); panel.add(comp1); panel.add(comp2); return panel; |
JPanel | getPanelFor(JComponent comp1, JComponent comp2) get Panel For JPanel panel = new JPanel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT)); panel.add(comp1); panel.add(comp2); return panel; |
JComponent | getParent(JComponent parent, final int... path) get Parent for (final int i : path) { parent = (JComponent) parent.getComponent(i); return parent; |
Container | getParentPanel(JComponent jc) go to parent that is not a scroll pane Container parent = jc.getParent(); while (parent != null) { if (parent instanceof JPanel) return parent; if (parent instanceof JFrame) return parent; if (parent instanceof JDialog) return parent; ... |