How to give Common Background color for all JPanels in My Swing application

Hi All,
I am developing a swing application using The Swing Application Framework(SAF)(JSR 296). I this application i have multiple JPanel's embedded in a JTabbedPane. In this way i have three JTabbedPane embedded in a JFrame.
Now is there any way to set a common background color for the all the JPanel's available in the application??
I have tried using UIManager.put("Panel.background",new Color.PINK);. But it did not work.
Also let me know if SAF has some inbuilt method or way to do this.
Your inputs are valuable.
Thanks in Advance,
Nishanth.C

It is not the fault of NetBeans' GUI builder, JPanels are opaque by default, I mean whether you use Netbeans or not.Thank you!
I stand corrected (which is short for +"I jumped red-eyed on my feet and rushed to create an SSCCE to demonstrate that JPanels are... mmm... oh well, they are opaque by default... ;-[]"+)
NetBeans's definitely innocent then, and indeed using it would be an advantage (ctrl-click all JPanels in a form and edit the common opaque property to false) over manually coding
To handle this it would be better idea to make a subclass of JPanel and override isOpaque() to return false. Then use this 'Trasparent Panel' for all the panels where ever transparency is required.I beg to differ. From a design standpoint, I'd find it terrible (in the pejorative sense of the word) to design a subclass to inconsistently override a getter whereas the standard API already exposes the property (both get and set) for what it's meant: specify whether the panel is opaque.
Leveraging this subclass would mean changing all lines where a would-be-transparent JPanel is currently instantiated, and instantiate the subclass instead.
If you're editing all such lines anyway, you might as well change the explicit new JPanel() for a call to a factory method createTransparentJPanel(); this latter could, at the programmer's discretion, implement transparency whichever way makes the programmer's life easier (subclass if he pleases, although that makes me shudder, or simply call thePanel.setOpaque(false) before returning the panel). That way the "transparency" code is centralized in a single easy to maintain location.
I had to read the code for that latter's UI classes to find out the keys to use (+Panel.background+, Label.foreground, etc.), as I happened to not find this info in an authoritative document - I see that you seem to know thoses keys, may I ask you where you got them from?
One of best utilities I got from this forum, written by camickr makes getting these keys and their values very easy. You can get it from his blog [(->link)|http://tips4java.wordpress.com/2008/10/09/uimanager-defaults/]
Definitely. I bit a pair of knucles off when discovered it monthes after cumbersomely traversing the BasicL&F code...
Still, it is a matter-of-fact approach (and this time I don't mean that to sound pejorative), that works if you can test the result for a given JDK version and L&F, but doesn't guarantee that these keys are there to stand - an observation, but not a specification.
Thanks TBM for highlighting this blog entry, that's the best keys list device I have found so far, but the questions still holds as to what specifies the keys.
Edited by: jduprez on Feb 15, 2010 10:07 AM

Similar Messages

  • My background color for all pages has changed to pink, how do I get it back to white?

    The background color in all of my screens has switched to pink. How do I get it back to white? I wonder if it changed when I was shopping in a web site and had clicked on a pink watch(?)

    Check the default color settings:
    *Tools > Options > Content : Fonts & Colors > Colors
    * [X] "Allow pages to choose their own colors, instead of my selections above"
    *https://support.mozilla.com/kb/Changing+fonts+and+colors

  • No Background Color for ALL DAY EVENTS

    Is there a way to prevent the background color from All-Day-Events in iCal? I would prefer to print/view the calendar w/o the background colors.

    No one answered

  • An applescript to change the background color for all finder windows

    I'll start off by telling you what I am trying to achieve, then show you what I've tried.
    I have a macbook with several HDD's attached. what I want is for each of those hdd to have a specific finder window background color. so no matter where I am in that hdd the background color will always be the same. so for instance if I set the background color of hdd 2 to blue then as long as I see a blue background I know that I'm within hdd 2.
    I've tried setting up an applescript to do this but can only get it to change the open finder window, and none of the subfolders have their backgrounds changed.
    here is what I have so far:
    tell application "Finder"
    tell the icon view options of the front Finder window
    set the background color to {52942, 54484, 31097}
    end tell
    end tell
    so how do I get this to apply to all subfolders without opening each one and running the script.
    thanks in advance for any and all help with this

    According to this article:
    http://docs.info.apple.com/article.html?path=AppleScript/2.1/en/as2039.html
    it seems that the various options can only be set while the window is open and in icon view.
    Rather than manually opening the window of every single folder on the hard drive, it should be possible to write a script to open every folder in sequence, make sure it is in icon view, change its background, then close its window. I have never been any good at the "actions within actions" procedure needed for folders within folders, so maybe someone else with the necessary knowledge and experience might be able to assist in this regard. Such a script would probably take a few minutes to complete while it ran through "every folder of every folder", but it sure would be quicker to have the process automated than to do it by hand - computers are really good at repetitive tasks (as long as the instructions are accurate, of course!).
    On the other hand, you might like to try the following:
    open a few windows in icon view, choose Show View Options in the View menu (I'm in System 10.4), click the radio button All Windows, click the Color radio button under Background, then choose your color. It might achieve what you are trying to do.

  • Changing font and background color for all components

    Hi,
    This is my first time writing a GUI, and I'm pretty new to Swing and Java. I just recently switched from C++, and so far Java seems to be doing a nice job =)
    Currently I have a gazilion components (textfields, labels, panels) and I'm wondering if there is a way to change their background/foreground colours without adding in setBackground/setForeground for every single component.
    I've done some researching onto using Look and Feel, but there aren't any current ones that suits my needs. And everyone seems to mention that programming your own is pretty complicated.
    My boss wants a slick white text on black background interface, so you can imagine that he's not very impressed with the current default greyish colours =)
    Thank you for any help!
    Cindy

    Hi Cindy,
    I'm not sure how effective a solution this will be, but you could try:UIManager.put("TextField.background", Color.BLACK); // Default text field background becomes blackThere are many more defaults you'd have to change and could probably achieve it more reliably and simply by creating or editing the properties file that controls the way the look and feel (even if it's the default) is implemented. Take a look at:
    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/UIManager.htmlHope this is helpful
    Chris.

  • I have trouble reading in Black and White. changing the background color for all

    I have trouble reading in Black and White. On my PC I can change the background  color (and I am not just talking about for a word or pages document) but for eveything so anything that was a white background I can put in what ever color I like but it still prints in Black and white.. I can't see how to do this on the Macbook air. on my PC I do this in display. Sort of putting colored film over the screen I dont know what to do. Can anyone help?

    Hello Floridamacbookpro,
    You may be interested in the 'invert colors' Accessibility feature. This can be invoked by pressing the Control, Option, Command, and 8 keys on your keyboard. This only affects your display, and does not have any affect on printed items.
    Mac OS X displays inverted image colors (white on black, reverse type)
    http://support.apple.com/kb/HT3488
    Cheers,
    Allen

  • How to apply common View criteria for all LOV View programatically?

    Hi,
    In my application I use nearly 100 VOs, which will be mapped as LOV to some base VOs. These VOs are not only for LOV but also will be used directly in screen as read-only table. All these VOs contains EFF_BGN_DTand EFF_END_DT. Requirement is to display only the active records in VO.
    We don't want to crete view criteria at design time for each and every VO. Instead we want to have a base ViewObjectImpl class, create at runtime and add this common criteria with the existing view criterias (If any given, which are actually required for the developer for screen specific functionality).
    NOTE: As all of our VOs are custom java data source implemented and none of them have queries, we cannot use whereclause API but only ViewCriteria.
    We want to create a view criteria, that somewhat looks like the below condition.
               (     (TO_CHAR( EffBgnDt, 'yyyy-mm-dd') <= '2010-02-01' )
                 AND (TO_CHAR( EffEndDt, 'yyyy-mm-dd') >= '2010-02-01' )
                 OR
               (     (TO_CHAR( EffBgnDt, 'yyyy-mm-dd') <= '2010-02-01' )
                 AND (EffEndDt IS NULL )
               )Question:
    1. Which is the best place in ViewObject class, where I will be able to create common view criteria, include it with existing criterias.
    Thanks in Advance.
    Raghu

    No it is not working. I've tested. When i test your implementation in my sample using AM tester, it is not at all going inside getCriteriaItemClause(ViewCriteriaItem pViewCriteriaItem). For example when i say, AM.findViewObject(String ViewObjectName), followed by getEstimatedRowCount(), it should apply common filter criteria and give me the result.
    Given below required scenario:
    Department table:
    ID     DEPT_NAME     START_DATE     END_DATE
    1     Hr          1-Jan-2010     
    2     Purchasing     1-Jan-2010     31-Dec-2010
    3     Shipping             1-Jan-2010     31-Dec-2055
    4     Sales          1-Jan-2010     
    Common criteria to be applied (Programatically) : :bind_current_date between StartDate and EndDate or :bind_current_date >= StartDate and EndDate is null
    VO specific view criteria (may vary VO to VO): DeptName not equal to 'Sales'
    Expected Result:
    Case 1:
             a. DeptView = AM.findViewObject("DepartmentVO")
             b. DeptView.getEstimatedRowCount()
              It should give me 3 records (Hr, Shipping, Sales)
    Case 2:
             a. DeptView = AM.findViewObject("DepartmentVO")
             b. Create View Criteria 'NotSalesDeptVC', which should not list out Sales department.
             c. Apply NotSalesDeptVC using RowSet rowSet = (RowSet) this.findByViewCriteria(NotSalesDeptVC, -1, ViewObject.QUERY_MODE_SCAN_VIEW_ROWS)
             d. rowSet.getEstimatedRowCount()
              It is in-memory filtering, will not disturb the default rowset, should give me 2 records (Hr, Shipping)
    Case 3:
             a. DeptView = AM.findViewObject("DepartmentVO")
             b. Apply 'NotSalesDeptVC' to the default row set, followed by executeQuery
             c. DeptView.getEstimatedRowCount()
              It should give me 2 records. (Hr, Shipping)
    Case 4:
             a. DeptView = AM.findViewObject("DepartmentVO")
             b. Unapply the applied 'NotSalesDeptVC', followed by executeQuery
             c. DeptView.getEstimatedRowcount()
              It should give me 3 records (Hr, Shipping, Sales)Essence is at any point of time, User should always work with active records. He no need to write extra logic to retrieve only the active records but the base Viewobject impl should have. Note, All of my view objects are custom java data source implemented and not query based. Similarly it does not meant that all of my VOs will be having some business specific View criteria. Some VOs may have. Some VOs may not have. However basic active records criteria is applicable for all VOs

  • How to retrieve default background color for JPanels or other containers?

    Hi everybody, I've written a small class extending the default JTextArea, intended to provide the functionality of a small, descriptive item in JPanels.
    import java.awt.*;
    import javax.swing.*;
    public class JInfoTextArea extends JTextArea{
         public JInfoTextArea(String text){
              super(text);
              setEditable(false);
              setFont(Font.decode("SansSerif"));
              setFocusable(false);
              setLineWrap(true);
              setWrapStyleWord(true);
    //          setBackground(contentPane.getBackground());
              setAlignmentX(Component.LEFT_ALIGNMENT);
              setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    }As you can see, there formerly used to be a third parameter, namely contentPane, which contained a reference to the parent Container in order to set the TextArea's background color appropriately for transparency.
    Now, is there ANY way to retrieve the background color without either passing a dedicated parameter or doing something like
    setBackground((new JPanel()).getBackground());Any help is greatly appreciated!
    Yours, Stefanie

    To answer your original question the UIManager contains properties of the various components. In case your interested the following program has a fancy GUI display of all the components:
    http://www.discoverteenergy.com/files/ShowUIDefaults.java

  • How to change the background color for lookup column options in sharepoint 2007

    Hi,
    I have a custom List with 10 fields,and in the edit form we want to display only 6 fields,
    So I have customized it with sharepoint designer 2007 ,designed a new custom edit form(Insert->ShaerPoint Controls->Custom List Form)
    We are using IE8 Browser,and the site has JQuery 1.8 loaded .
    The lookup columns is getting rendered as textbox and dropdown arrow image,instead of select html element.
    When we click on arrow image,its displaying the values magically,So I am unable to highlight the options with text "ABC" in yellow background color
    basically in the input textbox its storing all the lookup values as "ID|value "in choices attribute (I saw this in browser dev tools)
    I tried to set the textbox color everytime it loses focus using blur,however its always returning the previous value instead of current selected value.
    Is there any way we can achieve this,Any solutions/thoughts
    Thanks everyone..

    hi i bet you need to amend your jquery script to get onclick values and put it with like append HTML if you want to use Jquery.
    Also did you know you could use javascript in calculated column with type number?
    Check:
    http://sharepointwijzer.nl/sharepoint-blog/tech/icc-html-calculated-column-sharepoint-view
    Imposible is nothing

  • How to set cell background color for JCheckBox renderer in JTable?

    I need to display table one row with white color and another row with customized color.
    But Boolean column cannot set color background color.
    Here is my codes.
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.TreeSet;
    public class BooleanTable extends JFrame
        Object[][] data = {{Boolean.TRUE},{Boolean.TRUE},{Boolean.TRUE},{Boolean.TRUE},{Boolean.TRUE},{Boolean.TRUE}};
        String[] header = {"CheckBoxes"};
        public BooleanTable()
            setDefaultCloseOperation( EXIT_ON_CLOSE );
            TableModel model = new AbstractTableModel()
                public String getColumnName(int column)
                    return header[column].toString();
                public int getRowCount()
                    return data.length;
                public int getColumnCount()
                    return header.length;
                public Class getColumnClass(int columnIndex)
                    return( data[0][columnIndex].getClass() );
                public Object getValueAt(int row, int col)
                    return data[row][col];
                public boolean isCellEditable(int row, int column)
                    return true;
                public void setValueAt(Object value, int row, int col)
                    data[row][col] = value;
                    fireTableCellUpdated(row, col);
            JTable table = new JTable(model);
            table.setDefaultRenderer( Boolean.class, new MyCellRenderer() );
            getContentPane().add( new JScrollPane( table ) );
            pack();
            setLocationRelativeTo( null );
            setVisible( true );
        public static void main( String[] a )
            try
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            catch( Exception e )
            new BooleanTable();
        private class MyCellRenderer extends JCheckBox implements TableCellRenderer
            public MyCellRenderer()
                super();
                setHorizontalAlignment(SwingConstants.CENTER);
            public Component getTableCellRendererComponent(JTable
                                                           table, Object value, boolean isSelected, boolean
                                                           hasFocus, int row, int column)
                if (isSelected) {
                   setForeground(Color.white);
                   setBackground(Color.black);
                } else {
                   setForeground(Color.black);
                   if (row % 2 == 0) {
                      setBackground(Color.white);
                   } else {
                      setBackground(new Color(239, 245, 217));
                setSelected( Boolean.valueOf( value.toString() ).booleanValue() );
             return this;
    }

    Instead of extending JCheckBox, extend JPanel... put a checkbox in it. (border layout center).
    Or better yet, don't extend any gui component. This keeps things very clean. Don't extend a gui component unless you have no other choice.
    private class MyCellRenderer implements TableCellRenderer {
        private JPanel    _panel = null;
        private JCheckBox _checkBox = null;
        public MyCellRenderer() {
            //  Create & configure the gui components we need
            _panel = new JPanel( new BorderLayout() );
            _checkBox = new JCheckBox();
            _checkBox.setHorizontalAlignment( SwingConstants.CENTER );
            // Layout the gui
            _panel.add( _checkBox, BorderLayout.CENTER );
        public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
            if( isSelected ) {
               _checkBox.setForeground(Color.white);
               _panel.setBackground(Color.black);
            } else {
               _checkBox.setForeground(Color.black);
               if( row % 2 == 0 ) {
                  _panel.setBackground(Color.white);
               } else {
                  _panel.setBackground(new Color(239, 245, 217));
            _checkBox.setSelected( Boolean.valueOf( value.toString() ).booleanValue() );
            return _panel;
    }

  • How can I change background color for a text field

    Hi I tried this
    style="BACKGROUND-COLOR:#00FFFF"
    working fine in IE
    but not working in Netscape.. any other way to set the background color?

    Netscape 4.x does not support this feature. Only Netscape 6.x does.

  • How can I select a smaller font for all components of a Swing application?

    The default size of font in Java Look and Feel is 12, how can I change it to 10 globally for my Swing application ?
    Thanks for your help.
    Helen

    It is not very simple because all components don't use the same fonts and if you don't want to subclass the l&f you can do this :
    after setting the l&f (in the main for example)
    Font f = new Font("dialog", Font.PLAIN, 11);
    UIManager.put("MenuItem.font", f);
    UIManager.put("Menu.font", f);
    UIManager.put("MenuItem.acceleratorFont", new Font("dialog", Font.PLAIN, 10));
    UIManager.put("Label.font", f);
    UIManager.put("Button.font", f);
    UIManager.put("ToggleButton.font", f);
    UIManager.put("ToolTip.font", f);
    UIManager.put("List.font", f);
    UIManager.put("Table.font", f);
    UIManager.put("TextField.font", f);
    UIManager.put("ComboBox.font", f);
    UIManager.put("RadioButton.font", f);
    UIManager.put("CheckBox.font", f);
    UIManager.put("RadioButtonMenuItem.font", f);
    UIManager.put("CheckBoxMenuItem.font", f);
    UIManager.put("TableHeader.font", f);
    UIManager.put("Spinner.font", f);
    UIManager.put("Panel.font", f);etc...
    Denis

  • How to call common error pages for all the exceptions

    Hi All
    I have created the common ErrorPage in my application. In case of any error whether SQL,IO or JBO I want that error page be displayed. In the page definition I have given the errorpage name and also defined the error page as IS_ERROR_PAGE = true.But it is throwing Jbo exception at the top of the page itself.No redirection to the error page is done.
    Though I have gone through various threads in this forum but still its not clear how to get the things working.
    Can anyone please help me out in this regard?

    Hi,
    I assume you mean that you set the error page in the web.xml file. Note that exceptions are handled first by the JSF framework. Please have a look at the developer guide
    http://download-uk.oracle.com/docs/html/B25947_01/toc.htm
    http://download-uk.oracle.com/docs/html/B25947_01/web_val008.htm#CIHHBEEJ
    Frank

  • How to giv diff varible values for all the queries in a Workbook?

    Hello BI Gurus,
              I have an issue with the variable in a the workbook,
    I have a workbook in which 4 queries are inserted in the same sheet one below the other and all these queries has same hierarchy variable (same technical name). In all these queries uses different hierarchies but same selection variable.
              Now the issue is , when I refresh the workbook the first queryu2019s variable pops up selection option for the hier variable and when I enter the value this first query runs fine but it carries the same value to another query and fails as the 2nd query uses diff hier.
    All I need is, is there any way by which these queries pop up selection screen separately for every query in workbook?
    Thanks a lot..! have a great day!

    Hi,
    You should open workbook settings and remove tick for display dubplicate veriables omly once.
    Regards,
    Veronika.

  • Background color for column heading

    Hi,
    I have 5 columns in my report and I would like to have different background color for column headings. How can I do this in report templates?
    I was looking at Column heading section-
    <th class="t10ReportHeader"#ALIGNMENT# id="#COLUMN_HEADER_NAME#">#COLUMN_HEADER#</th>
    How can I specify backgrund colors for all columns here?
    Thanks in advance

    G'day Karen,
    Thanks for ur reply.
    I have seen this note before, its not that the header colors have changed after latest SP was applied in our systems. Also the ABAP and JAVA stacks are in sync.
    Scenario is that we are trying to set up a new Portal theme for Enterprise Reporting with some specific color codes (hex codes).
    What i have observed is Characterstics Header background color is set up using the element "Background Color of Level 1 Column Heading ".
    While the Background color for Key Figures header is using element "Background Color of Level 2 Column Heading ".
    But the problem is element "Background Color of Level 2 Column Heading " is also used as the Background color for Standard Characterstics cell, so if we make it same the whole report of the same color, which we dont want.
    Requirement is to get the same Background color for Header cells (both Char. and Key Figure headers).
    Any further suggestions will be appreciated.
    Thanks
    CK

Maybe you are looking for

  • Re Joining two fact tables.

    Hi Experts, We have a requirement for a report to display columns from two different fact table. We have a Order Table W_ORDER_D dimension table,a Order item table W_ORDERITEM_F fact table & a INVOICE table W_INVOICE_F fact table. The requirent is th

  • Users not able to see all the default reports in FDM under analysis

    All, Users in FDM are not able to see all the default reports which will be available under Analysis. I have checked the MenuNavigation and MenuNavigationItems under object maintainence in FDM which have "ALL" as the provisioning level. I am not sure

  • Error Msg when connecting iPod

    Ok so i just bought my iPod and I can't get it to connect to my PC the msg i get is "One of the USB devices attached to this computer has malfunctioned, and windows does not recognize it.". Faulty iPod? or something else i might be missing? I also ha

  • I wanna know how binding to LDAP V3

    If it is binding to LDAP V3, in case of storing Korean Language, doesn't is really have to need to conver to UTF-8 type? If so, is is binding sample code to LDAP V2, I wanna know how binding to LDAP V3 LDAP V2 Sample Code if ( ldap_simple_bind_s( ld,

  • Number of secs for TimeZone string

    Hello, I have a query related to date /time. I need to generate the number of seconds based on timezone string. I need C code for unix(solaris platform). My application gets the input with timezone string. I need to generate the number of sec for the