Re: disabling/changing rollover effect on buttons
In article <4A00D7DE.9030500@yahoo.de>,
lester psigal <lesterpsigal@yahoo.de> wrote:
[...]
This is a little annoying as the method must be called for each
JMenuItem separately but is much better than go along with unresolved
issues...;-) maybe i'll find a more convenient method for calling an
updateUI() on a bulk of components.
Alternatively, I think you can invoke UIManager.put() before
instantiating any components. In this example, the JTree icons in the
native system L&F are replaced by those from the Metal L&F. (Of course,
they may be the same L&F.)
<code>
package gui;
import java.awt.Color;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.RenderingHints;
import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JTree;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.metal.MetalLookAndFeel;
public class JTreeTest {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
//@Override
public void run() {
createGUI();
}
});
}
private static void createGUI() {
final JFrame frame = new JFrame();
frame.setLayout(new GridLayout(1, 0));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
try {
LookAndFeel save = UIManager.getLookAndFeel();
LookAndFeel laf = new MetalLookAndFeel();
UIManager.setLookAndFeel(laf);
Icon collapsed = (Icon) UIManager.get("Tree.collapsedIcon");
Icon expanded = (Icon) UIManager.get("Tree.expandedIcon");
UIManager.setLookAndFeel(save);
UIManager.put("Tree.collapsedIcon", collapsed);
UIManager.put("Tree.expandedIcon", expanded);
} catch (UnsupportedLookAndFeelException ex) {
ex.printStackTrace(System.err);
}
frame.add(new JTree());
frame.add(new JTree());
frame.add(new JTree());
frame.pack();
frame.setSize(400, 300);
frame.setVisible(true);
}
}
</code>
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>