tags:

views:

519

answers:

3

I am trying to change title bar color.but it dosen't work
UIManager.put("JFrame.activeCaption", new javax.swing.plaf.ColorUIResource( Color.GREEN)); JFrame.setDefaultLookAndFeelDecorated(true);

+3  A: 

I do not think that you can do anything about the colors in the title bar of a JFrame, at least not without using native code to implement a platform-specific solution. That is because JFrame actually uses your native windowing system to create the window.

As for internal frames, it would make sense for you to be able to customize it, since it is a component rendered inside of a window that is controlled by Java. Indeed, there are plenty of JInternalFrame properties that you can set in your UI manager. However, I wasn't able to get those to work on my system.

Doing a little googling, it appears that others have found that you cannot change the appearance of JInternalFrame without changing your whole system's look and feel settings. So, I'm afraid that you might have to depend on the operating system to control the colors of your title bars even when using internal frames.

Joe Carnahan
I think you have just about have _exactly_ described the spirit and intent behind the scope of JFrame and JInternalFrame. As JFrame and AWTs Frame classes are more or less the "Interface" between the Java's GUI layer and the OS GUI Layer. The only place that I think that this scoping is a bit "blurred" is of coarse by JFrame as it has some controls that probably are actually handled at the OS GUI layer--I seem to remember in the early days of Swing that some of the parameters seemed to be "suggestions" to the OS GUI layer as they Sun tried to decide how to position Swing in regards to the OS.
Wintermute
A: 

it is possible by doing your own look and feel: look at this

I don't know exactly how to do it, but maybe this full example can help

Hector
+1  A: 

OK I think Joe said it best, but remember you can decide not to decorate the Frame and then within the frame provide the ability to decorate it yourself. I have a Skin like set of custom AWT containers that do just that. The result is a GUI that looks or behaves nothing like what a Typical frame does--not "Rectangular" or "Square" "real estate" but something more like the Skins of applications like Winamp that cause the shape of the GUI to be asymmetric in design and look by by using the Alpha level in the OS GUI layer. In my Skin-able containers the "Skin" is an Image that is "cookie cut" up of a single image and then based on the geometry of Skin class draw and maintain those described areas--I only mention this as a way to literally "think outside of the box" of the type of problem.

WM

Wintermute
Looking again at Joe's answer, I think it is import--as over the years swing has obscured this--to remember that how a Java GUI interacts with an OS platform and renderer to user is ultimately determined by the Native Peer that is the Crux of the AWT. Forgive me older Java Gurus from pointing this out, but I think there is a large and growing group of Java programmers that do not really understand the AWT or even Java as a whole that leads to this: read about "heavy weight components" vs "light weight components" if curious :) and a lot will become clear.
Wintermute