NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Topcomponent color change
Goto page 1, 2  Next
 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users
View previous topic :: View next topic  
Author Message
nani_chinni



Joined: 21 Jan 2010
Posts: 20

PostPosted: Mon Oct 11, 2010 12:50 pm    Post subject: Topcomponent color change Reply with quote

Hi,

I want to change back ground color of top component window, button and output window.

I used setBackground(color);

But its not coming in complete button. Its coming like border for button and top component window color is not changed.

If anybody knows, please let me know.



Thanks,
Chinni
Back to top
Edvin Syse
Posted via mailing list.





PostPosted: Mon Oct 11, 2010 12:56 pm    Post subject: [platform-dev] Re: Topcomponent color change Reply with quote

Hi Chinni,

These values come from the UIManager, so I believe the
easiest way to change this is to update the pertinent settings via
UIManager.put.

-- Edvin

On 11.10.2010 12:50, nani_chinni wrote:
Quote:
Hi,

I want to change back ground color of top component window, button and output window.

I used setBackground(color);

But its not coming in complete button. Its coming like border for button and top component window color is not changed.

If anybody knows, please let me know.



Thanks,
Chinni





--
Edvin Syse
Back to top
Enrico Scantamburlo
Posted via mailing list.





PostPosted: Mon Oct 11, 2010 2:10 pm    Post subject: [platform-dev] Re: Topcomponent color change Reply with quote

Some time ago I had the same problem. In order to solve it, I added a JPanel to the TopComponent and changed its BackGround.

2010/10/11 Edvin Syse <address-removed ([email]address-removed[/email])>
Quote:
Hi Chinni,

These values come from the UIManager, so I believe the
easiest way to change this is to update the pertinent settings via
UIManager.put.

-- Edvin


On 11.10.2010 12:50, nani_chinni wrote:
Quote:
Hi,

I want to change back ground color of top component window, button and output window.

I used setBackground(color);

But its not coming in complete button. Its coming like border for button and top component window color is not changed.

If anybody knows, please let me know.



Thanks,
Chinni







--
Edvin Syse



--
Enrico Scantamburlo

"For people that try to compensate the lack of capacity with more effort, there is no limit to the things they cannot do"
Back to top
nani_chinni



Joined: 21 Jan 2010
Posts: 20

PostPosted: Tue Oct 12, 2010 6:58 am    Post subject: Reply with quote

Hi Enrico,

Actually i have added top component to jpanel and i am able to change color. But, if i close top component tab then the workspace color is remain old one.

I want to change workspace color also.

Please tell me that how to change workspace color?

Thanks,
Chinni
Back to top
bdschubert



Joined: 01 Oct 2009
Posts: 66
Location: Ventura, CA

PostPosted: Tue Oct 12, 2010 10:20 am    Post subject: Reply with quote

Hi Channi,

I wonder if themes will provide the answer you are looking for. See this article by Geertjan: http://netbeans.dzone.com/netbeans-platform-themes. The internal link referred to within the article is broken, but I salvaged a copy of it from a google cache and posted it below:

NetBeans and Themes
Builds newer than NetBeans 3.4 release include an improved XML based theming mechanism. If you are running NetBeans using the Java look and feel, you can use XML to control almost any aspect of the look and feel.

Theme support builds on the support for theme classes in the Java Look and Feel, by allowing your theme to be defined in XML. But it goes further than that. Swing uses string-names and a map to define a lot of things in more detail than themes cover, via the class UIDefaults.

NetBeans' theme support allows you to redefine all properties of MetalTheme, but additionally, it allows you to replace any object in UIDefaults. NetBeans' theme support allows you to define the following types of objects:
Quote:
Colors, Metric (integer), String, Font, Boolean, Dimension, Inset, Border

all of which types live in UIDefaults.

Using theme support with non-Metal look and feels
Starting with NetBeans 3.6, there is experimental support for using themes with look and feels other than Metal. Some things will work, some won't, depending on what keys and values the look and feel in question actually uses out of UIDefaults. To enable it on non-Metal look and feels, add the following to your ide.cfg (or start netbeans from the command line with this argument):

Code:
-J-Dnetbeans.useTheme=true


