Newsgroup: it.comp.java
Titolo: Visualizzazione JDialog

Ciao a tutti,
questa è la prima volta che scrivo in questo gruppo (ne approfitto per
salutare tutti). Il mio problema è questo: sto sviluppando
un'applicazione dove utilizzo una JDialog come osservatore per
verificare l'avvenuta esecuzione di alcune procedure. In parole povere
ogni volta che viene compiuto un determinato step dell'applicazione la
JDialog mi evidenzia una JLabel con il nome dello step. Quando però
lancio l'applicazione compare il rettangolo della JDialog ma non il
suo contenuto. Ho provato di tutto per vedere di risolvere il
problema, repaint e validate in primo luogo ma senza ottenere
risultati validi. Lo stesso problema accade utilizzando una JFrame.
Vi ringrazio per l'aiuto.
iDoctor

 suo contenuto. Ho provato di tutto per vedere di risolvere il
prima di far comparire la JDialog devi (se non lo fai gia') scrivere
qualcosa nella JLabel...
altrimenti posta il codice...

 altrimenti posta il codice...
La JDialog è già formattata in tutti i suoi campi.
Questo è il codice:
public class JDialogWorkingProgress extends javax.swing.JDialog
implements Observer {
	//Gestione classe con Pattern SINGLETON
	private static JDialogWorkingProgress
instanceOfJDialogWorkingProgress = null;
	private static final long serialVersionUID = 1L;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JCheckBox jCheckBox3;
    private javax.swing.JCheckBox jCheckBox4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JProgressBar jProgressBar1;
	private MakeLoginMAIN makeLoginMAIN = null;
	private MakeLogoutMAIN makeLogoutMAIN = null;
	private MakeAccesToRES accessToRES = null;
	private MakeOpenM0999 makeOpenM0999 = null;
	private MakeCloseM0999 makeCloseM0999 = null;
	private MakeOpenNewRESDirectory makeOpenNewRESDirectory = null;
	private MakeCloseRESDirectory makeCloseRESDirectory = null;
	private MakeOpenExistRESDirectory makeOpenExistRESDirectory = null;
	private MakeDeleteExistRESDirectory makeDeleteExistRESDirectory =
null;
	private MakeCreateDirectory makeCreateDirectory = null;
	private MakeDownloadFile makeDownloadFile = null;
	private MakeCloseOrder makeCloseOrder = null;
	private MakeArchiveOrder makeArchiveOrder = null;
	private MakeRestoreOrder makeRestoreOrder = null;
	/**
	 * Creates new form JDialogWorkingProgress
	 */
	private JDialogWorkingProgress(Frame owner) {
		super(owner, false);
		initComponents();
		makeLoginMAIN = MakeLoginMAIN.getLoginToMAIN();
		makeLogoutMAIN = MakeLogoutMAIN.getLogoutToMAIN();
		accessToRES = MakeAccesToRES.getAccesToRES();
		makeOpenM0999 = MakeOpenM0999.getOpenM0999();
		makeCloseM0999 = MakeCloseM0999.getCloseM0999();
		makeOpenNewRESDirectory =
MakeOpenNewRESDirectory.getOpenNewRESDirectory();
		makeCloseRESDirectory =
MakeCloseRESDirectory.getCloseNewRESDirectory();
		makeOpenExistRESDirectory =
MakeOpenExistRESDirectory.getOpenExistRESDirectory();
		makeDeleteExistRESDirectory =
MakeDeleteExistRESDirectory.getDeleteExistRESDirectory();
		makeCreateDirectory = MakeCreateDirectory.getMakeCreateDirectory();
		makeDownloadFile = MakeDownloadFile.getMakeDownloadFile();
		makeCloseOrder = MakeCloseOrder.getMakeCloseOrder();
		makeArchiveOrder = MakeArchiveOrder.getMakeArchiveOrder();
		makeRestoreOrder = MakeRestoreOrder.getMakeRestoreOrder();
		makeLoginMAIN.addObserver(this);
		makeLogoutMAIN.addObserver(this);
		accessToRES.addObserver(this);
		makeOpenM0999.addObserver(this);
		makeCloseM0999.addObserver(this);
		makeOpenNewRESDirectory.addObserver(this);
		makeCloseRESDirectory.addObserver(this);
		makeOpenExistRESDirectory.addObserver(this);
		makeDeleteExistRESDirectory.addObserver(this);
		makeCreateDirectory.addObserver(this);
		makeDownloadFile.addObserver(this);
		makeCloseOrder.addObserver(this);
		makeArchiveOrder.addObserver(this);
		makeRestoreOrder.addObserver(this);
		RepaintManager.currentManager(this).setDoubleBufferingEnabled(true);
		resetCheckBox();
	}
	public static JDialogWorkingProgress getJDialogWorkingProgress(Frame
owner) {
    	if(instanceOfJDialogWorkingProgress == null) {
    		instanceOfJDialogWorkingProgress = new
JDialogWorkingProgress(owner);
		}
		return instanceOfJDialogWorkingProgress;
    }
	/** 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.
	 */
	// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//
GEN-BEGIN:initComponents
	private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jCheckBox1 = new javax.swing.JCheckBox();
        jCheckBox2 = new javax.swing.JCheckBox();
        jProgressBar1 = new javax.swing.JProgressBar();
        jCheckBox3 = new javax.swing.JCheckBox();
        jCheckBox4 = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
 
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setAlwaysOnTop(true);
        setFocusCycleRoot(true);
        setFocusable(true);
        setFocusableWindowState(true);
        setIconImage(null);
        setResizable(false);
        setUndecorated(false);
        setTitle("Working Progress...");
        jPanel1.setFocusable(false);
        jPanel1.setRequestFocusEnabled(false);
        jPanel2.setFocusable(false);
        jPanel2.setOpaque(false);
        jPanel2.setRequestFocusEnabled(false);
        jPanel2.setVerifyInputWhenFocusTarget(false);
 
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel5.setIcon(new javax.swing.ImageIcon("C:\\Tutto Java\
\Progetti Java\\Octopus\\ico\\splash.gif"));
        jLabel5.setDoubleBuffered(true);
        javax.swing.GroupLayout jPanel2Layout = new
javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
 
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(78, 78, 78)
                .addComponent(jLabel5,
javax.swing.GroupLayout.PREFERRED_SIZE, 190,
javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
 
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jLabel5)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
        );
        jCheckBox1.setBorder(null);
        jCheckBox1.setDoubleBuffered(true);
        jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jCheckBox2.setBorder(null);
        jCheckBox2.setDoubleBuffered(true);
        jCheckBox2.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jProgressBar1.setDoubleBuffered(true);
        jProgressBar1.setFocusable(false);
        jProgressBar1.setRequestFocusEnabled(false);
        jProgressBar1.setIndeterminate(true);
 
jCheckBox3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0,
0, 0));
        jCheckBox3.setDoubleBuffered(true);
        jCheckBox3.setMargin(new java.awt.Insets(0, 0, 0, 0));
 
