-
Bug
-
Resolution: Fixed
-
P4
-
1.1.5, 1.2.0
-
1.2beta4
-
generic
-
generic
-
Not verified
Name: rk38400 Date: 05/14/98
The LookAndFeel names returned by
UIManager.LookAndFeelInfo.getName() and
UIManager.getLookAndFeel().getName() are different.
I would like to get a list of available LAF's and
select the default one from that list.
Code snippet:
private String[] getLAFNames() {
UIManager.LookAndFeelInfo[] lafInfos =
UIManager.getInstalledLookAndFeels();
String[] LAFNames = new String[lafInfos.length];
int i;
for( i = 0; i < lafInfos.length; i++ ){
LAFNames[i] = lafInfos[i].getName();
}
return( LAFNames );
}
private void addLAFRadioMenuAndSetLAF( JMenu menu ){
String[] lafNames = getLAFNames();
JRadioButtonMenuItem[] lafRadios;
ButtonGroup lafGroup = new ButtonGroup();
LookAndFeel defaultLAF = UIManager.getLookAndFeel();
String defaultLAFName = defaultLAF.getName();
if( defaultLAF == null ){
lafRadios = new JRadioButtonMenuItem[lafNames.length+1];
// Add Radio for the default selection
}else{
lafRadios = new JRadioButtonMenuItem[lafNames.length];
}
int i;
for( i = 0; i < lafNames.length; i++ ){
lafRadios[i] = new JRadioButtonMenuItem( lafNames[i] );
lafGroup.add( lafRadios[i] );
menu.add( lafRadios[i] );
// Great, it gives different names from
// UIManager.LookAndFeelInfo.getName() and
// UIManager.getLookAndFeel.getName(), can't do:
// if ( lafNames[i].equals(defaultLAFName)) lafRadios[i].setSelected(true);
System.out.println( "'"+lafNames[i]+"'" + " " + "'"+defaultLAFName+"'" );
}
}
Output using swing-1.0.1:
'Metal' 'Metal Look and Feel'
'CDE/Motif' 'Metal Look and Feel'
'Windows' 'Metal Look and Feel'
PS. This is my second bug report today. I am entitled
to a T-shirt now, right?
(Review ID: 26608)
======================================================================
- relates to
-
JDK-6482388 REGRESSION: LookAndFeel.getName() no longer matches LookAndFeelInfo.getName()
- Closed