"background color not showing"

Hi all,
I am back with a new problem..hope u guys will help me out..
I have a very basic prgm where i am trying out the GUI things..
here is my code:import java.lang.* ;
import java.awt.* ;
import java.awt.event.*;
import javax.swing.* ;
class SecTest {
public static void main(String args[])
  JFrame MyFrame = new JFrame("MyFrame");
  MyFrame.setBackground(Color.pink);
  // MyFrame.show();//if i put it only here..it doesnt show me the string
  MyFrame.setBounds(100,100,400,400);
  MyFrame.addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e)
      System.exit(0);
  Toolkit MyTk = Toolkit.getDefaultToolkit();
  Image MyImg = MyTk.getImage("not.gif"); // not.gif is in my current directory
  MyFrame.setIconImage(MyImg);
  Container MyContentPane = MyFrame.getContentPane();
  JPanel MyPanel = new JPanel();
  MyContentPane.add(MyPanel);
  MyContentPane.add(new NewPanel());
  MyFrame.show();
  // but then if i have .show() at both places..i just get a flash of pink background and again the usual gray one..
class NewPanel extends JPanel {
public void paintComponent(Graphics g)
  super.paintComponent(g);
  Font f = new Font("SansSerif", Font.BOLD+Font.ITALIC, 20);
  g.setFont(f);
  g.setColor(new Color(0,128,124));
  g.drawString("Hello There..This is my first GUI program",50,50);
};Thanks & Regards,

You want to set the JPanel color pink so it shows, because that's the topmost layer, not the frames. And the reason why if you add show() up there your String doesn't appear, is because you haven't created the JPanel that display that yet. You need to use show() after you've created all your components so they appear. Here's the modified code:
import java.lang.* ;
import java.awt.* ;
import java.awt.event.*;
import javax.swing.* ;
class SecTest {
public static void main(String args[])
  JFrame MyFrame = new JFrame("MyFrame");
  //MyFrame.setBackground(Color.pink);
  // MyFrame.show();//if i put it only here..it doesnt show me the string
  MyFrame.setBounds(100,100,400,400);
  MyFrame.addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e)
      System.exit(0);
  Toolkit MyTk = Toolkit.getDefaultToolkit();
  Image MyImg = MyTk.getImage("not.gif"); // not.gif is in my current directory
  MyFrame.setIconImage(MyImg);
  Container MyContentPane = MyFrame.getContentPane();
  JPanel MyPanel = new JPanel();
  MyContentPane.add(MyPanel);
  MyContentPane.add(new NewPanel());
  MyFrame.show();
  MyFrame.show();
  // but then if i have .show() at both places..i just get a flash of pink background and again the usual gray one..
class NewPanel extends JPanel {
public void paintComponent(Graphics g)
  super.paintComponent(g);
  setBackground(Color.pink);
  Font f = new Font("SansSerif", Font.BOLD+Font.ITALIC, 20);
  g.setFont(f);
  g.setColor(new Color(0,128,124));
  g.drawString("Hello There..This is my first GUI program",50,50);
};

