Newsgroup: it.comp.java
Titolo: Malfunzionamento di JInternalFrames o JDeskTopPane e JDK 1.4?

Ho provato il seguente esempio con il J2SDK 1.4 ma non compaiono i
frame interni. Ho provato anche un altro esempio analogo e anche in
quel caso non compaiono. Ho Windows Millenium e JDK 1.4 ma temo che
nonostante la compilazione vada a buon fine, nel JDK 1.4 ci sia
qualcosa che non funziona con JInternalFrames o JDeskTopPane.
Qualcuno ha qualcosa da segnalare a riguardo? Grazie.
Ps: solo il primo listato e' significativo per il malfunzionamento.
1) ---------------> file JInternalFrames.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JInternalFrames extends JFrame {
  public static void main(String[] args) {
    new JInternalFrames();
  }
  public JInternalFrames() {
    super("Multiple Document Interface");
    WindowUtilities.setNativeLookAndFeel();
    addWindowListener(new ExitListener());
    Container content = getContentPane();
    content.setBackground(Color.white);
    JDesktopPane desktop = new JDesktopPane();
    desktop.setBackground(Color.white);
    content.add(desktop, BorderLayout.CENTER);
    setSize(450, 400);
    for(int i=0; i<5; i++) {
      JInternalFrame frame
        = new JInternalFrame(("Internal Frame " + i),
                             true, true, true, true);
      frame.setLocation(i*50+10, i*50+10);
      frame.setSize(200, 150);
      frame.setBackground(Color.white);
      desktop.add(frame);
      frame.moveToFront();
    }
    setVisible(true);
  }
}
2) ---------------> file ExitListener.java
import java.awt.*;
import java.awt.event.*;
/** A listener that you attach to the top-level Frame or JFrame of
 *  your application, so quitting the frame exits the application.
 *  1998-99 Marty Hall, 
http://www.apl.jhu.edu/~hall/java/
 */
public class ExitListener extends WindowAdapter {
  public void windowClosing(WindowEvent event) {
    System.exit(0);
  }
}
3) ---------------> file WindowUtilities.java
import javax.swing.*;
import java.awt.*;
/** A few utilities that simplify using windows in Swing.
 *  1998-99 Marty Hall, 
http://www.apl.jhu.edu/~hall/java/
 */
public class WindowUtilities {
  /** Tell system to use native look and feel, as in previous
   *  releases. Metal (Java) LAF is the default otherwise.
   */
  public static void setNativeLookAndFeel() {
    try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch(Exception e) {
      System.out.println("Error setting native LAF: " + e);
    }
  }
  public static void setJavaLookAndFeel() {
    try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch(Exception e) {
      System.out.println("Error setting Java LAF: " + e);
    }
  }
   public static void setMotifLookAndFeel() {
    try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
    } catch(Exception e) {
      System.out.println("Error setting Motif LAF: " + e);
    }
  }
  /** A simplified way to see a JPanel or other Container.
   *  Pops up a JFrame with specified Container as the content pane.
   */
  public static JFrame openInJFrame(Container content,
                                    int width,
                                    int height,
                                    String title,
                                    Color bgColor) {
    JFrame frame = new JFrame(title);
    frame.setBackground(bgColor);
    content.setBackground(bgColor);
    frame.setSize(width, height);
    frame.setContentPane(content);
    frame.addWindowListener(new ExitListener());
    frame.setVisible(true);
    return(frame);
  }
  /** Uses Color.white as the background color. */
  public static JFrame openInJFrame(Container content,
                                    int width,
                                    int height,
                                    String title) {
    return(openInJFrame(content, width, height, title, Color.white));
  }
  /** Uses Color.white as the background color, and the
   *  name of the Container's class as the JFrame title.
   */
  public static JFrame openInJFrame(Container content,
                                    int width,
                                    int height) {
    return(openInJFrame(content, width, height,
                        content.getClass().getName(),
                        Color.white));
  }
}
--
Paolo Guagliumi - ICQ 46580228
_______________________________________
Casale Monferrato - Alessandria - Italy
http://web.tiscali.it/infosapere

qualcosa che non funziona con JInternalFrames o JDeskTopPane.
Era sufficiente applicare:
internalframe.setVisible(true);
Purtroppo 2 libri differenti portavano esempi senza aver settato
questa proprieta' e quindi i frame interni non venivano visualizzati.
Grazie per l'attenzione, ciao.
