java left logo
java middle logo
java right logo
 

Home arrow Java SE Tips
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4093
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to set up an internal frame in an application E-mail
User Rating: / 25
PoorBest 

This Java Swing tip illustrates quick demonstration of setting up an internal frame in an application. Developers may note that each internal frame comes up 30 pixels lower and to the right of the place where the previous internal frame first appeared. This functionality is implemented in the MyInternalFrame class, which is the custom subclass of JInternalFrame.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class SimpleInternalFrame extends Frame {
    
    JButton openButton, macButton, javaButton, motifButton, winButton;
    JLayeredPane desktop;
    JInternalFrame internalFrame;
    
    public SimpleInternalFrame() {

        super("Internal Frame Demo");
        setSize(500,400);
        openButton = new JButton("Open");
        macButton = new JButton("Mac");
        javaButton = new JButton("Metal");
        motifButton = new JButton("Motif");
        winButton = new JButton("Windows");
        Panel p = new Panel();
        p.add(openButton);
        p.add(macButton);
        p.add(javaButton);
        p.add(motifButton);
        p.add(winButton);
        add(p, BorderLayout.SOUTH);

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        openButton.addActionListener(new OpenListener());
        LnFListener lnf = new LnFListener(this);
        macButton.addActionListener(lnf);
        javaButton.addActionListener(lnf);
        motifButton.addActionListener(lnf);
        winButton.addActionListener(lnf);
        
        // Set up the layered pane
        desktop = new JDesktopPane();
        desktop.setOpaque(true);
        add(desktop, BorderLayout.CENTER);

    }
    
    // An inner class to handle presses of the Open button
    class OpenListener implements ActionListener {

        public void actionPerformed(ActionEvent e) {

            if ((internalFrame == null|| (internalFrame.isClosed())) {
                internalFrame = new JInternalFrame("Internal Frame",
                        true, true, true, true);
                internalFrame.setBounds(5050200100);
                desktop.add(internalFrame, new Integer(1));
                internalFrame.setVisible(true);
            }

        }
    }
    
    public static void main(String args[]) {

        SimpleInternalFrame sif = new SimpleInternalFrame();
        sif.setVisible(true);
    }
}


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.