/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.sleuthkit.autopsy.corecomponents;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.openide.windows.WindowManager;
/**
* Displays a panel in a new clean dialog. A clean dialog contains nothing but
* the panel given to it. No additional buttons or features, except the default
* close operation, which is set to dispose.
*/
public class AdvancedConfigurationCleanDialog extends javax.swing.JDialog {
/**
* Creates new form AdvancedConfigurationDialog
*/
public AdvancedConfigurationCleanDialog() {
this(false);
}
/**
* Creates new form AdvancedConfigurationDialog
*/
public AdvancedConfigurationCleanDialog(boolean resizable) {
super((JFrame) WindowManager.getDefault().getMainWindow(), true);
setResizable(resizable);
if (resizable) {
this.setIconImage(null);
}
initComponents();
}
/**
* Display the given panel on a clean dialog.
*
* @param panel the panel to display
*/
public void display(JPanel panel) {
this.setTitle(panel.getName());
panel.setAlignmentX(Component.CENTER_ALIGNMENT);
this.add(panel, 0);
this.pack();
Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
// set the popUp window / JFrame
int w = this.getSize().width;
int h = this.getSize().height;
// set the location of the popUp Window on the center of the screen
setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2);
this.setVisible(true);
}
/**
* Close the dialog.
*/
public void close() {
this.dispose();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS));
pack();
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}