Java Utililty Methods JFrame

List of utility methods to do JFrame

Description

The list of methods to do JFrame are organized into topic(s).

Method

voidfullScreenWithAPI(JFrame w)
full Screen With API
Rectangle r = null;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
GraphicsDevice gd = w.getGraphicsConfiguration().getDevice();
if (gs.length > 0) {
    GraphicsDevice device = gs[0];
    if (device.isFullScreenSupported()) {
        System.out.println("Full screen supported"); 
...
FilegetFileSelection(JFrame parent, boolean onlyDirectories, String startingDir)
get File Selection
if (System.getProperty("os.name").toLowerCase().indexOf("mac") != -1) {
    FileDialog fileDialog = new FileDialog(parent, "Select directory to dump source into", FileDialog.LOAD);
    fileDialog.setDirectory(startingDir);
    fileDialog.setVisible(true);
    if (fileDialog.getFile() != null) {
        return new File(fileDialog.getFile());
} else {
...
JFramegetJFrame(Component cmp)
Gets the parent JFrame of the component.
return (JFrame) SwingUtilities.getWindowAncestor(cmp);
JFramegetjFrame(int width, int height)
getj Frame
JFrame frame = new JFrame(WINDOW_TITLE);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setSize(width, height);
return frame;
JFramegetJFrame(JPanel panel, String title, int width, int height)
get J Frame
JFrame f = new JFrame(title);
f.setContentPane(panel);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(new Dimension(width, height));
return f;
JFramegetJFrame(Window window)
get J Frame
if (window instanceof JFrame) {
    return (JFrame) window;
return null;
JFramegetJFrameOfComponent(Component cmpnt)
get J Frame Of Component
if (cmpnt == null) {
    throw new IllegalArgumentException("cmpnt == null");
Container cntr = cmpnt.getParent();
while (true) {
    if (cntr == null)
        break;
    if (cntr instanceof JFrame)
...
JDialoggetModalDlg(JFrame frame, String title)
get Modal Dlg
JDialog dlg;
if (frame == null)
    dlg = new JDialog(__frame, true);
else if (__modalDlg != null && __modalDlg.isVisible())
    dlg = null;
else
    dlg = __modalDlg = new JDialog(frame, true);
dlg.setModal(true);
...
JFramegetParentJFrame(Component c)
get Parent J Frame
for (Container p = c.getParent(); p != null; p = p.getParent()) {
    if (p instanceof JFrame) {
        return (JFrame) p;
return null;
JFramegetParentJFrame(Container theFrame)
finds a parent JFrame for the specified container.
do {
    theFrame = theFrame.getParent();
} while ((theFrame != null) && !(theFrame instanceof JFrame));
if (theFrame == null)
    theFrame = new JFrame();
return (JFrame) theFrame;