// ------------------- ShowUIDefaults.java -------------------------
/*******************************************************************
===========================================
Camickr's ShowUIDefaults Properties Viewer
===========================================
By Camickr
Source Contributions by
Dr. Lazlo Jamf,
Thomas Kellerer,
Brent Allen Parrish
Compiled on 14 May 2008
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
********************************************************************/
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.plaf.*;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.border.Border;
/**
* ShowUIDefaults class lists all of the various properties found in the
* javax.swing.UIDefaults LAF collection and presents the data in a
* javax.swing.JTable and categorized tabbed pane view. Provides support
* for common data transfer operations (i.e. copy/paste) and features
* four changeable LookAndFeels (LAF),
*
*
Java(TM) Metal
*
Windows XP
*
CDE/Motif
*
Windows Classic
*
*
* @param title java.lang.String sets the window titlebar string.
* @author camickr
*/
public class ShowUIDefaults extends JFrame implements ActionListener
{
JFrame frame;
JTabbedPane tabbedPane;
JButton metal;
JButton windows;
JButton motif;
JButton basic;
JButton classic;
JButton jamf;
SampleRenderer sampleRenderer;
/**
* Class constructor sets this window's titlebar string; sets up the tabbed
* pane layout; instantiates the javax.swing.JButton objects and
* sets this instance's javax.swing.JFrame member.
*
*/
public ShowUIDefaults(String title)
{
super(title);
frame = this;
getContentPane().setLayout( new BorderLayout() );
tabbedPane = getTabbedPane();
getContentPane().add( tabbedPane );
JPanel buttons = new JPanel();
buttons.setLayout( new GridLayout( 1, 5) );
getContentPane().add(buttons, BorderLayout.SOUTH);
metal = new JButton( "Metal" );
metal.addActionListener( this );
buttons.add(metal);
windows = new JButton( "Windows" );
windows.addActionListener( this );
buttons.add(windows);
motif = new JButton( "Motif" );
motif.addActionListener( this );
buttons.add(motif);
// Added classic LAF -Brent P.
classic = new JButton( "Windows Classic" );
classic.addActionListener( this );
buttons.add(classic);
jamf = new JButton( "Jamf's Listing" );
jamf.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
String[] args = {};
Listing.main(args);
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}
}
}); // End anonymous
buttons.add(jamf);
}
/**
* Handles events as specified by the java.awt.event.ActionListener
* interface.
*
* @param e java.awt.event.ActionEvent.
*/
public void actionPerformed(ActionEvent e)
{
String laf = "";
Object o = e.getSource();
if (o.equals(metal))
laf = "javax.swing.plaf.metal.MetalLookAndFeel";
else if (o.equals(windows))
laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
else if (o.equals(motif))
laf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
else if (o.equals(classic))
laf = "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel";
try
{
UIManager.setLookAndFeel(laf);
}
catch (Exception e2)
{
System.out.println(e2.getMessage());
e2.printStackTrace();
}
getContentPane().remove(tabbedPane);
tabbedPane = getTabbedPane();
getContentPane().add( tabbedPane );
SwingUtilities.updateComponentTreeUI(frame);
frame.pack();
}
/**
* Parses the javax.swing.UIDefaults collection and returns the tabbed
* pane view for this window.
*
* @return pane javax.swing.JTabbedPane of this instance's key/value pairs.
*/
private JTabbedPane getTabbedPane()
{
// Modified: Brent Allen Parrish
// Added: Generic type hinting for collection objects
Map