Demonstrate use of GlassPane : GlassPane « 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 » GlassPaneScreenshots 
Demonstrate use of GlassPane
Demonstrate use of GlassPane
 

import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/*
 * Demonstrate use of GlassPane in JWindow & friends. Buttons enable/disable it.
 * @author Eckstein et al, in the O'Reilly book "Java Swing"
 */
public class GlassExample {

  /** Construct a Splash screen with the given image */
  public static void main(String[] args) {
    JFrame f = new JFrame("GlassPane");

    final JPanel p1 = new JPanel();
    p1.add(new JLabel("GlassPane Example"));
    JButton show = new JButton("Show");
    p1.add(show);
    p1.add(new JButton("No-op"));
    f.getContentPane().add(p1);

    final JPanel glass = (JPanelf.getGlassPane();

    glass.setVisible(true);
    glass.setLayout(new GridBagLayout());
    JButton glassButton = new JButton("Hide");
    glass.add(glassButton);

    f.setSize(15080);
    f.setVisible(true);

    boolean debug = false;
    if (debug) {
      System.out.println("Button is " + glassButton);
      System.out.println("GlassPane is " + glass);
    }

    // Add actions to the buttons...

    // show button (re-)shows the glass pane.
    show.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        glass.setVisible(true);
        p1.repaint();
      }
    });
    // hide button hides the Glass Pane to show what's under.
    glassButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        glass.setVisible(false);
        p1.repaint();
      }
    });
  }

}




           
         
  
Related examples in the same category
1. Show how a glass pane can be used to block mouse (and key!) eventsShow how a glass pane can be used to block mouse (and key!) events
2. Paint on glass pane
3. Block mouse and key events in an application
4. Replace existing GlassPane
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.