jCheckBox4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0,
0, 0));
        jCheckBox4.setDoubleBuffered(true);
        jCheckBox4.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jLabel1.setText("Login MAIN");
        jLabel1.setDoubleBuffered(true);
        jLabel2.setText("Crea Ordine");
        jLabel2.setDoubleBuffered(true);
        jLabel3.setText("Download Files");
        jLabel3.setDoubleBuffered(true);
        jLabel4.setText("Logout MAIN");
        jLabel4.setDoubleBuffered(true);
        javax.swing.GroupLayout jPanel1Layout = new
javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
 
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jCheckBox1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel1))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jCheckBox2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2))
                    .addComponent(jProgressBar1,
javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jCheckBox3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jCheckBox4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4)))
                .addContainerGap())
            .addComponent(jPanel2,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
 
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCheckBox1)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jCheckBox2)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jCheckBox3)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jCheckBox4)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
18, Short.MAX_VALUE)
                        .addComponent(jProgressBar1,
javax.swing.GroupLayout.PREFERRED_SIZE, 8,
javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel2,
javax.swing.GroupLayout.PREFERRED_SIZE, 101,
javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
        pack();
		validate();
		repaint(getX(), getY(), getWidth(), getHeight());
		// Center the Window
        Dimension screenSize =
Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = this.getSize();
        if (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        }
        if (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        }
        this.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
		// Center the Window
	}// </editor-fold>
	private void resetCheckBox() {
		jLabel1.setEnabled(false);
		jLabel2.setEnabled(false);
		jLabel3.setEnabled(false);
		jLabel4.setEnabled(false);
		jCheckBox1.setSelected(false);
		jCheckBox2.setSelected(false);
		jCheckBox3.setSelected(false);
		jCheckBox4.setSelected(false);
	}
	public void update(Observable o, Object arg) {
		System.out.println("Stato ricevuto.");
		System.out.println("Oggetto osservato: " +
o.getClass().getSimpleName() + "\n");
		setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
		if(makeLoginMAIN.getClass().getSimpleName().equals(arg)) {
			resetCheckBox();
			jLabel1.setEnabled(true);
			jCheckBox1.setSelected(true);
		}
		if(makeCreateDirectory.getClass().getSimpleName().equals(arg)) {
			resetCheckBox();
			jLabel2.setEnabled(true);
			jCheckBox2.setSelected(true);
		}
		if(makeDownloadFile.getClass().getSimpleName().equals(arg)) {
			resetCheckBox();
			jLabel3.setEnabled(true);
			jCheckBox3.setSelected(true);
		}
		if(makeLogoutMAIN.getClass().getSimpleName().equals(arg)) {
			resetCheckBox();
			jLabel4.setEnabled(true);
			jCheckBox4.setSelected(true);
		}
		validate();
		repaint(getX(), getY(), getWidth(), getHeight());
	}
}
Grazie mille!!