List of utility methods to do JFrame Parent
void | ensureVisibilityAtParent(final JInternalFrame frame) ensure Visibility At Parent final JComponent parent = (JComponent) frame.getParent(); final Rectangle parentRect = SwingUtilities.calculateInnerArea(parent, null); final Rectangle frameRect = frame.getBounds(); final int x = Math.min(frameRect.x, Math.max(0, parentRect.width - frameRect.width)); final int y = Math.min(frameRect.y, Math.max(0, parentRect.height - frameRect.height)); frame.setLocation(x, y); |
void | execLoop(JComponent editor, Frame parent, boolean modal, int w, int h) exec Loop JDialog dialog = new JDialog(parent, modal); Container contentPane = dialog.getContentPane(); contentPane.setLayout(new BorderLayout()); JScrollPane scrollPane = new JScrollPane(editor); contentPane.add(scrollPane, BorderLayout.CENTER); dialog.setSize(w, h); centerWindow(dialog); dialog.setVisible(true); ... |
File | fileOpen(Frame parent, String typename, String ext) file Open JFileChooser chooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter(typename, ext); chooser.setFileFilter(filter); chooser.setCurrentDirectory(lastpathload != null ? new File(lastpathload) : null); int returnVal = chooser.showOpenDialog(parent); if (returnVal == JFileChooser.APPROVE_OPTION) { lastpathload = chooser.getSelectedFile().getPath(); return chooser.getSelectedFile(); ... |
Object | findParentDialogOrFrame(Container container) Look for a JDialog or JFrame in the parent hierarchy of this specified container and return that JDialog or JFrame. while (container != null) { if (container instanceof JFrame || container instanceof JDialog) { return container; container = container.getParent(); return null; |
Component | getFirstParentFrameOrDialog(Component cmp) Return the first parent that is a JFrame or a JDialog .
while (cmp != null) { if (cmp instanceof JFrame || cmp instanceof JDialog) { return cmp; cmp = cmp.getParent(); return null; |
Frame | getFrame(Component parent) Find the parent Frame. if (parent == null) { Frame option = JOptionPane.getRootFrame(); if (!option.getClass().getName().startsWith("javax.swing.SwingUtilities$")) { return option; Frame best = null; int bestSize = 0; Frame[] frames = Frame.getFrames(); ... |
JFrame | getFrameParent(Component component) get Frame Parent Window windowAncestor = getWindowParent(component); if (windowAncestor instanceof JFrame) return (JFrame) windowAncestor; return null; |
Action | getInstalledOperation(final RootPaneContainer frame, final Object actionKey, boolean selfOnly) Returns the Action installed under the specified action key in the specified frame. JRootPane root = frame.getRootPane(); if (selfOnly) { ActionMap actionMap = root.getActionMap(); ActionMap parentMap = actionMap.getParent(); actionMap.setParent(null); Action result = actionMap.get(actionKey); actionMap.setParent(parentMap); return result; ... |
Frame | getParentalFrame(Component n) Get the Frame a Component is contained in. while (!(n instanceof Frame) && n != null) n = n.getParent(); return (Frame) n; |
JFrame | getParentFrame(Component component) get Parent Frame Component frame = component; while (!(frame instanceof JFrame)) { frame = frame.getParent(); if (frame == null) { break; return (JFrame) frame; ... |