-
Bug
-
Resolution: Fixed
-
P2
-
1.4.0
-
beta2
-
sparc
-
solaris_2.6
-
Verified
Name: nkR10003 Date: 06/08/2001
UIManger can't return defaults(color, font, etc.) correctly for UI delegate
when different L&F is installed. For example, one can't display Metal tabbed pane
on Windows JFrame when Windows L&F is installed. Sometimes we can't even
instantiate some metal classes when different L&F is installed, for example,
MetalInternalFrameTitlePane on Apple Aqua L&F.
If this is correct behavior (one should not display(instantiate) components from
different L&F this way, or should use any workaround), this should be documented
(for example, in JavaDoc for JComponent.setUI method).
Example below demonstrates this problem:
------------------example--------------------
import javax.swing.*;
import com.sun.java.swing.plaf.windows.*;
import javax.swing.plaf.metal.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.plaf.*;
public class test {
public static void main(String[] args) {
JFrame frame = new JFrame("Metal Tab pane on Windows L&F");
//make tab
//////////
JTabbedPane mtabbedPane = new JTabbedPane();
JPanel panel = new JPanel(false);
JLabel filler = new JLabel("Metal");
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
mtabbedPane.addTab("Metal", panel);
frame.getContentPane().setLayout(new GridLayout(1, 1));
frame.getContentPane().add(mtabbedPane, BorderLayout.CENTER);
//Install Windows L&F
/////////
WindowsLookAndFeel wlnf = new WindowsLookAndFeel();
try {
UIManager.setLookAndFeel(wlnf);
} catch (UnsupportedLookAndFeelException ulnfe) {
ulnfe.printStackTrace();
}
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
//set Metal UI
//////////
MetalTabbedPaneUI ui = new MetalTabbedPaneUI();
mtabbedPane.setUI(ui);
frame.setSize(400, 125);
frame.setVisible(true);
}
}
---------------------------------------------
======================================================================