A quick demonstration of setting up an internal frame in an application : InternalFrame « Swing JFC « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » Swing JFC » InternalFrameScreenshots 
A quick demonstration of setting up an internal frame in an application
A quick demonstration of setting up an internal frame in an application
 
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class SimpleInternalFrameDemo extends Frame {

  JButton openButton, macButton, javaButton, motifButton, winButton;

  JLayeredPane desktop;

  JInternalFrame internalFrame;

  public SimpleInternalFrameDemo() {
    super("Internal Frame Demo");
    setSize(500400);
    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[]) {
    SimpleInternalFrameDemo sif = new SimpleInternalFrameDemo();
    sif.setVisible(true);
  }
}

class LnFListener implements ActionListener {
  Frame frame;

  public LnFListener(Frame f) {
    frame = f;
  }

  public void actionPerformed(ActionEvent e) {
    String lnfName = null;
    if (e.getActionCommand().equals("Mac")) {
      lnfName = "com.apple.mrj.swing.MacLookAndFeel";
    else if (e.getActionCommand().equals("Metal")) {
      lnfName = "javax.swing.plaf.metal.MetalLookAndFeel";
    else if (e.getActionCommand().equals("Motif")) {
      lnfName = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
    else if (e.getActionCommand().equals("Windows")) {
      lnfName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
    else {
      System.err.println("Unrecognized L&F request action: " + e.getActionCommand());
      return;
    }
    try {
      UIManager.setLookAndFeel(lnfName);
      SwingUtilities.updateComponentTreeUI(frame);
    catch (UnsupportedLookAndFeelException ex1) {
      System.err.println("Unsupported LookAndFeel: " + lnfName);
    catch (ClassNotFoundException ex2) {
      System.err.println("LookAndFeel class not found: " + lnfName);
    catch (InstantiationException ex3) {
      System.err.println("Could not load LookAndFeel: " + lnfName);
    catch (IllegalAccessException ex4) {
      System.err.println("Cannot use LookAndFeel: " + lnfName);
    }
  }
}

           
         
  
Related examples in the same category
1. A simple extension of the JInternalFrame class that contains a list
2. JDesktopPane demoJDesktopPane demo
3. Working with Internal Frames within a Desktop
4. Internal Frames DemoInternal Frames Demo
5. InternalFrame TestInternalFrame Test
6. JDesktopPane Cascade DemoJDesktopPane Cascade Demo
7. Java X WindowsJava X Windows
8. Desktop Manager DemoDesktop Manager Demo
9. Internal Frame Listener Demo Internal Frame Listener Demo
10. Layered Pane DemoLayered Pane Demo
11. LayeredPane Demo 2: Custom MDILayeredPane Demo 2: Custom MDI
12. LayeredPane Demo 3: Custom MDILayeredPane Demo 3: Custom MDI
13. LayeredPane Demo 4: Custom MDILayeredPane Demo 4: Custom MDI
14. Implements InternalFrameListenerImplements InternalFrameListener
15. InternalFrame demoInternalFrame demo
16. InternalFrameEvent DemoInternalFrameEvent Demo
17. A few interesting things using JInternalFrames, JDesktopPane, and DesktopManagerA few interesting things using JInternalFrames, JDesktopPane, and DesktopManager
18. A quick setting up an Internal Frame in an applicationA quick setting up an Internal Frame in an application
19. Interesting things using JInternalFrames, JDesktopPane, and DesktopManager 2Interesting things using JInternalFrames, JDesktopPane, and DesktopManager 2
20. Make a JInternalFrame a tool window
21. Move JInternalFrame To Front
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.