JPanel background color as a resource property [message #884190] |
Sun, 10 June 2012 11:15  |
Eclipse User |
|
|
|
I was wondering if there was a way where I can set up the background color for my jpanel to a property defined in my properties file. I can do this by directly modifying the code, but the problem is that when viewing the frame in design mode the panel is black. And if i do the same for all components in the frame the entire screen is black and I really can't see how the design is coming along unless I actually run the application.
I hope my issue is clear enough, and that there is a easy solution for this. Netbeans allows you to set up the properties like colors, fonts as a resource.
Thanks
|
|
|
|
Re: JPanel background color as a resource property [message #884288 is a reply to message #884265] |
Sun, 10 June 2012 18:27   |
Eclipse User |
|
|
|
This the code that is generated by netbeans when I select "Define as resource" for the background color.
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(appView.class);
mainPanel.setBackground(resourceMap.getColor("mainPanel.background"));
The entry in the properties file for this resource is
mainPanel.background=204, 0, 0
In eclipse my code for the background that I have manually added
mainPanel.setBackground(new Color(Integer.parseInt(viewProperties.getProperty("global.color"), 16)));
Here the entry in the properties file is
global.color=577996
I hope this makes the issue a little clearer.
Thanks
|
|
|
Re: JPanel background color as a resource property [message #884974 is a reply to message #884288] |
Tue, 12 June 2012 07:52  |
Eclipse User |
|
|
|
Hi, any ideas on how I can get around this problem?
For now i have created a class that has all the properties defined as static strings. This way i can see the changes to the interface at design time. Although, I'd much rather have these in the properties file.
Thanks.
|
|
|
Powered by
FUDForum. Page generated in 0.03433 seconds