List of utility methods to do JFrame
JFrame | getParentJFrame(java.awt.Container component) get Parent J Frame while (component != null) { if (component.getClass().toString().equals("class javax.swing.JFrame") || component.getClass().getSuperclass().toString().equals("class javax.swing.JFrame")) { return (JFrame) component; component = component.getParent(); return null; ... |
int | getPersistentExtendedStateMask(JFrame frame) Gets JFrame extended state mask for this frame. Object res = frame.getRootPane().getClientProperty(FRAME_PERSISTENT_EXTENDED_STATE_MASK); if (res instanceof Integer) { return (Integer) res; return Integer.MAX_VALUE; |
javax.swing.JFrame | getRootJFrame(Component c) This is the only method that relies on Swing. Object parent = c.getParent(); while (parent != null) { if (parent instanceof javax.swing.JFrame) return (javax.swing.JFrame) parent; parent = ((Component) parent).getParent(); return null; |
Component | getRootJFrame(Component component) Gets the root JFrame from the given Component Object. while (null != component.getParent()) { component = component.getParent(); if (component instanceof JFrame) { break; return component; |
JFrame | getTheJFrame(String title, int width, int height, int x, int y) get The J Frame JFrame jframe = new JFrame(title); jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jframe.setSize(width, height); jframe.setLocation(x, y); jframe.pack(); jframe.setVisible(true); return jframe; |
JFrame | getTopJFrame(Container c) get Top J Frame if (c instanceof JFrame) return (JFrame) c; Container theFrame = c; do { theFrame = theFrame.getParent(); } while ((theFrame != null) && !(theFrame instanceof JFrame)); if (theFrame == null) theFrame = new JFrame(); ... |
String | getUserInput(JFrame _frame, String arg1, String arg2, Object arg3) get User Input if (_frame == null) _frame = frame; Object obj = JOptionPane.showInputDialog(_frame, arg1, arg2, JOptionPane.QUESTION_MESSAGE, null, null, arg3); if (obj != null) return obj.toString(); return null; |
JMenu | getViewMenu(JFrame mainFrame) get View Menu JMenuBar menuBar = mainFrame.getJMenuBar(); MenuElement[] menuElements = menuBar.getSubElements(); for (MenuElement menuElement : menuElements) { if (menuElement instanceof JMenu) { JMenu menu = (JMenu) menuElement; String name = menu.getText(); if (name.equalsIgnoreCase(MENU_NAME)) { return menu; ... |
void | giveFrameHalfScreen(final JFrame frame) give Frame Half Screen final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); final Rectangle winSize = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); final int taskBarHeight = screenSize.height - winSize.height; final int width = (int) (screenSize.width * 0.505); final int height = screenSize.height - taskBarHeight; frame.setSize(width, height); |
void | igualarFormularios(JFrame destino, JFrame origen) igualar Formularios destino.setExtendedState(origen.getExtendedState());
if (origen.getExtendedState() == JFrame.NORMAL) {
destino.setSize(origen.getSize());
destino.setLocation(origen.getLocation());
|