jdesktoppane
www.igtfiidea.com
JDesktopPane is a Swing container that provides a workspace for arranging and managing internal frames. An internal frame is a subwindow that exists within the JDesktopPane and can be moved, resized, and iconified. It is often used in desktop applications to create a multitasking environment.
Here's an example of how to create a simple application that uses JDesktopPane and JInternalFrame.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DesktopDemo extends JFrame {
private JDesktopPane desktop;
public DesktopDemo() {
super("Desktop Demo");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create a desktop pane and set it as the content pane
desktop = new JDesktopPane();
setContentPane(desktop);
// Create a menu bar with a menu that allows the user to create new internal frames
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("File");
menuBar.add(menu);
JMenuItem newItem = new JMenuItem("New");
newItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
createInternalFrame();
}
});
menu.add(newItem);
setJMenuBar(menuBar);
// Set the size and location of the window
setSize(500, 500);
setLocationRelativeTo(null);
}
private void createInternalFrame() {
JInternalFrame frame = new JInternalFrame("Internal Frame", true, true, true, true);
frame.setSize(200, 200);
frame.setVisible(true);
desktop.add(frame);
}
public static void main(String[] args) {
DesktopDemo demo = new DesktopDemo();
demo.setVisible(true);
}
}
This creates a window with a menu bar that allows the user to create new internal frames. When the user clicks the "New" menu item, the createInternalFrame method is called, which creates a new internal frame and adds it to the desktop pane.
