List of utility methods to do JFrame
void | error(JFrame frame, String msg) error Object[] options = { "OK" }; JOptionPane.showOptionDialog(frame, msg, "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]); |
void | exitFullScreen(JFrame mainAppFrame) exit Full Screen mainAppFrame.dispose(); mainAppFrame.setUndecorated(fsFrameUndecorated); mainAppFrame.setResizable(fsFrameResizable); mainAppFrame.setSize(fsFrameSize); mainAppFrame.setLocation(fsFrameLocation); GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(null); mainAppFrame.setVisible(true); |
File | fileChooser(JFrame frame, boolean saveDialog, String windowName, String filterName, String filterExtension) file Chooser JFileChooser fileChooser = new JFileChooser(System.getProperty("user.dir")); fileChooser.setAcceptAllFileFilterUsed(false); fileChooser.setFileFilter(new FileNameExtensionFilter(filterName, filterExtension)); File file = null; if (fileChooser.showDialog(frame, windowName) == JFileChooser.APPROVE_OPTION) { String ext = extension(fileChooser.getSelectedFile()); String message = null; if (saveDialog) ... |
File | findFileOpen(JFrame frame, String ext, String desc) find File Open JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(new FileNameExtensionFilter(desc, ext)); if (chooser.showOpenDialog(frame) != JFileChooser.APPROVE_OPTION) { return null; return chooser.getSelectedFile(); |
File | findFileSave(JFrame frame, String ext, String desc) find File Save JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(new FileNameExtensionFilter(desc, ext)); if (chooser.showSaveDialog(frame) != JFileChooser.APPROVE_OPTION) { return null; return getSelectedFileWithExtension(chooser); |
JFrame | findJFrame(Component c) Locates the JFrame for the given component if (c == null) { return null; } else if (c instanceof RootPaneContainer) { return (JFrame) c; } else { return findJFrame(c.getParent()); |
JFrame | findJFrame(Component myComponent) find J Frame Component currentParent = myComponent; JFrame myFrame = null; while (currentParent != null) { if (currentParent instanceof JFrame) { myFrame = (JFrame) currentParent; break; currentParent = currentParent.getParent(); ... |
void | fitToDesktop(final JFrame frame) fit To Desktop final int minWidth = (int) Math.min(frame.getBounds().getWidth(), desktopBounds.getWidth()); final int minHeight = (int) Math.min(frame.getBounds().getHeight(), desktopBounds.getHeight()); frame.setSize(minWidth, minHeight); |
void | fullScreen(JFrame window) full Screen Toolkit kit = Toolkit.getDefaultToolkit(); Dimension screenSize = kit.getScreenSize(); screenSize.width = screenSize.width * 2 / 3; screenSize.height = screenSize.height * 2 / 3; window.setMinimumSize(screenSize); window.setLocation(screenSize.width * 1 / 6, screenSize.height * 1 / 6); window.setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH); |
void | fullScreenUsingMaximise(JFrame w) full Screen Using Maximise w.setExtendedState(Frame.MAXIMIZED_BOTH); w.setAlwaysOnTop(true); |