Example usage for javax.swing JDesktopPane JDesktopPane

List of usage examples for javax.swing JDesktopPane JDesktopPane

Introduction

In this page you can find the example usage for javax.swing JDesktopPane JDesktopPane.

Prototype

public JDesktopPane() 

Source Link

Document

Creates a new JDesktopPane.

Usage

From source file:Main.java

public static void main(String[] a) {
    final JFrame jf = new JFrame("JIFrameDemo Main Window");

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    screenSize.width -= 42;//  w  ww .j  a  v a2 s  . c om
    screenSize.height -= 42;
    jf.setSize(screenSize);
    jf.setLocation(20, 20);

    JMenuBar mb = new JMenuBar();
    jf.setJMenuBar(mb);
    JMenu fm = new JMenu("File");
    mb.add(fm);
    JMenuItem mi;
    fm.add(mi = new JMenuItem("Exit"));
    mi.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });

    JDesktopPane dtp = new JDesktopPane();
    //dtp.setBackground(Color.GREEN);
    jf.setContentPane(dtp);

    JInternalFrame mboxFrame = new JInternalFrame("Mail Reader", true, true, true, true);
    JLabel reader = new JLabel("Mail Reader Would Be Here");
    mboxFrame.setContentPane(reader);
    mboxFrame.setSize(400, 300);
    mboxFrame.setLocation(50, 50);
    mboxFrame.setVisible(true);
    dtp.add(mboxFrame);

    JInternalFrame compFrame = new JInternalFrame("Compose Mail", true, true, true, true);
    JLabel composer = new JLabel("Mail Compose Would Be Here");
    compFrame.setContentPane(composer);
    compFrame.setSize(300, 200);
    compFrame.setLocation(200, 200);
    compFrame.setVisible(true);
    dtp.add(compFrame);

    JInternalFrame listFrame = new JInternalFrame("Users", true, true, true, true);
    JLabel list = new JLabel("List of Users Would Be Here");
    listFrame.setContentPane(list);
    listFrame.setLocation(400, 400);
    listFrame.setSize(500, 200);
    listFrame.setVisible(true);
    dtp.add(listFrame);

    jf.setVisible(true);
    jf.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            jf.setVisible(false);
            jf.dispose();
            System.exit(0);
        }
    });
}

From source file:MainClass.java

public MainClass(String title) {
    super(title);
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    final JDesktopPane desk = new JDesktopPane();
    setContentPane(desk);//from  w ww.  j ava 2  s .  com
    JOptionPane.showInternalConfirmDialog(desk, "Is this OK?");
}

From source file:MainClass.java

public MainClass(String title) {
    super(title);
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    final JDesktopPane desk = new JDesktopPane();
    setContentPane(desk);/*  w w  w.j  a  v  a  2 s  . co  m*/

    JOptionPane.showInternalInputDialog(desk, "Enter Name");
}

From source file:Figure3.java

public Figure3(String title) {
    super(title);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    desk = new JDesktopPane();
    setContentPane(desk);
}

From source file:SimpleInternalFrame.java

public SimpleInternalFrame() {
    super("");
    setSize(500, 400);/* w w w .  j a v  a 2 s . c o  m*/

    desktop = new JDesktopPane();
    desktop.setOpaque(true);
    add(desktop, BorderLayout.CENTER);

    internalFrame = new JInternalFrame("Meow", true, true, true, true);
    internalFrame.setBounds(50, 50, 200, 100);
    internalFrame.getContentPane().add(new JLabel(new ImageIcon("1.jpg")));
    internalFrame.setVisible(true);

    desktop.add(internalFrame, new Integer(1));
}

From source file:Main.java

private void test() {
    myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    myFrame.setBounds(50, 50, 250, 150);
    myFrame.setContentPane(new JDesktopPane());
    JMenuBar myMenuBar = new JMenuBar();
    JMenu myMenu = getDialogMenu();
    myMenuBar.add(myMenu);//  w w  w .ja v  a 2 s .  com
    myFrame.setJMenuBar(myMenuBar);
    myFrame.setVisible(true);
}

