2

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.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Subhash Chandran
  • 1,275
  • 1
  • 13
  • 20

2 Answers2

3

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

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Your example is running fine for me too. But when I run my [RESTClient tool](http://code.fosshub.com/WizToolsorg-RESTClient/downloads), this is not the case. Yes, I do [use pack()](https://github.com/wiztools/rest-client/blob/master/restclient-ui/src/main/java/org/wiztools/restclient/ui/RESTMain.java) as mentioned by you. – Subhash Chandran Mar 07 '14 at 13:43
  • Also verify that you are constructing the GUI on the [event dispatch thread](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html); some APIs have [changed](http://stackoverflow.com/a/15979112/230513). – trashgod Mar 07 '14 at 16:53
  • Found the issue. I use this before initializing the Swing UI: `javax.swing.UIManager.put (key, f);` with custom Font `f`. If I comment out this code, this tab-corruption does not happen. – Subhash Chandran Jun 15 '14 at 00:01
  • This seems plausible. You can update your question or [answer your own question](http://meta.stackoverflow.com/q/17463/163188). – trashgod Jun 15 '14 at 00:05
0

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.

Subhash Chandran
  • 1,275
  • 1
  • 13
  • 20