How to change colour of jDesktopPane from properties

How to change colour of jDesktopPane from properties



I am creating a project that requires the use of multiple internal frames and interconnecting it through the desktop pane.



I have tried changing the colour of the desktop pane (from the property->background)but when I run it it's still that default Blue colour.



Check attached snapshot link maybe you will better understand my question what I want.



FRAME BLUE COLOUR:



https://i.stack.imgur.com/IzTNj.png



PROPERTY SET COLOUR:



https://i.stack.imgur.com/dVhoT.png





Im not exactly understanding for which part of your jdesktoppane you want to change the color
– Donatic
Aug 24 at 7:19





I have tried changing the colour of the desktop pane - where? Your code should be something like: JDesktopPane desktop = new JDesktop(); desktop.setBackground( Color.RED ); First get this working, then if you want to make it more dynamic use the JColorChooser. If you have problems then pPost your Minimal, Complete, and Verifiable example that demonstrates the problem because we can't guess what you are doing. Don't use the IDE to change the color. Learn how to write your own code to set properties of components so you learn Swing, not the IDE.
– camickr
Aug 24 at 13:59



I have tried changing the colour of the desktop pane


JDesktopPane desktop = new JDesktop(); desktop.setBackground( Color.RED );





@Donatic I'm kinda new to java so I'm trying not to use codes. the part I'm trying to change is the LIGHT BLUE COLOUR u can see in the pic. I want to set it to the purple colour I have used in the panel.
– Namita Geo.
Aug 26 at 8:44





@camirk I am kinda new to java.. so I know only the basic codes. I need to submit it by 28th so I'm trying not to use too much codes. "I have tried changing the colour of the desktop pane" - I meant that I tried through the properties as shown above. And how else am I supposed to show you the colour I'm choosing is not coming?
– Namita Geo.
Aug 26 at 8:49





1 Answer
1



It appears that you're using Nimbus L&F? Background color of JDesktopPane and other components are handled by the L&F. You can override the background as such:


desktop = new JDesktopPane()

@Override
public void updateUI()
if ("Nimbus".equals(UIManager.getLookAndFeel().getName()))
UIDefaults map = new UIDefaults();
Painter<JComponent> painter = new Painter<JComponent>()

@Override
public void paint(Graphics2D g, JComponent c, int w,
int h)
g.setColor(Color.white); //background color
g.fillRect(0, 0, w, h);

;
map.put("DesktopPane[Enabled].backgroundPainter", painter);
putClientProperty("Nimbus.Overrides", map);

super.updateUI();

;





,I have no idea what nimbus or L&F is. I'm using Java Netbeans 8.2. And can you tell me how to change background colour without any coding? (like through its properties.)
– Namita Geo.
Aug 26 at 8:52







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế