Working with Internal Frames within a Desktop : InternalFrame « Swing JFC « Java






Working with Internal Frames within a Desktop

  
import java.awt.BorderLayout;
import java.awt.Container;

import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;

public class InternalTest {
  public static void main(String args[]) {
    JFrame frame = new JFrame();
    Container contentPane = frame.getContentPane();
    JLayeredPane desktop = new JDesktopPane();
    desktop.setOpaque(false);
    desktop.add(createLayer("One"), JLayeredPane.POPUP_LAYER);
    desktop.add(createLayer("Two"), JLayeredPane.DEFAULT_LAYER);
    desktop.add(createLayer("Three"), JLayeredPane.PALETTE_LAYER);
    contentPane.add(desktop, BorderLayout.CENTER);
    frame.setSize(300, 300);
    frame.show();
  }

  static JInternalFrame createLayer(String label) {
    return new SelfInternalFrame(label);
  }

  static class SelfInternalFrame extends JInternalFrame {
    public SelfInternalFrame(String s) {
      getContentPane().add(new JLabel(s, JLabel.CENTER),
          BorderLayout.CENTER);
      setBounds(50, 50, 100, 100);
      setResizable(true);
      setClosable(true);
      setMaximizable(true);
      setIconifiable(true);
      setTitle(s);
      setVisible(true);
    }
  }
}


           
         
    
  








Related examples in the same category

1.A quick demonstration of setting up an internal frame in an applicationA quick demonstration of setting up an internal frame in an application
2.A simple extension of the JInternalFrame class that contains a list
3.JDesktopPane demoJDesktopPane demo
4.Internal Frames DemoInternal Frames Demo
5.JDesktopPane Cascade DemoJDesktopPane Cascade Demo
6.Java X WindowsJava X Windows
7.Desktop Manager DemoDesktop Manager Demo
8.Internal Frame Listener Demo Internal Frame Listener Demo
9.Layered Pane DemoLayered Pane Demo
10.LayeredPane Demo 2: Custom MDILayeredPane Demo 2: Custom MDI
11.LayeredPane Demo 3: Custom MDILayeredPane Demo 3: Custom MDI
12.LayeredPane Demo 4: Custom MDILayeredPane Demo 4: Custom MDI
13.Implements InternalFrameListenerImplements InternalFrameListener
14.InternalFrame demoInternalFrame demo
15.InternalFrameEvent DemoInternalFrameEvent Demo
16.A few interesting things using JInternalFrames, JDesktopPane, and DesktopManagerA few interesting things using JInternalFrames, JDesktopPane, and DesktopManager
17.A quick setting up an Internal Frame in an applicationA quick setting up an Internal Frame in an application
18.Interesting things using JInternalFrames, JDesktopPane, and DesktopManager 2Interesting things using JInternalFrames, JDesktopPane, and DesktopManager 2
19.Make a JInternalFrame a tool window
20.Move JInternalFrame To Front
21.This program demonstrates the use of internal framesThis program demonstrates the use of internal frames