From source file:CascadeDemo.java

public CascadeDemo() {
    super("CascadeDemo");
    EARTH = new ImageIcon("earth.jpg");
    m_count = m_tencount = 0;// w  ww . java  2 s  . c  o m

    m_desktop = new JDesktopPane();
    m_desktop.putClientProperty("JDesktopPane.dragMode", "outline");
    m_newFrame = new JButton("New Frame");
    m_newFrame.addActionListener(this);

    m_infos = UIManager.getInstalledLookAndFeels();
    String[] LAFNames = new String[m_infos.length];
    for (int i = 0; i < m_infos.length; i++) {
        LAFNames[i] = m_infos[i].getName();
    }
    m_UIBox = new JComboBox(LAFNames);
    m_UIBox.addActionListener(this);

    JPanel topPanel = new JPanel(true);
    topPanel.add(m_newFrame);
    topPanel.add(new JLabel("Look & Feel:", SwingConstants.RIGHT));
    topPanel.add(m_UIBox);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add("North", topPanel);
    getContentPane().add("Center", m_desktop);

    setSize(570, 400);
    Dimension dim = getToolkit().getScreenSize();
    setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2);
    setVisible(true);
    WindowListener l = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(l);
}

From source file:Main.java

public Main() {
    JMenuBar bar = new JMenuBar();
    JMenu addMenu = new JMenu("Add");
    JMenuItem newFrame = new JMenuItem("Internal Frame");
    addMenu.add(newFrame);/*from  w  w  w .  j  a  v a 2s.co m*/
    bar.add(addMenu);
    setJMenuBar(bar);

    final JDesktopPane theDesktop = new JDesktopPane();
    getContentPane().add(theDesktop);

    newFrame.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JInternalFrame frame = new JInternalFrame("Internal Frame", true, true, true, true);

            Container c = frame.getContentPane();
            MyJPanel panel = new MyJPanel();

            c.add(panel, BorderLayout.CENTER);
            frame.setSize(200, 200);
            frame.setOpaque(true);
            theDesktop.add(frame);
        }
    });

    setSize(500, 400);
    setVisible(true);
}

From source file:Main.java

private Component createDesktop() {
    JDesktopPane d = new JDesktopPane();
    internalFrame = new Internal("first");
    d.add(internalFrame);//from  w w w  .  j  av  a2 s .c  o m
    return d;
}

From source file:DialogDesktop.java

public DialogDesktop(String title) {
    super(title);
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    final JDesktopPane desk = new JDesktopPane();
    setContentPane(desk);/*www . ja  va  2s  .  co m*/

    // Create our "real" application container; use any layout manager we
    // want.
    final JPanel p = new JPanel(new GridBagLayout());

    // Listen for desktop resize events so we can resize p. This will ensure
    // that
    // our container always fills the entire desktop.
    desk.addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent ev) {
            Dimension deskSize = desk.getSize();
            p.setBounds(0, 0, deskSize.width, deskSize.height);
            p.validate();
        }
    });

    // Add our application panel to the desktop. Any layer below the
    // MODAL_LAYER
    // (where the dialogs will appear) is fine. We'll just use the default
    // in
    // this example.
    desk.add(p);

    // Fill out our app with a few buttons that create dialogs
    JButton input = new JButton("Input");
    JButton confirm = new JButton("Confirm");
    JButton message = new JButton("Message");
    p.add(input);
    p.add(confirm);
    p.add(message);

    input.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            JOptionPane.showInternalInputDialog(desk, "Enter Name");
        }
    });

    confirm.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            JOptionPane.showInternalConfirmDialog(desk, "Is this OK?");
        }
    });

    message.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            JOptionPane.showInternalMessageDialog(desk, "The End");
        }
    });
}