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

voidcloseWindow(final JFrame frame)
Send a WindowEvent#WINDOW_CLOSING event to the given window.
final WindowEvent ev = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING);
frame.dispatchEvent(ev);
voidconfigToApplicationFrame(JFrame frm)
config To Application Frame
configToApplicationFrame(frm, "Application");
booleanconfirm(JFrame parent, String query, int type)
confirm
return JOptionPane.showConfirmDialog(parent, query, "UploadR", JOptionPane.YES_NO_OPTION, type) == 0;
WindowAdaptercreateConfirmOnExitAdapter(final JFrame frame, final String title, final String message)
create Confirm On Exit Adapter
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
return new java.awt.event.WindowAdapter() {
    public void windowClosing(java.awt.event.WindowEvent ev) {
        int result = JOptionPane.showConfirmDialog(frame, message, title, JOptionPane.YES_OPTION);
        if (result == JOptionPane.OK_OPTION) {
            frame.getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            System.exit(0);
};
JDialogcreateDialogForPanel(JFrame parent, JPanel panel)
create Dialog For Panel
JDialog newdialog = new JDialog(parent);
newdialog.getContentPane().add(panel, java.awt.BorderLayout.CENTER);
newdialog.pack();
return newdialog;
javax.swing.JFramecreatePackedJFrame(java.awt.Component content, String title, int closeOperation)
create Packed J Frame
javax.swing.JFrame rv = new javax.swing.JFrame();
rv.setTitle(title);
rv.getContentPane().add(content);
rv.pack();
rv.setDefaultCloseOperation(closeOperation);
return rv;
voiddecorateFrame(JFrame frame, JMenuBar menuBar)
_more_
if ((frame != null & menuBar != null) && doMacMenubar()) {
    frame.setJMenuBar(menuBar);
booleandeleteFile(String filepath, JFrame parent)
Deletes the given file
File tempFile = new File(filepath);
File trashFile = new File(ClassLoader.getSystemResource("trash").getPath(), new File(filepath).getName());
if (trashFile.exists())
    recursiveDeleteFile(trashFile);
if (tempFile.exists() && !tempFile.renameTo(trashFile)) {
    String errstr = "Unable to delete module.. Please check if trash path exists...";
    JOptionPane.showMessageDialog(parent, errstr, "File Delete Error", JOptionPane.ERROR_MESSAGE);
    return false;
...
intdialogYesNo(JFrame frame, String title, String message, Object[] options)
dialog Yes No
JOptionPane pane = new JOptionPane(message);
pane.setOptions(options);
JDialog dialog = pane.createDialog(frame, title);
dialog.setVisible(true);
Object obj = pane.getValue();
for (int i = 0; i < options.length; i++) {
    if (options[i].equals(obj)) {
        return i;
...
voiddispAlert(JFrame pFrame, String pTask, String pMessaggio)
visualizzazione messaggio HTML
JOptionPane.showMessageDialog(pFrame, formattaHTML(pMessaggio), ALERT_TITLE, JOptionPane.OK_CANCEL_OPTION);