Metal Look & Feel on a Mac
When I run my app on a Mac, the look and feel is not Metal.
How can I prevent this?
do this at the start of application.
[email protected]
try {
UIManager.setLookAndFeel("com.sun.java.swing.mac.MacLookAndFeel");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFellClassName
} catch(Exception e) {
System.out.println("Error setting Motif LAF: " + e);
}
Similar Messages
-
Rendered Nodes in JTree, Look&Feel Problem
Hallo,
I make a small JTree and write my own TreeNodeRenderer which renders in each case a simple JPanel with Titled-Border an 2 JLabels.
If I adjust Metal Look&Feel the rendered Nodes are displayed correctly. (The JPanels size is about 300x200 pixels)
With other L&Fs (windows, motif, plastic from jgoodies) there is only the title of the TitledBorder displayed.
I meet the Problem as i programmed a more complicated JTree with rendered TreeNodes.
Do you know the problem and a solution? I don't want to setting up Metal look for my application.
The following link contains the source of the example in an executable jar file:
http://home.arcor.de/Thomas-Pfaff/treetest.jar
thanks for all answersI found the answer of my question....
http://onesearch.sun.com/search/clickthru?qt=TreeCellRenderer&url=http%3A%2F%2Fbugs.sun.com%2Fbugdatabase%2Fview_bug.do%3Fbug_id%3D4656280&pathInfo=%2Fonesearch%2Findex.jsp&hitNum=1&col=support-all -
I have a static initializer in my Applet:
public class ObjectEditApplet extends JApplet implements ActionListener {
static {
try {
UIManager.setLookAndFeel (UIManager.getSystemLookAndFeelClassName());
}catch(Exception e) {
Do something...
It shows all the Applet contents with Windows Look&Feel the first time. Next time the Applet is loaded it has Metal Look&Feel. I have seen that many have had the same problem but none of the simple solutions suggested have worked for me. Putting the code in the Applet constructor makes at least some panels show up with the right Look& Feel.
What am I supposed to do? Thanks in advance for any hints!
MagnusHello!
I think this is a known problem, try to put your "change look and feel" code in the start method of your applet, this may help.
If not, then try the following after setting up the look and feel:
SwingUtilities.updateComponentTree(this);
where "this" is your applet.
Good Luck
Taoufik -
JFileChooser problems in GTK look&feel
Hi,
the JFileChooser dialog is just ugly and not acceptable when using the GTK look&feel, there are so many layout problems and display errors. It also does not look like the native dialog. I'm using Ubuntu Linux 7.10 and Gnome 2.20.
My application uses the GTK look&feel, because most of the normal widgets look nice. Is there a way to use the same JFileChooser dialog layout as it is in the Metal look&feel when using the GTK look&feel? This would be an acceptable workaround...
Thanks,
StefanI don't believe it will be supported under any platform but *nix platforms. The GTKLookAndFeel currently requires native theme information which is not available on the Windows platform.
-
Can i use Mac Look&Feel in java app under Windows.
Thanksi saw it mentioned on here once. i believe you just have to set your own os in the system preferences to mac. or mac OS or something like that.
run sys.pref on a mac, get the os, then set that variable to that value in the windows machine. i believe that is all that is stopping you.
i haven't done it, but i remember reading it on here. -
I am trying to get the metal look and feel which was the default look and feel from 1.4. I used the following code.
try
UIManager.setLookAndFeel(new MetalLookAndFeel());
SwingUtilities.updateComponentTreeUI(this);
catch (Exception e) {System.out.println("Exception");}
but I am still getting the ocean look and feel.Ocean is the new default theme for Metal. Use
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme()) -
Look & Feel, in JComboBox
How would I allow the user to choose his preferred Look & Feel from a JComboBox, and make him press an 'OK button' to confirm his choice? I've tried some stuff, but I can't get it to work... ANY code would be extremely helpful, and I would be grateful for any suggestions.
Hi,
Create a String to hold the names of the different look n feels
//create String to hold names of the different Look and feels
String[ ] LAFNames = new String[ ] {"System Default", "Windows", "Java", "Mac OS", "Motif"};
//String to hold users selection
String storeLAFChoice;
//or can use int
int storeLAFSelection;
//Actual JComboBox
JComboBox LAFCB;
//in your constructor initialise the JCB
LAFCB = new JComboBox(LAFNames);
LAFCB.setSelectedIndex(0);
LAFCB.setMaximumRowCount(5);
//create your frame/window
//within your frame/window
//storeLAFChoice =LAFCB.getSelectedItem().toString();
//can use above with something like
// if( storeLAFChoice.equals("Motif") ) { do motif Look n Feel }...
storeLAFSelection = LAFCB.getSelectedItemIndex();
switch(storeLAFSelection)
//if sys def has been chosen
case 0: try{ UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName() );
SwingUtilities.updateComponentTreeUI(the name of your main panel /frame here);
}//ends try
catch(Exception ex) { }
//if windows chosen
case 1: try{ UIManager.setLookAndFeel
("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
SwingUtilities.updateComponentTreeUI(your main panel here);
}//ends try
catch(Exception ex) { //set to system default Look n feel }
case n ....
//for java:
...("javax.swing.plaf.metal.MetalLookAndFeel");...
//for Mac OS
...("javax.swing.plaf.mac.MacLookAndFeel");...
//for Motif
...("com.sun.java.swing.plaf.motif.MotifLookAndFeel");...
}//ends switch
...I know this is very much a bits and pieces implementation, but good luck,
Has. -
I have my Mac Book Pro with the OS Yesomite since a month and I am feeling that my mac is getting slower than before a month. I want to install OS Lion on my mac. I think i have a DVD of OS Lion which comes when i bougnt Mac laptop in 2011. Should i install OS Lion? What wil happen if i install OS Lion, do i lost my Applications or ...????
Hi, the last install dvd that came out for mac's was Snow Leopard,10.6.3. Lion is a download from apple. You cannot just install it over Yosemite. You would have to backup your drive to save files you want and do a clean install. You might want to look into getting more memory. You can run 8 Gig"s of memory on your Macbook Pro.If your Macbook Pro is getting really slow you might want to download EtreCheck and then post the results here.http://www.etresoft.com/etrecheck Check out this article. http://support.apple.com/kb/PH19031
-
Getting incorrect JComboBox color through UIManager in Nimbus Look&Feel
Hello all,
As I implementing a multi columns JComboBox, I need to provide my own custom ListCellRenderer.
* @author yccheok
public class ResultSetCellRenderer extends javax.swing.JPanel implements ListCellRenderer {
// Do not use static, so that our on-the-fly look n feel change will work.
private final Color cfc = UIManager.getColor("ComboBox.foreground");
private final Color cbc = UIManager.getColor("ComboBox.background");
private final Color csfc = UIManager.getColor("ComboBox.selectionForeground");
private final Color csbc = UIManager.getColor("ComboBox.selectionBackground");
private final Color cdfc = UIManager.getColor("ComboBox.disabledForeground");
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
System.out.println("UIManager.getColor(ComboBox.selectionForeground) = " + UIManager.getColor("ComboBox.selectionForeground"));
System.out.println("UIManager.getColor(ComboBox.selectionBackground) = " + UIManager.getColor("ComboBox.selectionBackground"));
this.setBackground(isSelected ? csbc : cbc);
this.setForeground(isSelected ? csfc : cfc);
jLabel1.setBackground(isSelected ? csbc : cbc);
jLabel1.setForeground(isSelected ? csfc : cfc);
jLabel2.setBackground(isSelected ? csbc : cbc);
jLabel2.setForeground(isSelected ? csfc : cfc);
jLabel3.setBackground(isSelected ? csbc : cbc);
jLabel3.setForeground(cdfc);
final ResultType result = (ResultType)value;
jLabel1.setText(result.symbol);
jLabel2.setText(result.name);
final String type = result.typeDisp != null ? result.typeDisp : result.type;
final String exch = result.exchDisp != null ? result.exchDisp : result.exch;
jLabel3.setText(type + " - " + exch);
return this;
}I try to get the selection colors of JComboBox through UIManager.
private final Color csfc = UIManager.getColor("ComboBox.selectionForeground");
private final Color csbc = UIManager.getColor("ComboBox.selectionBackground");However, I realize that while I am in Nimbus Look & Feel, the above 2 return me null.
May I know is there any workaround to overcome this? Or I had missed out something?
Thanks.
Edited by: yccheok on Oct 21, 2010 10:39 AMbecause "c" is instance of UIResource:
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.*;
public class NimbusComponentColorTest {
public JComponent makeUI() {
final Color c = UIManager.getColor(
"ComboBox:\"ComboBox.renderer\"[Selected].background");
System.out.format("c instanceof UIResource: %s", c instanceof UIResource);
JLabel label01 = new JLabel("label01");
/* //com/sun/java/swing/plaf/nimbus/AbstractRegionPainter.java
protected final Color getComponentColor(...) {
// we return the defaultColor if the color found is null, or if
// it is a UIResource. This is done because the color for the
// ENABLED state is set on the component, but you don't want to use
// that color for the over state. So we only respect the color
// specified for the property if it was set by the user, as opposed
// to set by us.
if (color == null || color instanceof UIResource) {
return defaultColor;
} else if(saturationOffset!=0||brightnessOffset!=0||alphaOffset!=0) {
label01.setOpaque(true);
label01.setBackground(c);
JLabel label02 = new JLabel("label02");
label02.setOpaque(true);
label02.setUI(new javax.swing.plaf.metal.MetalLabelUI());
label02.setBackground(c);
JLabel label03 = new JLabel("label03") {
@Override public void paintComponent(Graphics g) {
g.setColor(c);
g.fillRect(0,0,getWidth(),getHeight());
super.paintComponent(g);
JLabel label04 = new JLabel("label04");
label04.setOpaque(true);
label04.setBackground(new ColorUIResource(Color.RED));
JPanel p = new JPanel();
p.add(label01); p.add(label02); p.add(label03); p.add(label04);
return p;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override public void run() { createAndShowGUI(); }
public static void createAndShowGUI() {
try {
for (UIManager.LookAndFeelInfo laf:UIManager.getInstalledLookAndFeels())
if ("Nimbus".equals(laf.getName()))
UIManager.setLookAndFeel(laf.getClassName());
} catch (Exception e) {
e.printStackTrace();
JFrame f = new JFrame();
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.getContentPane().add(new NimbusComponentColorTest().makeUI());
f.setSize(200, 100);
f.setLocationRelativeTo(null);
f.setVisible(true);
} -
GUI screwed up sometimes with Custom Look & Feel
Hello,
i've got a few problems with my JApplet. Im using a custom Look and Feel (Kunststoff, http://www.incors.org/index.php3 very nice) - my problem is that sometimes (often) my gui is screwed up - some parts like a JPane are not rendered in the custom look & feel, they are still default, but the buttons are. Or my whole dialog looks like a little puzzle - small pieces are cut out.
I have no idea how to avoid these bugs, im not certain that this is because of the custom look and feel because i seem to have the same problems with the metal look and feel from java.
I tryed to put a repaint() in my initiliaze of my dialog classes at the very end, but no success either...
Any help would be greatly appreciated.Hello,
i've got a few problems with my JApplet. Im using a custom Look and Feel (Kunststoff, http://www.incors.org/index.php3 very nice) - my problem is that sometimes (often) my gui is screwed up - some parts like a JPane are not rendered in the custom look & feel, they are still default, but the buttons are. Or my whole dialog looks like a little puzzle - small pieces are cut out.
I have no idea how to avoid these bugs, im not certain that this is because of the custom look and feel because i seem to have the same problems with the metal look and feel from java.
I tryed to put a repaint() in my initiliaze of my dialog classes at the very end, but no success either...
Any help would be greatly appreciated. -
Can anyone tell me, where to download the MacOS Look & Feel calsses. Please give me the URL. And also tell me the full package name
thanksI've also read that Mac OS-X will not work on windows, because it has a lot of Mac-only native code in it, (whereas earlier Mac OS versions can be persuaded to work).
I've never tried any of this - just passing it along. Try doing a forum search - the question crops up repeatedly -
Look & Feel Being Ignored on Second launch of Applet...
Hi,
does anybody have a work around for this scenario, I click a hyper link to launch a web page which contains a business applet , the first time the applet executes the look and feel is being set correctly to the default system look and feel (i.e. windows on my test client) . If I exit the page containing the applet and click the hyper link again the metal look and feel is being used. I am setting the look and feel as follows,
static{
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }
catch (Exception e) {
e.printStackTrace();
I'm also using the latest version of the plugin. Any contributions would be greatly appreciated.Thanks sbelsly,
I'll check that out, if its a sucess i'll forward the dollars, (Pity it's not real cash eh?)....Salinte.. -
Keystroke action 'Enter' for Metal look
Hi
The keystroke actions are the same for Windows and Metal look, but nothing happens, if I activate in Metal look normal command buttons by 'Enter'. But it works with the Windows look and feel. Isn't it implemented yet or isn't it possible to activate the command buttons by 'Enter'?
Thanks very muchI think "enter" isn't a valid KeyEvent....
I allways use ActionEvents (ActionListener) when i wanna catch an "enter"
more easy to use and works fine...
i've tried and tried to get the key "enter" but it doesn't work...
SeJo
hope i helped... -
What happened to my Look & feel !!!
What happened to my Look & feel !!!
Hi,
Can someone help me !!!
I upgraded my JRE version from 1.3 to 1.4
I never explicitely specified any look and feel
As I am running my application with the 1.3 version, I've got one look& feel, and another with the 1.4 version ...
the problem is that the latest look & fell is ... say ... horrible ?
Can someone help me ?
Is there an instruction to write to come back to the older laf ?
thanks in advance !do I need to update my java.policy file, so that LAF could be changed?
the problem is that when I set Windows LAF with all permissions:
grant
permission java.security.AllPermission;
everything works fine, but when I use my own java.policy file, it gives me a Metal LAF.
is there a special Permission class for LAF?
thanks! -
Look&Feel setting partially effective in applet, why?
I have set the applet look&feel in method init() by doing this.
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeel());There are a JTree in a JScrollPane and some JButtons on the Applet.
But when browsed by IE, the tree is displayed in a Windows style, but the
buttons and outside the JScrollPane are all in a Metal style. Why this happens?
And how to solve it? Thanks.I have find many questions in the forum like mine, but they are not the same.
And I find that this kind of questions are very common, can anybody give a total
solution? Maybe everyone is tired of replying this. And is there any tech FAQs
in the forum?
Maybe you are looking for
-
Actually we have 10.5.8, 10.6.8 and 10.7.2 computers. All of them share this problem.
-
Add-ins that are being set to Inactive
This pertains to Outlook 2013 in this particular case, but may apply to other 2013 products. It's not just one add-in, but we have seen a few add-ins that go from a happy, Active add-in to a sad, unused Inactive add-in. If I have a user who's add-in
-
Possible to stream from FMLE to another (desktop)computer?
This is some kind of a challenge: I'm trying to find a sollution for streaming a video signal from one computer (preferably with FMLE) and pick up the video stream on another computer and show the video fullscreen. So far it seem to me that FMLE is o
-
Hi, for evry documents posted with this Account : "XXXXXX" i want to have specific code of VAT like : "Y1". so i want to force users to choose this VAT code when they post documents with "XXXXXX" (it is treasury account). please advise good points fo
-
Test stand crashes: "test stand has detected that your script debugging"
05-01-201203:18 PM Hi everyone. I am setting up a new installation of Test stand and writing my first sequence with an existing sequence of legacy code. When I run the sequence and stop on the call to the DLL, and then step into the dll and I get thi