Setting background color to just the root node in a tree

How can I set a background color to just the root node in a tree? I got the node in the followig way in the renderer method.
IconNodeClass parentIconNode = (IconNodeClass)((IconNodeClass)value).getRoot();
Then how can I set the background for just the root node? Thanks.

You need to write ur own treeCellRenderer for that to be done

Similar Messages

  • How to get the root node of a tree?

    I wanna get all the leaf node of a tree.But JTree have no method about how to get the root TreeNode of a tree.Then how should I do?

    try this:
    http://javaalmanac.com/egs/javax.swing.tree/GetNodes.html?l=rel

  • Setting Background Color for a tree node

    I have the following code
    ====================================================================================
    public class IconNodeRendererClass extends DefaultTreeCellRenderer {
    //* getListCellRendererComponent
    /**Return a component renderer based on the passed in components*/
    public Component getTreeCellRendererComponent(JTree tree, Object value,
    boolean sel, boolean expanded, boolean leaf,
    int row, boolean hasFocus) {
    Component c = super.getTreeCellRendererComponent(tree, value,
    sel, expanded, leaf, row, hasFocus);
    ImageIcon icon = ((IconNodeClass)value).getIcon();
    if (((IconNodeClass)value).isRoot()) {
    c.setBackground(Color.blue);
    setIcon(null);
    return c;
    if (icon != null) {
    setIcon(icon);
    return this;
    }// end getTreeCellRendererComponent
    }// end IconNodeRendererClass
    ====================================================================================
    I would like to have a gray color to the root node before even I selected the root node.
    Can I do that by setting the background color?
    With the below code I am unable to set the background color to the root node even when I selected it. what else can i write to set the color to the root node?
    if (((IconNodeClass)value).isRoot()) {
    c.setBackground(Color.blue);
    setIcon(null);
    return c;

    I gave the following on your advice. But the background color is set to all the nodes. I want it to be set it to only the root node. How can I do that? Thanks.
    if (((IconNodeClass)value).isRoot()) {
    setOpaque(true);
    c.setBackground(Color.gray);
    updateUI();
    setIcon(null);
    }

  • Set background color to inside of the border in JPanel.

    Hi all,
    I want to set background color for JPanel with in the TitledBorder limit.
    Thanks in Advance.
    Siddhes.

    >
    I want to set background color for JPanel with in the TitledBorder limit.>Here is another approach..
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.border.*;
    class ColoredInnerPanel {
      public static void main(String[] args) {
        JPanel coloredPanel = new JPanel();
        coloredPanel.setBackground(Color.RED);
        coloredPanel.setPreferredSize( new Dimension(300,400) );
        JPanel outerPanel = new JPanel(new BorderLayout());
        outerPanel.add( coloredPanel );
        outerPanel.setBorder(new TitledBorder("I See Red"));
        JOptionPane.showMessageDialog(null, outerPanel);
    }

  • Set Background color for headers in excel

    DECLARE
       v_fh     UTL_FILE.file_type;
       v_dir    VARCHAR2 (30)      := 'my dir';
       v_file   VARCHAR2 (30)      := 'test.xls';
       PROCEDURE run_query (p_sql IN VARCHAR2)
       IS
          v_v_val   VARCHAR2 (4000);
          v_n_val   NUMBER;
          v_d_val   DATE;
          v_ret     NUMBER;
          c         NUMBER;
          d         NUMBER;
          col_cnt   INTEGER;
          f         BOOLEAN;
          rec_tab   DBMS_SQL.desc_tab;
          col_num   NUMBER;
       BEGIN
          c := DBMS_SQL.open_cursor;
          -- parse the SQL statement
          DBMS_SQL.parse (c, p_sql, DBMS_SQL.native);
          -- start execution of the SQL statement
          d := DBMS_SQL.EXECUTE (c);
          -- get a description of the returned columns
          DBMS_SQL.describe_columns (c, col_cnt, rec_tab);
          -- bind variables to columns
          FOR j IN 1 .. col_cnt
          LOOP
             CASE rec_tab (j).col_type
                WHEN 1
                THEN
                   DBMS_SQL.define_column (c, j, v_v_val, 4000);
                WHEN 2
                THEN
                   DBMS_SQL.define_column (c, j, v_n_val);
                WHEN 12
                THEN
                   DBMS_SQL.define_column (c, j, v_d_val);
                ELSE
                   DBMS_SQL.define_column (c, j, v_v_val, 4000);
             END CASE;
          END LOOP;
          -- Output the column headers
          UTL_FILE.put_line (v_fh, '<ss:Row>');
          FOR j IN 1 .. col_cnt
          LOOP
             UTL_FILE.put_line (v_fh, '<ss:Cell>');
             UTL_FILE.put_line (v_fh,
                                   '<ss:Data ss:Type="String">'
                                || rec_tab (j).col_name
                                || '</ss:Data>'
             UTL_FILE.put_line (v_fh, '</ss:Cell>');
          END LOOP;
          UTL_FILE.put_line (v_fh, '</ss:Row>');
          -- Output the data
          LOOP
             v_ret := DBMS_SQL.fetch_rows (c);
             EXIT WHEN v_ret = 0;
             UTL_FILE.put_line (v_fh, '<ss:Row>');
             FOR j IN 1 .. col_cnt
             LOOP
                CASE rec_tab (j).col_type
                   WHEN 1
                   THEN
                      DBMS_SQL.COLUMN_VALUE (c, j, v_v_val);
                      UTL_FILE.put_line (v_fh, '<ss:Cell>');
                      UTL_FILE.put_line (v_fh,
                                            '<ss:Data ss:Type="String">'
                                         || v_v_val
                                         || '</ss:Data>'
                      UTL_FILE.put_line (v_fh, '</ss:Cell>');
                   WHEN 2
                   THEN
                      DBMS_SQL.COLUMN_VALUE (c, j, v_n_val);
                      UTL_FILE.put_line (v_fh, '<ss:Cell>');
                      UTL_FILE.put_line (v_fh,
                                            '<ss:Data ss:Type="Number">'
                                         || TO_CHAR (v_n_val)
                                         || '</ss:Data>'
                      UTL_FILE.put_line (v_fh, '</ss:Cell>');
                   WHEN 12
                   THEN
                      DBMS_SQL.COLUMN_VALUE (c, j, v_d_val);
                      UTL_FILE.put_line (v_fh,
                                         '<ss:Cell ss:StyleID="OracleDate">'
                      UTL_FILE.put_line (v_fh,
                                            '<ss:Data ss:Type="DateTime">'
                                         || TO_CHAR (v_d_val,
                                                     'YYYY-MM-DD"T"HH24:MI:SS'
                                         || '</ss:Data>'
                      UTL_FILE.put_line (v_fh, '</ss:Cell>');
                   ELSE
                      DBMS_SQL.COLUMN_VALUE (c, j, v_v_val);
                      UTL_FILE.put_line (v_fh, '<ss:Cell>');
                      UTL_FILE.put_line (v_fh,
                                            '<ss:Data ss:Type="String">'
                                         || v_v_val
                                         || '</ss:Data>'
                      UTL_FILE.put_line (v_fh, '</ss:Cell>');
                END CASE;
             END LOOP;
             UTL_FILE.put_line (v_fh, '</ss:Row>');
          END LOOP;
          DBMS_SQL.close_cursor (c);
       END;
       PROCEDURE start_workbook
       IS
       BEGIN
          UTL_FILE.put_line (v_fh, '<?xml version="1.0"?>');
          UTL_FILE.put_line
             (v_fh,
              '<ss:Workbook xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">'
       END;
       PROCEDURE end_workbook
       IS
       BEGIN
          UTL_FILE.put_line (v_fh, '</ss:Workbook>');
       END;
       PROCEDURE start_worksheet (p_sheetname IN VARCHAR2)
       IS
       BEGIN
          UTL_FILE.put_line (v_fh,
                             '<ss:Worksheet ss:Name="' || p_sheetname || '">'
          UTL_FILE.put_line (v_fh, '<ss:Table>');
       END;
       PROCEDURE end_worksheet
       IS
       BEGIN
          UTL_FILE.put_line (v_fh, '</ss:Table>');
          UTL_FILE.put_line (v_fh, '</ss:Worksheet>');
       END;
       PROCEDURE set_date_style
       IS
       BEGIN
          UTL_FILE.put_line (v_fh, '<ss:Styles>');
          UTL_FILE.put_line (v_fh, '<ss:Style ss:ID="OracleDate">');
          UTL_FILE.put_line
                           (v_fh,
                            '<ss:NumberFormat ss:Format="dd/mm/yyyy\ hh:mm:ss"/>'
          UTL_FILE.put_line (v_fh, '</ss:Style>');
          UTL_FILE.put_line (v_fh, '</ss:Styles>');
       END;
    BEGIN
       v_fh := UTL_FILE.fopen (v_dir, v_file, 'w', 32767);
       start_workbook;
       set_date_style;
       start_worksheet ('OM');
       run_query ('select PARTY_ID,PARTY_NAME from HZ_PARTIES
        where PARTY_ID<1080');
       end_worksheet;
       start_worksheet ('PO');
       run_query ('SELECT AGENT_ID,TYPE_LOOKUP_CODE FROM PO_HEADERS_ALL
            WHERE PO_HEADER_ID<20');
       end_worksheet;
       end_workbook;
       UTL_FILE.fclose (v_fh);
    END;
    Here i will get two outputs in same excel with different spread sheets,
    now i want to set background color for headers i
    ex:PARTY_ID,PARTY_NAME,AGENT_ID,TYPE_LOOKUP_CODE are the headers,in excel output i want background color as blue.
    Please do need full help,its urgent req.

    Hello,
    open the file in Excel and save it, just to ensure that Excel writes all the additional stuff it thinks is necessary.
    Now change the background colour of the header and save the file again but with a different name.
    Open both files in a text editor and look at the differences. That's what you need to change in your code.
    Alternatively you can use packages like xml_spreadsheet or ExcelDocumentType, both write the same file format that you use in your code and you don't have to reinvent the wheel.
    Regards
    Marcus

  • Could set background color of scrollbar?

    Hy
    is it possibile set background color of scrollbar?
    thanks

    From my experience on this - yes, setting the colour (or the Visual Attribute) of the Block object will determine the background colour of the scrollbar. As far as I can see, it doesn't affect anything else.
    I've had to ensure all my Blocks have a background colour set (to r88g88b88), because if it's left as <unspecified>, then the background of the scrollbar will be transparent. In Client-Server 6i, this isn't too bad, as the scrollbar still has a visible 'edge', but in 10.1.2.0.2 WebForms, this edge isn't present, meaning the background of the scrollbar isn't visible at all, just the two ends and a disembodied drag button. Not the end of the world, but some users thought it looked funny.

  • GRC 10 LDAP query issue at the root node

    Hello,
    We are unable to do a search based on root node after successful LDAP integration but if we add a particular OU within the base entry then we are able to search the users for that specific OU. Specifying a specific OU is not the right solution as we have different OU for North America, Europe,
    Latin America etc. regions. We need to specify the root node so that it will search for all the users in different region. We are getting the below operation failed error when we don't specify OU in the base entry.
    Operation failed
    Message no. LDAPRC001
    Diagnosis
    This is an error message that is triggered by the directory server.
    It is not possible to analyze the error in the SAP system.
    Procedure
    Check the log files for the directory server (if they exist), to see if they
    contain more information.
    Please let us know if you guys have faced this situation and what was the resolution.
    Thanks,
    Gautam.

    We just have one LDAP server/connector set-up and it is working fine if we specifiy OU within the base entry along with the domain but it doesn't work if we remove OU and leave the base entry with the root node/domain. I have checked with our Basis team and we have only one forest..going to check with our AD team for the same. Since specifying OU in the base entry is pulling result from Active directory within LDAP t-code in GRC 10 system, I believe everything is fine from LDAP configuration standpoint and also SPRO configuration in GRC 10 system will come into scope when we try to retrive/populate those field in ARQ/CUP configuration in NWBC.
    Below is the structure of our AD. If we leave the base entry with the root node/domain (DC=NR,DC=AD,DC=NEWELLCO,DC=COM) then it doesn't work and give the operation failed error message but if we add OU (OU=EMEA,DC=NR,DC=AD,DC=NEWELLCO,DC=COM) along with the root node then it does provide us with the result.
    I'm going to follow up with the AD team but let me know if anyone got any ideas to resolve the above error.
    Thanks,
    Gautam.

  • How to set background color in PL/SQL

    Hi,
    I have tried to set background color in SQL Query. When I execute in Report Region, I am not getting the background color.
    SELECT first query
    UNION 
    SELECT '   || v_sel_organization_id  || ' organization_id  FROM DUAL) org , hr_all_organization_units haou                          WHERE positions_set.position_id = allocations_set.position_id(+)              AND org.organization_id = positions_set.organization_id AND positions_set.position_id = encumbrance_set.enc_position_id(+)              AND positions_set.position_id = payclass_set.position_id(+)  AND org.organization_id = haou.organization_id AND TRUNC (SYSDATE) BETWEEN haou.date_from AND NVL (haou.date_to, TRUNC (SYSDATE))      AND (NVL (allocations_set.allocations, 0) + NVL (encumbrance_set.enc_count, 0) + NVL (payclass_set.pay_count, 0)) != 0  union  select  null , '' ''  ,'' '',''<SPAN STYLE="background-color: red;">Total</span>'' ,''' || v_sum_alloc ||''','|| v_sum_vac ||','''||  v_sum_encum ||''',''' || v_sum_pay ||''' ,null,null,null,null,2 from dual' ; Can anyone help me to resolve this issue.
    Regards
    Balaji S
    Edited by: Balaji Subramaniam on Jan 19, 2010 5:53 PM
    Edited by: Balaji Subramaniam on Jan 19, 2010 5:53 PM
    Edited by: Balaji Subramaniam on Jan 19, 2010 6:46 PM
    Edited by: Balaji Subramaniam on Jan 19, 2010 6:48 PM

    Hi
    A couple of things...
    Thats SQL - not PL/SQL
    That is not a valid SQL statement, I'm surprised its not giving an error. Please post the exact region source.
    When posting code on the forum, put {noformat}{noformat} (with the curly brackets and the word code in lowercase) above and below your code like this...
    {noformat}{noformat}
    SELECT *
    FROM emp
    {noformat}{noformat}
    It will then appear like this... SELECT *
    FROM emp
    Cheers
    Ben                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to set background color in JTF GRID

    Is it possible to set background color in JTF GRID ?

    Hello Pavo,
    it's also possible to take the code from ebitar and use the expression within styleClass instead of inlineStyle.
    E.g. you can define a custom style "StyleClassEmptyText" in your skin and set this styleclass if af:inputtext is empty.
    By using style classes you can have the same style in the whole application and you are able to change this style on a single point(in the styleclass) for the whole application.
    br
    Peter

  • How to set background color in row of JTable ?

    i am new in java please tell me about How to set background color in row of JTable ? please example code. Thnak you.

    Here is an example: http://www.javaworld.com/javaworld/javaqa/2001-09/03-qa-0928-jtable.html
    For more info on how to use tables read the swing tutorial: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    ICE

  • How to set background color in af:inputText in an af:table

    Hi,
    how to set background color in af:inputText in an af:table depending on the value of af:inputText.
    For example, how to set background red if the af:inpuText is empty
    Thanks

    Hello Pavo,
    it's also possible to take the code from ebitar and use the expression within styleClass instead of inlineStyle.
    E.g. you can define a custom style "StyleClassEmptyText" in your skin and set this styleclass if af:inputtext is empty.
    By using style classes you can have the same style in the whole application and you are able to change this style on a single point(in the styleclass) for the whole application.
    br
    Peter

  • How to set background color for selected days in DateChooser

    How to set background color for selected days. I created
    checkbox for each day [Son,Mon,Tue,Wed,Thu,Fri,Sat] and a
    DateChooser, I want to change the background color for the selected
    day when i click on a button after selecting the desired checkboxs
    [ monthly wise/yearly wise]
    Thanks in advance

    There is no button involved in the following code, but it may
    be of use to you:
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    creationComplete="init()">
    <mx:Script>
    <![CDATA[
    private var origColor:uint;
    private function init():void {
    origColor = dc.getStyle("selectionColor");
    public function setBackGrdColors(newColor:uint):void {
    dc.setStyle("selectionColor", origColor);
    if(dc.selectedDate){
    var dayOfWeek:Number = dc.selectedDate.day;
    else{
    return;
    switch(dayOfWeek) {
    case 0:
    if(sun.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 1:
    if(mon.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 2:
    if(tue.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 3:
    if(wed.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 4:
    if(thu.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 5:
    if(fri.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 6:
    if(sat.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    default:
    break;
    ]]>
    </mx:Script>
    <mx:VBox horizontalAlign="center" verticalGap="20">
    <mx:DateChooser id="dc" textAlign="left"
    change="setBackGrdColors(cellColor.selectedColor)"/>
    <mx:HBox width="100%" horizontalAlign="center">
    <mx:CheckBox id="sun" label="Sun"/>
    <mx:CheckBox id="mon" label="Mon"/>
    <mx:CheckBox id="tue" label="Tue"/>
    <mx:CheckBox id="wed" label="Wed"/>
    </mx:HBox>
    <mx:HBox width="100%" horizontalAlign="center">
    <mx:CheckBox id="thu" label="Thu"/>
    <mx:CheckBox id="fri" label="Fri"/>
    <mx:CheckBox id="sat" label="Sat"/>
    </mx:HBox>
    <mx:HBox width="300" horizontalAlign="center">
    <mx:Label text="Background Color" />
    <mx:ColorPicker id="cellColor"
    selectedColor="#FF00FF"/>
    </mx:HBox>
    </mx:VBox>
    </mx:Application>

  • How do i get to display the nodes under the root node in a JTree?

    In my JTree there is a root node.This root node has 4 child nodes.Each child node in turn has nodes under it.What i need to do is just display the child nodes under the root node i.e., the four child nodes and keep these child nodes in a collapsed state.How do i go sbout this?

    Please try this:
    tree.expandRow(0);
    SwingUtilities.invokeLater(new Runnable(){
        public void run(){
            tree.setRootVisible(false);
    });If you want to show the RootHandles:
    tree.setShowsRootHandles(true);If you want to keep nodes in collapsed state (not expandable):
            tel = new TreeWillExpandListener() {
                public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
                    throw new ExpandVetoException( event, "Don't want" );
                public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
            tree.addTreeWillExpandListener(tel);Some reading material:
    http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html
    http://java.sun.com/docs/books/tutorial/uiswing/events/treewillexpandlistener.html
    Edited by: Andre_Uhres on Nov 14, 2007 5:17 PM
    Edited by: Andre_Uhres on Nov 14, 2007 5:33 PM
    Edited by: Andre_Uhres on Nov 14, 2007 5:39 PM

  • Eyedropper Tool sets Background color instead of Foreground

    Q: Why does the Eyedropper Tool set the Background color instead of the Foreground color when I click in my image?
    A: The reason for this is that the Background swatch is "targeted" to accept the color information passed on by the Eyedropper Tool when you use it to sample a color. You can reset the behavior by clicking on the Foreground swatch in your Colors Palette/Panel. See the image below:
    http://forums.adobe.com/servlet/JiveServlet/downloadImage/2-1902897-1946/Eyedropper-Focus- Infographic.png
    No matter which swatch is targeted, you can choose to temporarily sample color into the other swatch by holding down the Option key (ALT on Windows) while you sample with the Eyedropper Tool.
    If you'd like to have the current Foreground and Background colors (as displayed in your Toolbox) switch places, simply tap the 'X' key on your keyboard.
    Finally, to reset the Foreground and Background swatches to their default of black and white, simply tap the 'D' key.

    Click on Windows and color.  There is a setting there to change from
    foreground to background.  The one with the box around it is the default setting.

  • Eyedropper sets Background color swatch instead of Foreground

    Q: Why does the Eyedropper Tool set the Background color instead of the Foreground color when I click in my image?
    A: The reason for this is that the Background swatch is "targeted" to accept the color information passed on by the Eyedropper Tool when you use it to sample a color. You can reset the behavior by clicking on the Foreground swatch in your Colors Palette/Panel. See the image below:
    http://forums.adobe.com/servlet/JiveServlet/downloadImage/2-1902897-1946/Eyedropper-Focus- Infographic.png
    No matter which swatch is targeted, you can choose to temporarily sample color into the other swatch by holding down the Option key (ALT on Windows) while you sample with the Eyedropper Tool.
    If you'd like to have the current Foreground and Background colors (as displayed in your Toolbox) switch places, simply tap the 'X' key on your keyboard.
    Finally, to reset the Foreground and Background swatches to their default of black and white, simply tap the 'D' key.

    Click on Windows and color.  There is a setting there to change from
    foreground to background.  The one with the box around it is the default setting.

Maybe you are looking for