Pagina 3 di 3 primaprima 1 2 3
Visualizzazione dei risultati da 21 a 22 su 22

Discussione: [JAVA] Frame di frame!

  1. #21
    No, esiste:

    direttamente dal sito della sun:
    codice:
    With the JInternalFrame class you can display a JFrame-like window within another window. Usually, you add internal frames to a desktop pane. The desktop pane, in turn, might be used as the content pane of a JFrame. The desktop pane is an instance of JDesktopPane, which is a subclass of JLayeredPane that has added API for managing multiple overlapping internal frames. 
    
    You should consider carefully whether to base your program's GUI around frames or internal frames. Switching from internal frames to frames or vice versa isn't necessarily a simple task. By experimenting with both frames and internal frames, you can get an idea of the tradeoffs involved in choosing one over the other. 
    
    Here is a picture of an application that has two internal frames (one of which is iconified) inside a regular frame:
    e questo è il modo per usarlo:
    codice:
    The following code, taken from InternalFrameDemo.java, creates the desktop and internal frames in the previous example. 
    
    ...//In the constructor of InternalFrameDemo, a JFrame subclass:
        desktop = new JDesktopPane();
        createFrame(); //Create first window
        setContentPane(desktop);
        ...
        //Make dragging a little faster but perhaps uglier.
        desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    ...
    protected void createFrame() {
        MyInternalFrame frame = new MyInternalFrame();
        frame.setVisible(true); //necessary as of 1.3
        desktop.add(frame);
        try {
            frame.setSelected(true);
        } catch (java.beans.PropertyVetoException e) {}
    }
    
    ...//In the constructor of MyInternalFrame, a JInternalFrame subclass:
    static int openFrameCount = 0;
    static final int xOffset = 30, yOffset = 30;
    
    public MyInternalFrame() {
        super("Document #" + (++openFrameCount),
              true, //resizable
              true, //closable
              true, //maximizable
              true);//iconifiable
        //...Create the GUI and put it in the window...
        //...Then set the window size or call pack...
        ...
        //Set the window's location.
        setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
    }

  2. #22
    Moderatore di Programmazione L'avatar di LeleFT
    Registrato dal
    Jun 2003
    Messaggi
    17,328
    Appunto... si parla di JInternalFrame e JDesktopPane, non JDesktopFrame. Quelli li conoscevo anch'io!

    Grazie!

    Ciao.
    "Perchè spendere anche solo 5 dollari per un S.O., quando posso averne uno gratis e spendere quei 5 dollari per 5 bottiglie di birra?" [Jon "maddog" Hall]
    Fatti non foste a viver come bruti, ma per seguir virtute e canoscenza

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.