001/* ---------------------------------------------------------------------------- 002 The Kiwi Toolkit - A Java Class Library 003 Copyright (C) 1998-2004 Mark A. Lindner 004 005 This library is free software; you can redistribute it and/or 006 modify it under the terms of the GNU General Public License as 007 published by the Free Software Foundation; either version 2 of the 008 License, or (at your option) any later version. 009 010 This library is distributed in the hope that it will be useful, 011 but WITHOUT ANY WARRANTY; without even the implied warranty of 012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 General Public License for more details. 014 015 You should have received a copy of the GNU General Public License 016 along with this library; if not, write to the Free Software 017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 018 02111-1307, USA. 019 020 The author may be contacted at: mark_a_lindner@yahoo.com 021 ---------------------------------------------------------------------------- 022 $Log: LookAndFeelChooser.java,v $ 023 Revision 1.4 2004/05/12 19:01:07 markl 024 comment block updates 025 026 Revision 1.3 2003/01/19 09:50:53 markl 027 Javadoc & comment header updates. 028 029 Revision 1.2 2001/03/12 09:27:57 markl 030 Source code and Javadoc cleanup. 031 032 Revision 1.1 1999/04/23 07:25:38 markl 033 Initial revision 034 ---------------------------------------------------------------------------- 035*/ 036 037package kiwi.ui; 038 039import java.awt.event.*; 040import javax.swing.*; 041 042/** This class represents a combo box for selecting a Look & Feel. It lists 043 * all L&Fs installed on the system. 044 * 045 * @see javax.swing.UIManager 046 * 047 * @author Mark Lindner 048 */ 049 050public class LookAndFeelChooser extends JComboBox 051 { 052 private boolean liveUpdate = false; 053 private String plafClasses[], plafNames[]; 054 055 /** Construct a new <code>LookAndFeelChooser</code>. 056 */ 057 058 public LookAndFeelChooser() 059 { 060 UIManager.LookAndFeelInfo plafs[] = UIManager.getInstalledLookAndFeels(); 061 062 for(int j = 0; j < plafs.length; ++j) 063 addItem(new UIManager.LookAndFeelInfo(plafs[j].getName(), 064 plafs[j].getClassName()) 065 { 066 public String toString() 067 { 068 return(getName()); 069 } 070 }); 071 072 String curplaf = UIManager.getLookAndFeel().getName(); 073 074 for(int i = 0; i < plafs.length; i++) 075 { 076 if(curplaf.equals(plafs[i].getName())) 077 { 078 setSelectedIndex(i); 079 break; 080 } 081 } 082 } 083 084 /** Get the currently selected Look & Feel. 085 * 086 * @return The <code>LookAndFeelInfo</code> object corresponding to the 087 * currently-selected L&F. 088 */ 089 090 public String getLookAndFeel() 091 { 092 return(((UIManager.LookAndFeelInfo)getSelectedItem()).getClassName()); 093 } 094 095 } 096 097/* end of source file */