Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I'm making a JDesktopPane based application, and I want to make it have a Windows 8 metro style UI feel to it, I'm too far in to the project to switch over to JavaFX, which I know has stylesheets for metro, so I was wondering if it's possible to customize Nimbus so that I can change the title bars to be a solid color. Thanks in advance!
Posted

1 solution

I solved it! and it's not too hard either, so to be nice to people searching for the same thing, this is a solution I found:

I looked at this site: http://www.jasperpotts.com/blog/2008/08/skinning-a-slider-with-nimbus/, which details how to customize a nimbus slider, then, after looking at Java's documents about Nimbus values, I found one called
InternalFrame[Enabled+WindowFocused].backgroundPainter
Which is the painter which draws the title bar, and window border + background, so I took the code from the slider article, and modified it slightly, and this is what I got:

UIManager.put("InternalFrame[Enabled+WindowFocused].backgroundPainter", new Painter<Object>() {
			@Override
			public void paint(Graphics2D g, Object c, int w, int h) {
				g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                g.setStroke(new BasicStroke(2f));
                g.setColor(Color.GRAY);
                g.fillRoundRect(0, 0, w-1, h-1, 8, 8);
                g.setColor(Color.WHITE);
                g.drawRoundRect(0, 0, w-1, h-1, 8, 8);
			}});
		
		UIManager.put("InternalFrame[Enabled].backgroundPainter", new Painter<Object>() {

			@Override
			public void paint(Graphics2D g, Object c, int w, int h) {
				g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                g.setStroke(new BasicStroke(2f));
                g.setColor(Color.RED);
                g.fillRoundRect(0, 0, w-1, h-1, 8, 8);
                g.setColor(Color.WHITE);
                g.drawRoundRect(0, 0, w-1, h-1, 8, 8);
			}});

All you need to do is paste this somewhere in your code, and you will get this result:

http://imgur.com/XuDGiHB
This is obviously very simple, but if you spend more time with it, you can make some amazing looking windows!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900