سؤال

This is how JTabbedPane renders in Java 1.6:

JTabbedPane rendered perfectly in Java 1.6

When using Java 1.7 (or 1.8 EA), see the bottom of the tabs getting clipped:

JTabbedPane rendered badly in Java 1.7 and 1.8

I tried, without any success (or effect) the system properties -Dcom.apple.macos.smallTabs=true and -Dcom.apple.smallTabs=true.

Any solution or hack for this is appreciated.

هل كانت مفيدة؟

المحلول 2

Found the issue. I had this code that was called before building the UI in SwingUtilities.invokeLater block:

import java.awt.Font;
import java.util.ArrayList;
import java.util.Enumeration;
import javax.swing.UIManager;

...

Font f = new Font(Font.DIALOG, Font.PLAIN, 12);
ArrayList<String> excludes = new ArrayList<String>();
Enumeration itr = UIManager.getDefaults().keys();
while(itr.hasMoreElements()){
    Object o = itr.nextElement();
    if(o instanceof String) {
        String key = (String) o;
        Object value = UIManager.get (key);
        if ((value instanceof javax.swing.plaf.FontUIResource)
                && (!excludes.contains(key))){
            UIManager.put (key, f);
        }
    }
}

I wanted all UI elements to have uniform Font in my application. When I commented this block, the UI rendering came up as in Java 6. Seems to be a bug in later Java releases.

نصائح أخرى

Running this example, I am unable to reproduce the effect shown on Mac OS X 10.9.2 using Java 7. I suspect you are neglecting to pack() the enclosing Window, but you might compare your code to the one shown for reference.

image

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top