How to use themes
Create a file following the instructions below called themes.xml and put it in the system/ subdirectory of your user directory (for example, $HOME/.netbeans/dev/system/.

Mix and match themes
NetBeans allows you to define more than one theme in your theme file. The first line in the file (after the obligatory <?xml version="1.0" encoding="UTF-8" ?>) should define the themeset. A themeset is a collection of themes (you'll really never need more than one):

Quote:
<themeset active="Tan,SmallScrollBars,LargerFonts">


Notice the "active" attribute. It is a list of references to themes that can be found inside the themeset tags. Different themes can be turned on and off by editing this line, so you can create separate themes for different aspects of the environment, such as sizes of scrollbars, sizes of fonts, and so forth, and apply different combinations of them for different environments.

Note:If two themes override the same value, whichever one occurs later in the file will be kept and the other discarded.

NetBeans-specific UIManager keys
NetBeans defines some keys of its own which are used in UIDefaults, and may be customized.

Structure of a theme
Each entry starts by saying what it is, such as <color key="primary1" r="170" g="144" b="119"/>

Each entry has an attribute called "key". This should be an exact match to either one of the properties of MetalTheme (e.g. primary1 - don't capitalize the first letter!) or an arbitrary string used in UIDefaults. If you specify a string that doesn't exist in UIDefaults, it simply create an object in UIDefaults that nothing uses and map it to that string.

Warning: Use the right classes for things (see table below). If you supply a font resource where there should be a color resource, NetBeans will probably not run. Fortunately, the format is simple.

The rest of the attributes are specific to what type of entry it is. For example, a color will have r, g and b attributes for the red, green and blue values of the color.

Example theme file
Code:
<theme name="Tan">
    <!--below are properties defined in MetalTheme-->
  <color key="primary1" r="170" g="144" b="119"/>
  <color key="primary2" r="190" g="170" b="140"/>
  <color key="primary3" r="250" g="240" b="210"/>
  <color key="secondary1" r="198" g="183" b="157"/>
  <color key="secondary2" r="180" g="162" b="145"/>
  <color key="secondary3" r="240" g="218" b="190"/>
  <color key="black" r="10" g="10" b="60"/> 
  <color key="white" r="231" g="207" b="181"/>
  <color key="window" r="231" g="207" b="181"/>
  <color key="controlText" r="190" g="170" b="140"/>
  <color key="info" r="190" g="170" b="140"/>
  <color key="controlDkShadow" r="190" g="170" b="140"/>

    <!--these are some specific colors stored in UIDefaults-->
  <color key="ScrollBar.darkShadow" r="190" g="170" b="140"/>
  <color key="MenuItem.acceleratorForeground" r="130" g="100" b="35"/>
  <color key="Menu.acceleratorForeground" r="130" g="100" b="35"/>
  <color key="Menu.selectionBackground" r="240" g="218" b="190"/>
 </theme>

 <theme name="SmallScrollBars">
  <metric key="ScrollBar.width" value="12"/>
 </theme>

<theme name="SmallTabs">
    <metric key="TabbedPane.textIconGap" value="2"/>
    <insets key="TabbedPane.tabInsets" top="0" bottom="1" left="3" right="1"/>
</theme>

 <theme name="LargerFonts">
    <!--below are properties defined in MetalTheme-->
  <font key="systemfont" name="Dialog" style="Plain" size="12"/>
  <font key="userFont" name="Dialog" style="Plain" size="12"/>
  <font key="subFont" name="Dialog" style="Plain" size="12"/>
  <font key="menuFont" name="SansSerif" style="Plain" size="12"/>
  <font key="windowTitleFont" name="SansSerif" style="Plain" size="12"/>
  <font key="controlFont" name="SansSerif" style="Plain" size="12"/>

    <!--these are some specific fonts stored in UIDefaults-->
  <font key="List.font" name="SansSerif" style="Plain" size="12"/>
  <font key="Tree.font" name="SansSerif" style="Plain" size="12"/>
  <font key="Panel.font" name="SansSerif" style="Plain" size="12"/>
 </theme>


Things you can change in UIDefaults
Below is a list of the attributes that you can set in UIDefaults using Themes. These attributes are taken from the defaults in MetalLookAndFeel, and may vary for other look and feels. It is always up to the Look and Feel implementation to use or not use the contents of UIDefaults. Note that GTK/Synth look and feels tend not to use UIDefaults at all.

PS: I think the color key property you might be looking for is Desktop.background.
Back to top
bdschubert



Joined: 01 Oct 2009
Posts: 66
Location: Ventura, CA

PostPosted: Tue Oct 12, 2010 1:01 pm    Post subject: Reply with quote

Here's an example that changes the background color(s) for an RCP app to green. I arbitrarily called the theme "Desktop"

branding/core/core.jar/org/netbeans/core/startup/resources/themes.xml:
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<!--Multiple themes are allowed, specify which ones are active in comma delimited list-->
<themeset active="Desktop">
    <theme name="Desktop">
        <color key="Panel.background"   r="0" g="128" b="0" />
    </theme>
</themeset>


Suite's project.properties:
Code:
run.args.extra=-J-Dnetbeans.useTheme=true
Back to top
nani_chinni



Joined: 21 Jan 2010
Posts: 20

PostPosted: Wed Oct 13, 2010 5:25 am    Post subject: Reply with quote

Hi bdschubert,

Thanks for your reply. I am able to change the desktop or workspace color.

In the similar way, i want to change button background color , menu background color and window color etc.

How can i know that which key i need to use for which one in which theme like tan,desktop etc.

Please suggest me.

Thanks,
Chinni
Back to top
bdschubert



Joined: 01 Oct 2009
Posts: 66
Location: Ventura, CA

PostPosted: Wed Oct 13, 2010 11:57 am    Post subject: Reply with quote

Here's the link to the page with all of the keys: http://ui.netbeans.org/docs/ui/themes/themes.html.

Note: The link is weird. If I try to access the page later via a bookmark, I get a page not found from netbeans.org. Strange. So, you might want to save a copy of the page to your disk right away so you have a solid resource later.

Or, you can use this code block that I got from http://www.java2s.com/Tutorial/Java/0240__Swing/ListingUIDefaultProperties.htm. It will list all the UIDefaults keys and values.

Code:
import java.util.Enumeration;

import javax.swing.UIDefaults;
import javax.swing.UIManager;

public class ListProperties {
  public static void main(String args[]) throws Exception {
    UIManager.LookAndFeelInfo looks[] = UIManager.getInstalledLookAndFeels();

    for (UIManager.LookAndFeelInfo info : looks) {
      UIManager.setLookAndFeel(info.getClassName());

      UIDefaults defaults = UIManager.getDefaults();
      Enumeration newKeys = defaults.keys();

      while (newKeys.hasMoreElements()) {
        Object obj = newKeys.nextElement();
        System.out.printf("%50s : %s\n", obj, UIManager.get(obj));
      }
    }
  }
}
Back to top
registered



Joined: 13 Oct 2012
Posts: 24

PostPosted: Thu Nov 29, 2012 8:58 pm    Post subject: Reply with quote

where should i put this themes.xml file on windows 7 system with netbeans 7.2?
Back to top
Geertjan Wielenga
Posted via mailing list.





PostPosted: Thu Nov 29, 2012 10:29 pm    Post subject: [platform-dev] Re: Topcomponent color change Reply with quote

On 11/29/2012 09:58 PM, registered wrote:
Quote:
where should i put this themes.xml file on windows 7 system with netbeans 7.2?




http://netbeans.dzone.com/netbeans-platform-themes

Gj
Back to top
registered



Joined: 13 Oct 2012
Posts: 24

PostPosted: Fri Nov 30, 2012 6:33 am    Post subject: Re: [platform-dev] Re: Topcomponent color change Reply with quote

Geertjan Wielenga wrote:
http://netbeans.dzone.com/netbeans-platform-themes

he is talking about including theme into a program.
i am talking about theming netbeans itself.
so, i don`t have access to source code.
all i can - is modify netbeans.conf and append
Code:
 -J-Dnetbeans.useTheme=true
to
netbeans_default_options

but then i need either specify location of themes.xml with some setting or,
put this file in default location where netbeans will find it.
in this post it was told to put themes.xml in
Code:
$HOME/.netbeans/dev/system/

which, of course, doesn`t exists on windows 7
Back to top
Geertjan Wielenga
Posted via mailing list.





PostPosted: Fri Nov 30, 2012 11:49 am    Post subject: [platform-dev] Re: Topcomponent color change Reply with quote

On 11/30/2012 07:33 AM, registered wrote:
Quote:
Geertjan Wielenga wrote:
Quote:
http://netbeans.dzone.com/netbeans-platform-themes
he is talking about including theme into a program.
i am talking about theming netbeans itself.
so, i don`t have access to source code.
all i can - is modify netbeans.conf and append

Code:
-J-Dnetbeans.useTheme=true
to
netbeans_default_options


but then i need either specify location of themes.xml with some setting or,
put this file in default location where netbeans will find it.
in this post it was told to put themes.xml in
Code:
$HOME/.netbeans/dev/system/


which, of course, doesn`t exists on windows 7




So, create it.

Gj
Back to top
registered



Joined: 13 Oct 2012
Posts: 24

PostPosted: Fri Nov 30, 2012 12:35 pm    Post subject: Re: [platform-dev] Re: Topcomponent color change Reply with quote

Geertjan Wielenga wrote:
So, create it.

there is no
Code:
$HOME

system variable in windows.
so, i`ve tried to create
Code:
c:\users\username\.netbeans\dev\system\themes.xml

but it didn`t work out.
Back to top
registered



Joined: 13 Oct 2012
Posts: 24

PostPosted: Fri Nov 30, 2012 1:20 pm    Post subject: Reply with quote

neither it worked with
Code:
netbeans home:
C:\Program Files\NetBeans 7.2\platform\themes.xml
C:\Program Files\NetBeans 7.2\platform\system\themes.xml
netbeans user:
c:\Users\username\AppData\Roaming\NetBeans\7.2\themes.xml
c:\Users\username\AppData\Roaming\NetBeans\7.2\system\themes.xml
netbeans.default_userdir_root:
C:\Users\username\AppData\Roaming\NetBeans\themes.xml
C:\Users\username\AppData\Roaming\NetBeans\system\themes.xml
Back to top
Ernie Rael
Posted via mailing list.





PostPosted: Fri Nov 30, 2012 11:16 pm    Post subject: [platform-dev] Re: Topcomponent color change Reply with quote

The default location of "userdir" is specified in
<NB-install-dir>/etc/netbeans.conf (it can be changed with a netbeans
startup command line option).

-ernie

On 11/30/2012 4:35 AM, registered wrote:
Quote:
Geertjan Wielenga wrote:
Quote:
So, create it.
there is no

Code:
$HOME


system variable in windows.
so, i`ve tried to create

Code:
c:\users\username\.netbeans\dev\system\themes.xml


but it didn`t work out.





Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo