Java Utililty Methods JFrame Show

List of utility methods to do JFrame Show

Description

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

Method

booleanisShowing(JFrame f)
Is the frame showing
if (f == null) {
    return false;
return f.isShowing() && (f.getState() != Frame.ICONIFIED);
Fileopen(JFrame view)
Creates "Open file" dialog.
int fileChosen = chooser.showDialog(view, "Open file");
if (fileChosen == JFileChooser.APPROVE_OPTION) {
    chooser.requestFocus();
    file = chooser.getSelectedFile();
return file;
voidshow(JFrame frame)
Shows a frame.
frame.setVisible(true);
voidshowAndSaveReportFile(JFrame frmParent, File defaultReportFile, String data)
show And Save Report File
JFileChooser fc = createReportFileChooser(defaultReportFile);
int returnVal = fc.showSaveDialog(frmParent);
if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fc.getSelectedFile();
    try {
        FileWriter writer = new FileWriter(file);
        writer.write(data);
        writer.flush();
...
voidshowDemoFrame(JFrame frame)
Method for demo purposes.
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
frame.setSize((int) (screenSize.width / 1.5), (int) (screenSize.height / 1.5));
center(frame);
frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
        System.exit(0);
});
...
voidshowFrame(JFrame frame)
show Frame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
voidshowFrame(JFrame frame, JFrame parent)
show Frame
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.pack();
frame.setLocation(parent.getX() + (parent.getWidth() - frame.getWidth()) / 2,
        parent.getY() + (parent.getHeight() - frame.getHeight()) / 2);
frame.setVisible(true);
voidshowHelp(JFrame frame, String path)
show Help
File docRoot = new File("iTopologyManager/topologyViewer/src/main/resources/helpdocs");
File docFile = new File(docRoot, path);
URI docURI = docFile.toURI();
if (!java.awt.Desktop.isDesktopSupported()) {
    JOptionPane.showConfirmDialog(frame,
            "Can not open default browser. See the documentation in: " + docURI);
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
...
voidshowModalFrame(final JFrame newFrame, final JFrame owner)
show Modal Frame
addToQue(owner);
newFrame.setLocationRelativeTo(owner);
owner.setVisible(false);
owner.setEnabled(false);
newFrame.setVisible(true);
newFrame.toFront();
Thread t = new Thread(new Runnable() {
    public void run() {
...
voidshowOnScreen(int screen, JFrame frame)
show On Screen
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
if (screen >= 0 && screen < gs.length) {
} else if (gs.length > 0) {
} else {
    throw new RuntimeException("No Screens Found");