TabbedPane Test : TabbedPane « 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 » TabbedPaneScreenshots 
TabbedPane Test
TabbedPane Test

/**
 @version 1.00 1999-07-17
 @author Cay Horstmann
 */

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

public class SwingTabbedPaneTest {  
   public static void main(String[] args)
   {  JFrame frame = new TabbedPaneFrame();
      frame.show();
   }
}

class TabbedPaneFrame extends JFrame
   implements ChangeListener
{  public TabbedPaneFrame()
   {  setTitle("TabbedPaneTest");
      setSize(400300);
      addWindowListener(new WindowAdapter()
         {  public void windowClosing(WindowEvent e)
            {  System.exit(0);
            }
         } );

      tabbedPane = new JTabbedPane();
      tabbedPane.addChangeListener(this);

      /* we set the components to null and delay their
         loading until the tab is shown for the first time
      */

      ImageIcon icon = new ImageIcon("yellow-ball.gif");

      tabbedPane.addTab("Mercury", icon, null);
      tabbedPane.addTab("Venus", icon, null);
      tabbedPane.addTab("Earth", icon, null);
      tabbedPane.addTab("Mars", icon, null);
      tabbedPane.addTab("Jupiter", icon, null);
      tabbedPane.addTab("Saturn", icon, null);
      tabbedPane.addTab("Uranus", icon, null);
      tabbedPane.addTab("Neptune", icon, null);
      tabbedPane.addTab("Pluto", icon, null);

      getContentPane().add(tabbedPane, "Center");
   }

   public void stateChanged(ChangeEvent event)
   {  JTabbedPane pane = (JTabbedPane)event.getSource();

      // check if this tab still has a null component

      if (pane.getSelectedComponent() == null)
      {  // set the component to the image icon

         int n = pane.getSelectedIndex();
         String title = pane.getTitleAt(n);
         ImageIcon planetIcon = new ImageIcon(title + ".gif");
         pane.setComponentAt(n, new JLabel(planetIcon));

         // indicate that this tab has been visited--just for fun

         pane.setIconAt(n, new ImageIcon("red-ball.gif"));
      }
   }

   private JTabbedPane tabbedPane;
}
           
       
Related examples in the same category
1. Demonstrates the Tabbed PaneDemonstrates the Tabbed Pane
2. A demonstration of the tab wrapping property of JTabbedPaneA demonstration of the tab wrapping property of JTabbedPane
3. A quick test of the JTabbedPane componentA quick test of the JTabbedPane component
4. JTabbedPane class for displaying and manipulatingJTabbedPane class for displaying and manipulating
5. TabbedPane SampleTabbedPane Sample
6. TabbedPane Sample 2TabbedPane Sample 2
7. TabbedPane DemoTabbedPane Demo
8. Laying Out a Screen with JTabbedPaneLaying Out a Screen with JTabbedPane
9. TabPane DemoTabPane Demo
10. Determining When the Selected Tab Changes in a JTabbedPane Container
11. Enable Scrolling Tabs in a JTabbedPane Container
12. Enabling the Selection of a Tab in a JTabbedPane Container Using a Keystroke
13. Setting the Color of a Tab in a JTabbedPane Container
14. Setting the Tool Tip for a Tab in a JTabbedPane Container
15. Enabling and Disabling a Tab in a JTabbedPane Container
16. Setting the Location of the Tabs in a JTabbedPane Container
17. Getting the Tabs in a JTabbedPane Container
18. Retrieve the index of a tab when needed
19. Get the index of the first tab that matches an icon
20. Get the index of the tab by matching the child component
21. Moving a Tab in a JTabbedPane Container
22. Removing a Tab in a JTabbedPane Container
23. Add a tab with a label taken from the name of the component
24. Add a tab with a label at the end of all tabs
25. Add a tab with a label and icon at the end of all tabs
26. Add a tab with a label, icon, and tool tip at the end of all tabs
27. Insert a tab after the first tab
28. Getting and Setting the Selected Tab in a JTabbedPane Container
29. Creating a JTabbedPane Container
30. Setting the Size of the Divider in a JSplitPane Container
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.