Similar Messages

  • Background color not showing up in Firefox

    I think I am having a CSS problem, but I am not sure. If you
    look at this
    link
    in Firefow you will see that the background color is not showing
    up. I put the background color in that table in the HTML as well as
    the CSS, but am not getting any love! On another page I did it is
    working fine. Click
    here and you
    will see it working fine.
    Is there some small detail that I missed? Any help is greatly
    appreciated!!

    In fact a whole heap of files are pointing to your hard
    drive...
    Jo
    "Josie1one" <joleros[nospam]@yahoo.com> wrote in
    message
    news:e35c9r$4ln$[email protected]..
    > On the one not working, the file is pointing to your
    hard drive:
    > <link href="file:///C|/Documents and Settings/nick/My
    Documents/Work
    > Files/Clients/RKFA/style.css"
    > Jo
    >
    > "Cloudbrk" <[email protected]> wrote in
    message
    > news:e35btk$41c$[email protected]..
    >>I think I am having a CSS problem, but I am not sure.
    If you look at this
    >>
    http://rebeccakoury.com/spiralstapestries/scrollearthtones.htm
    in Firefow
    >> you
    >> will see that the background color is not showing
    up. I put the
    >> background
    >> color in that table in the HTML as well as the CSS,
    but am not getting
    >> any
    >> love! On another page I did it is working fine.
    Click
    >>
    http://rebeccakoury.com/spiraltapestry.htm
    and you will see it working
    >> fine.
    >>
    >> Is there some small detail that I missed? Any help
    is greatly
    >> appreciated!!
    >>
    >
    >

  • Div background color not showing in Internet Explorer 8 and before

    My Footer div is not showing the background color (supposed to be black...)  in Internet Explorer 8 and earlier.  It's assuming the body color instead.  Also the border color on top of the 'bubbles' that run across the page is wrong (supposed to be blue)    Is this just because Internet Explorer 8 and earlier did not support div background and border colors yet, or is there a work-around??  Or maybe I did something wrong?
    The site is:    www.meridianwaterfiltration.com

    martcol wrote:
    I don't think that IE8 does rgba.
    It should be OK with rgb but not rgba.
    Martin
    No its doesnt
    I'd just use a hexidecimal color - black #000 and blue: #03f (see below)
    .footer {
    position: relative;
        width: 100%;
        padding-top: 0px;
        padding-right: 0;
        padding-bottom: 0px;
        padding-left: 0;
        background-image: none;
        background-repeat: repeat-x;
        margin-top: 0px;
        clear: both;
        height: 350px;
        background-color: #000;
    #bubble {
        background-image: url(Images/water drop 0banner.jpg);
        background-repeat: repeat-x;
        width: 100%;
        height: 43px;
        border-top-width: 3px;
        border-top-style: solid;
        border-top-color: #03F;
        margin: 0px;
        padding: 0px;
        background-color: #3FF;

  • Spot colors not showing correctly in acrobat 11

    Spot colors not showing correctly in the output preview as well as the page correctly. I have a spot pms
    295 on a page in a few different areas of text and backgrounds. The spot color shows on 1 of my backgrounds
    and text and a spot color on another background does not. These items are on the same page. Although I
    can use the eyedropper to check the color of these items and it states the spot color is present. The page
    also prints correctly. Previews not happening.

    I included 3 screen shots from Acobat 11 of the test requested. Also, included the last screen shot from Acobat 9 of same file.
    Which shows correct preview. To eliminate possible ICC profile issue. I did change profiles to all that were in the profile list
    with no change in either test.

  • Gradient filled background is not showing up in Internet Explorer on a PC.

    My gradient filled background is not showing up in Internet Explorer on a PC.
    I'm working on a MAC, so I don't know of anyway to preview a new MUSE Site in I.E. since it's no longer supported on a Mac.
    When the Home Page is viewed, my blue sky gradient background shows up as a white box?? I need a fix for this please.
    Here is my url:  www.ThanksSanta.org

    Hello,
    We might have to look into your .muse file to have a better look into the issue.
    I tried it on a sample file but it worked fine for me.
    Could you please e-mail your .muse file on [email protected] You can use Adobe SendNow service (https://sendnow.acrobat.com/) to send your file in case it is larger than 20MB.
    Please do not forget to mention the link to this forum in your e-mail.
    Regards,
    Sachin

  • Background does not show up when creating a PDF in InDesign

    I have placed the same image in Illustrator and the PDF does show up the image.

    Ooh. Ok. Thank you! I'm using InDesign CS5.5, Acrobat 10.1.6. Mac OSX (10.6.8).
    Layer 1: background (TIFF): does not show up
    Layer 2: Type and logos (EPS): do show up in my pdf.
    -When I select Overprint Preview in Indesign the background is missing.
    -I have created pdfs in different presets (smallest, high quality, etc) and still background does not show up.
    -When I place ONLY the background on a new InDesign document, it does show up in the PDF.
    -I have created a pdf with the background in Illustrator and it does show in my PDF.
    Thanks!

  • Is it possible to change TreeView's background color, not node color?

    In advance, Thanks!!
    Actually, I've made my own treeview in my project. and  I've changed my treeview node color as i want
    I wonder whether or not to change treeview's background color, not node color in below class.
    // in ~.fr
    Class
      kMyTreeViewWidgetBoss,
      kTreeViewWidgetBoss,
         IID_ICONTROLVIEW,                    kMyTreeViewCtrlViewImpl,  
         IID_ITREEVIEWWIDGETMGR,      kMyTreeViewListBoxWidgetMgrImpl,
         IID_ITREEVIEWHIERARCHYADAPTER,  kMyTreeViewListBoxHierarchyAdapterImpl,
         IID_ISTRINGLISTDATA,                          kStringListDataImpl,
         IID_IOBSERVER,                                  kMyTreeViewCtrlBoxObserverImpl,
    type MainTreeViewListBox(kViewRsrcType)       : TreeViewWidget    (ClassID = kMyTreeViewWidgetBoss)  {};
    MainTreeViewListBox   //Tree view
               kMyTreeViewWithTextListWidgetID, kPMRsrcID_None, // WidgetId, RsrcId
               kBindAll,           // Frame binding
               Frame(-1, 26, 300, 276)  // Frame
               kTrue, kTrue,         // Visible, Enabled
               kTrue,       // EraseBeforeDraw
               kInterfacePaletteFill,   // InterfaceColor
               kHideRootNode,// | kDrawEndLine, // Options. Display root node
               kFalse,  // Use H Scroll bar
               kTrue,  // Use V scroll bar
               20,   // fVScrollButtonIncrement
               20,   // fVThumbScrollIncrement
               0,   // fHScrollButtonIncrement
               0,   // fHThumbScrollIncrement
               2,   // Items selectable, 0 = No Selection, 1 = Single Selection, 2 = Multiple Selection
               kFalse,  // Allow children from multiple parents to be selected
               kTrue,  // Allow discontiguous selection
                //The tree view is dynamically created. 
    class MyTreeViewCtrlView : public PanelView
    virtual void   Draw(IViewPort* viewPort, SysRgn updateRgn);
    void MyTreeViewCtrlView::Draw( IViewPort*  viewPort, SysRgn  updateRgn )
       AGMGraphicsContext gc(viewPort, this, updateRgn);
      InterfacePtr<IGraphicsPort>  gPort(gc.GetViewPort(), UseDefaultIID()); // IID_IGRAPHICSPORT);
      ASSERT(gPort);
      gPort->gsave();
      PMRect frameOut      = GetFrame();
      frameOut.MoveTo(0, 0);
      COLORREF crBackColor    = RGB( 255, 0, 0 );
      gPort->setrgbcolor( GetRGBtoReal( GetRValue(crBackColor) ), GetRGBtoReal( GetGValue(crBackColor) ), GetRGBtoReal( GetBValue (crBackColor) ));
    gPort->rectpath(frameOut);
    gPort->fill();
    gPort->grestore();
    PanelView::Draw( viewPort, updateRgn );
    In above case, there are errors in kMyTreeViewCtrlViewImple when Indesign is launching.
    // Error Assert
    XferObject- ReadWrite for impl kMyTreeViewCtrlViewImpl of iid IID_ICONTROLVIEW in class kMyTreeViewWidgetBoss read wrong amount in plugin kMyTreeViewWidgetBoss
    but, in kMyTreeViewWidgetBoss ClassDescriptionTable, when remove this( IID_ICONTROLVIEW, kMyTreeViewCtrlViewImpl), that's ok. but I can't change background color. just interfacepalettefill color
    Please help me!!

    Here's a sample!
    That's all.
    #define GetRGBtoReal( X )   (double) X / (double) 255.f
    COLORREF crBackColor    = RGB( 255, 0, 0 );
    gPort->setrgbcolor( GetRGBtoReal( GetRValue(crBackColor) ), GetRGBtoReal( GetGValue(crBackColor) ), GetRGBtoReal( GetBValue(crBackColor) ));

  • When printing a PLD in 9.0 the color background does not show

    I have a PLD document (Sales Order) that I changed a field to have a "red" background which shows in my PLD document fine.  But I cannot get the color to show in my print out or in the print preview.  This issue has not been a problem for us in 8.82 but in 9.0 the same changes I make does not work.
    Has anyone had similar issues with this and if so, any suggestions on how to fix?
    PLD layout
    Preview of same layout
    Thanks

    Hi,
    Please compare and check both layouts. (8.82 & 9.0).
    Also refer thread No Color Backgrounds on print previews of PLD
    Thanks & Regards,
    Nagarajan

  • WYSIWYG Color not showing in PDF

    Output Designer 5.6
    Hi , I have two color shaded boxes on my form - a yellow -and- a light blue. When I output to PDF these show as grey :( .
    However to test if color is working I included some Blue text in Arial to the form and this prints as Blue ! on the PDF .
    What is the secret for color shaded boxes to also appear on PDF?
    Thanks in Advance.

    I got it to show in color , though looks like it works when you use a solid background and not a mesh.

  • CSS- Background img not showing up in container

    Hello, I am new to css but not to webpages. I used to design
    pages using tables and now I want to learn and design using css.
    But I'm having trouble and I figure its a quick fix. Note this
    website is not on line I am doing my test use IE 7 and Firefox ver
    2 PC Ver.
    Q: I'm trying to design a website for a client and I am have
    trouble try to get my background img to show up in my #container.
    Here is sample of my basic layout. Hope some could help me.
    @charset "utf-8";
    body {
    background-color: #271a0b;
    background-image: url(../images/bgStrip.gif);
    background-repeat: repeat-x;
    #container {
    width: 100%;
    height: 900px;
    overflow: hidden;
    background-image: url(/images/backGround.jpg);
    background-repeat: no-repeat;
    background-position: 0;
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=utf-8" />
    <title>Untitled Document</title>
    <link href="asset/screen.css" rel="stylesheet"
    type="text/css" />
    </head>
    <body>
    <div id="container">Content for id
    &quot;container&quot; Goes Here</div>
    </body>
    </html>
    body background is working. Note: Got the codes samples from
    CSS Cookbook, good book learning allot but can't seem to get it to
    work. Hope some could help me.

    If the page in question is one level below the root of the
    site, and if the
    images folder is at the same level as the root of the site,
    then both links
    would be correct.
    Also, since background-position defaults to "0", there's no
    reason to
    restate it.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "Virginia Carter" <[email protected]>
    wrote in message
    news:[email protected]...
    > Without seeing the page on the web, it's somewhat
    difficult to see exactly
    > where the problem is, but this is curious:
    >
    > body {
    > background-color: #271a0b;
    > background-image: url(../images/bgStrip.gif);
    > background-repeat: repeat-x;
    > }
    >
    > #container {
    > width: 100%;
    > height: 900px;
    > overflow: hidden;
    > background-image: url(/images/backGround.jpg);
    background-repeat:
    > no-repeat;
    > background-position: 0;
    > }
    >
    > It's looking in two different places for those images:
    >
    > ../images and /images
    >
    > Check that and then see if you still have troubles.
    >
    > --
    >
    > Virginia Carter
    > Carolina Web Creations
    > ======================
    > www.carolinawebcreations.biz
    >
    > borgru12 wrote:
    >> Hello, I am new to css but not to webpages. I used
    to design pages using
    >> tables and now I want to learn and design using css.
    But I'm having
    >> trouble and I figure its a quick fix. Note this
    website is not on line I
    >> am doing my test use IE 7 and Firefox ver 2 PC Ver.
    >>
    >> Q: I'm trying to design a website for a client and I
    am have trouble try
    >> to get my background img to show up in my
    #container. Here is sample of
    >> my basic layout. Hope some could help me.
    >> @charset "utf-8";
    >>
    >> body {
    >> background-color: #271a0b;
    >> background-image: url(../images/bgStrip.gif);
    >> background-repeat: repeat-x;
    >> }
    >>
    >> #container {
    >> width: 100%;
    >> height: 900px;
    >> overflow: hidden;
    >> background-image: url(/images/backGround.jpg);
    background-repeat:
    >> no-repeat;
    >> background-position: 0;
    >> }
    >>
    >>
    >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Strict//EN"
    >> "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    >> <html xmlns="
    http://www.w3.org/1999/xhtml">
    >> <head>
    >> <meta http-equiv="Content-Type"
    content="text/html; charset=utf-8" />
    >> <title>Untitled Document</title>
    >>
    >> <link href="asset/screen.css" rel="stylesheet"
    type="text/css" />
    >> </head>
    >>
    >> <body> <div id="container">Content for
    id 'container' Goes Here</div>
    >>
    >> </body>
    >> </html>
    >>
    >>
    >> body background is working. Note: Got the codes
    samples from CSS
    >> Cookbook, good book learning allot but can't seem to
    get it to work. Hope
    >> some could help me.
    >>

  • BUG(?): background color not in print profile

    When printing a photo from Lightroom 3 with paper background color this color is not corrected for printing, although I print with icc, print profile from Spyderprint. The photo itself is corrected. This means that the paper backround is colored instead of gray, for example.
    Is this a bug? I think so, because I there is no way I can change this.
    Thanks

    Hello CameraHans (are you Dutch, by the way?)
    The whole border or sheet has a color cast. The photo itself has not. Both are in greys, so I will do as you suggested and look what happens when I do this in colors.
    I will insert 3 screenshots, 2 of the Lightroom environment, and 1 of the print preview, I used here the 'contour' to show the effect. You can very well see that the color of the border does not change at all, Thanks, Hans van den Berg

  • Dreamweaver and Safari - colors not showing up

    I am creating a web site in Dreamweaver, and when I preview it in Safari my background colors do not show up at all. They look fine in Firefox and in mobile device previews. Anyone have any ideas on how to correct this? Thanks!

    Go to Image>Mode and make sure you color is RGB, not gray scale. Also, a preference reset might help: Ctrl/Cmd+Alt/Opt+Shift as you initiate Photoshop startup.
    Benjamin

  • Out put in Background (SM37) not showing All columns

    Hi Folks,
             I’m creating an out put display for my query in background , we have define an output device , after submitting the query in back ground it just showing me only 10 columns . I mean I its not showing me all columns when I went to SE37-> select job->”spool ->view (display).
    Why it’s happening?
    Please help me
    Cheers
    Usman

    When you are submitting the job in background by exexuting your query from Sq01 or Tr.code , a screen will pop-up ask for you device name, on the same screen you’ll see properties hit that, it’ll take you to another screen and change the report format 65 and 200 or 65 and 200. It depends on your out put device . You can only display report till 255 . If you want to active ALV functional enable in background spool job you have to use extracts for that . So you can download your data in correct format.
    You can also decrease the length of variables in query so within 255 characters you can see all report columns. 
    Hope this’ll help you .
    Hope this’ll give you idea!!
    <b>P.S award the points.</b>
    Good luck
    Thanks
    Saquib Khan
    "Some are wise and some are otherwise"

  • Background Images not showing up in template-based pages

    For some reason, whenever I make a custom .dwt template, with
    background images for things such as buttons, on my newly created
    page, the background images do not show up. Anyone know why? Thanks
    for the help in advance.

    Best you start here:
    http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fmattsworld.mooretecproductions.co m%2F
    55 code errors. Yikes!
    Fix those and then see if the problem goes away. If not, post
    back. At lease
    with clean code we may be able to spot the problem.
    Walt
    "Irish_Cereal" <[email protected]> wrote in
    message
    news:fegl0v$jvc$[email protected]..
    > Alright guys, I get it. Here's a link to the index:
    >
    http:///mattsworld.mooretecproductions.com
    > Click on Videos on the navigation bar and you'll see
    what I'm talking
    > about.
    > Notice how on the navbar on the index theres the custom
    button? On videos
    > it
    > doesn't show up.
    >

  • Browser Background Color Not Drawing Completely

    On the web page I recently uploaded, the page does not draw the browser background color completely when it loads. The browser background color fills in to the bottom of the sized page, below there it is white.
    1. Modern Frame 2.0 - Blank
    2. Set Browser Background color to Blue
    3. Page background color either the same Blue or none at all. I've tested both ways.
    4. Manual resize always allows the browser background color to fill in properly.
    5. Footer on and off. Doesn't make a difference.
    After uploading to the web, clearing all my caches, it continues to fill in incompletely.
    What do you suggest I do to solve this?
    Thank you - Fabe

    Give us the URL for the site so we can examine it first hand. With out looking at the site you should change the theme to White theme which does not use files for background and therefore will not restrict the amount of space the background takes up. That's just a guess though.
    OT
    Message was edited by: Old Toad

Maybe you are looking for

  • Patch number for Oracle 8.1.7.4 on Solaries SPARC 64bit

    Guys, Oracle Version: 8.1.6.0 OS: Solaris SPARC 64-bit I would like to patch to 8.1.7.4. I need a patch number for this, I find it very difficult to search for the patch on Metalink. Would you please suggest the patch number and maybe also suggest th

  • How to Add the cost centre  in the KSBB report

    Hi Experts, How can we add cost centre in KSBB report. Is it possible to add? if yes could any one guide me how to add the cost centre in KSBB report? waiting for your replies, Regards

  • Pdf reader wont open, why ?

    when I am trying to open PDF reader it opens an error prompt and wont open, why is that happening ? thanks in edwens to eny one that colde solve me this problem

  • Security issues with connecting pdf to database

    I have a pdf form that is being called from a webform as part of a web application. The PDF has two dropdown lists that I was populating from a SQL Server Database. I had created a special user that had select access only to the tables for the dropdo

  • About to purchase new mac: Migrating Logic

    Hi, I'm about to purchase a new mac and I don't have my original Logic disks. I've got the studio upgrade disks and obviously the serial from original logic. I'll have to migrate. From peoples experience, will I have any problems migrating Logic from