Results 1 to 5 of 5

Thread: What are an Internal Frames?

  1. #1
    Join Date
    Aug 2006
    Posts
    300

    What are an Internal Frames?

    I am new to the Java programming language. I have tried to create an internal frame and to some extent I was successful but was not getting the actual result that I needed. I think I was unable to try many things because I do not know the concepts of the internal frame. So can anyone please tell me what are an Internal Frames.?? So tell me how to use it.!? Hoping that somebody would help soon.!!

  2. #2
    Join Date
    Nov 2008
    Posts
    1,192

    Re: What are an Internal Frames?

    You can also display windows inside the main window. For doing that you would have to make use of JInternalFrame class. With the JInternalFrame class you can display a JFrame-like window within another window. Normally an internal frames are added to the desktop pane. You can use the desktop pane of a JFrame. The desktop pane is an instance of JDesktopPane. And the JDesktopPane is a subclass of JLayeredPane that has added API for managing multiple overlapping internal frames. Using the JInternalFrame constructor that just requires a title results in an internal frame that is not resizable, closeable, maximizable, or minimizable.

  3. #3
    Join Date
    Mar 2008
    Posts
    349

    Re: What are an Internal Frames?

    I think that till now you should have got some points on Internal Frames. You should be careful while using the codes for your base of the program. You will have to decide properly about the GUI around frames or internal frames. Because switching from internal frames to frames or vice versa is not always a simple task. Also there are five-argument constructor that accepts boolean values for each of JDesktopPane and JInternalFrame.

  4. #4
    Join Date
    Mar 2008
    Posts
    672

    Re: What are an Internal Frames?

    I have provided you with a sample of coding that will create the desktop and internal frames.
    Code:
    desktop = new JDesktopPane();
        createFrame(); 
        setContentPane(desktop);
        ...
        desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    ...
    protected void createFrame() {
        MyInternalFrame frame = new MyInternalFrame();
        frame.setVisible(true);
        desktop.add(frame);
        try {
            frame.setSelected(true);
        } catch (java.beans.PropertyVetoException e) {}
    }
    
    static int openFrameCount = 0;
    static final int xOffset = 40, yOffset = 40;
    
    public MyInternalFrame() {
        super("Document #" + (++openFrameCount),
              true, 
              true,
              true, 
              true);
        ...
        setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
    }

  5. #5
    Join Date
    Jul 2006
    Posts
    442

    Re: What are an Internal Frames?

    The following is the coding for an Internal Frames in Java. You may feel the coding lengthy but it would be really useful for you when you start studying the more about an Internal Frames. Here is the coding for that :
    Code:
    import javax.swing.JInternalFrame;
    import javax.swing.JFrame;
    import javax.swing.JMenuItem;
    import javax.swing.JMenuBar;
    import javax.swing.JDesktopPane;
    import javax.swing.JMenu;
    import javax.swing.KeyStroke;
    import java.awt.event.*;
    import java.awt.*;
    
    public class InternalFrameDemo extends JFrame
                                   implements ActionListener {
        JDesktopPane desktop;
    
        public InternalFrameDemo() {
            super("InternalFrameTrial");
    
            int inset = 60;
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds(inset, inset,
                      screenSize.width  - inset*2,
                      screenSize.height - inset*2);
    
            desktop = new JDesktopPane(); 
            createFrame(); 
            setContentPane(desktop);
            setJMenuBar(createMenuBar());
    
            desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        }
    
        protected JMenuBar createMenuBar() {
            JMenuBar menuBar = new JMenuBar();
    
            JMenu menu = new JMenu("My File");
            menu.setMnemonic(KeyEvent.VK_D);
            menuBar.add(menu);
    
            JMenuItem menuItem = new JMenuItem("New");
            menuItem.setMnemonic(KeyEvent.VK_N);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(
                    KeyEvent.VK_N, ActionEvent.ALT_MASK));
            menuItem.setActionCommand("new");
            menuItem.addActionListener(this);
            menu.add(menuItem);
    
            menuItem = new JMenuItem("Exit");
            menuItem.setMnemonic(KeyEvent.VK_Q);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(
                    KeyEvent.VK_Q, ActionEvent.ALT_MASK));
            menuItem.setActionCommand("exit");
            menuItem.addActionListener(this);
            menu.add(menuItem);
    
            return menuBar;
        }
    
        public void actionPerformed(ActionEvent e) {
            if ("new".equals(e.getActionCommand())) { 
                createFrame();
            } else { 
                quit();
            }
        }
    
        protected void createFrame() {
            MyInternalFrame frame = new MyInternalFrame();
            frame.setVisible(true); 
            desktop.add(frame);
            try {
                frame.setSelected(true);
            } catch (java.beans.PropertyVetoException e) {}
        }
    
        protected void quit() {
            System.exit(0);
        }
    
        private static void createAndShowGUI() {
            JFrame.setDefaultLookAndFeelDecorated(true);
    
            InternalFrameDemo frame = new InternalFrameDemo();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
            frame.setVisible(true);
        }
    
        public static void main(String[] args) {
       
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
                }
            });
        }
    }
    "When they give you ruled paper, write the other way..." J.R.J.

Similar Threads

  1. HTML Frames
    By Adrina_g in forum Software Development
    Replies: 5
    Last Post: 19-01-2010, 10:06 AM
  2. 24 frames per second
    By Ximen in forum Monitor & Video Cards
    Replies: 5
    Last Post: 24-02-2009, 02:41 PM
  3. Frames per Second FPS
    By Renderman21 in forum Software Development
    Replies: 3
    Last Post: 23-02-2009, 03:43 PM
  4. FPS (frames per second)
    By Theophilus in forum Overclocking & Computer Modification
    Replies: 1
    Last Post: 27-10-2008, 03:37 PM
  5. After the frames?
    By Rixwel in forum Software Development
    Replies: 5
    Last Post: 15-09-2008, 07:23 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,536,763.17011 seconds with 16 queries