JDesktopPane

The JDesktopPane is a container which is used to create a multiple-document interface or a virtual desktop.The JFrame inside the desktop becomes JInternalFrame. JInternalFrame is used just like the JFrame but is added to JDesktopPane object.

Progarm

jhgjghjhgj



 
 
 

Program Source

import javax.swing.JFrame;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.JButton;
import java.awt.FlowLayout;

class JInternalFrameTest extends JFrame {
    
    private JDesktopPane jd = new JDesktopPane();
            
    JInternalFrameTest()
    {
        setTitle("JInternalFrame");
        setJInternalFrame(jd,"InternalFrame1",30,30);
        setJInternalFrame(jd,"InternalFrame2",60,60);
        setJDesktopPane();
        setSize(700,400);
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    
    void setJDesktopPane()
    {
        add(jd);
    }
    
    void setJInternalFrame(JDesktopPane jd,String name,int loc1,int loc2)
    {
        JInternalFrame jn = new JInternalFrame(name,true,true,true,true);
        jn.setLayout(new FlowLayout());
        jn.setSize(300, 300);
        jn.add(new JButton("JButton"));
        jn.setLocation(loc2, loc2);
        jn.setVisible(true);
        jd.add(jn);
    }
}
 
public class Javaapp {
  
    public static void main(String[] args) {
        
        JInternalFrameTest jn = new JInternalFrameTest();
    }
}

Leave a Comment