Gradient paint or image as a background in JPanel.

Discussion in 'Java' started by Aaron Fude, Nov 7, 2008.

  1. Aaron Fude

    Aaron Fude Guest

    How to do it?

    I found a few ways to do it on the web, but there's gotta be one de-
    facto-standard way of doing it. What would that be?

    Thanks,

    Aaron
     
    Aaron Fude, Nov 7, 2008
    #1
    1. Advertising

  2. On Nov 7, 11:52 am, Aaron Fude <> wrote:
    > How to do it?
    >
    > I found a few ways to do it on the web,


    Why? It is not exactly common that a program needs a
    gradient or image BG to a panel.

    >...but there's gotta be one de-
    > facto-standard way of doing it. What would that be?


    Why not use one of the techniques you found, and thereby
    make it (by force of numbers) one step closer to being a
    'de-facto standard'?

    --
    Andrew T.
    pscode.org
     
    Andrew Thompson, Nov 7, 2008
    #2
    1. Advertising

  3. Aaron Fude

    Aaron Fude Guest

    On Nov 6, 9:41 pm, Andrew Thompson <> wrote:
    > On Nov 7, 11:52 am, Aaron Fude <> wrote:
    >
    > > How to do it?

    >
    > > I found a few ways to do it on the web,

    >
    > Why?  It is not exactly common that a program needs a
    > gradient or image BG to a panel.
    >
    > >...but there's gotta be one de-
    > > facto-standard way of doing it. What would that be?

    >
    > Why not use one of the techniques you found, and thereby
    > make it (by force of numbers) one step closer to being a
    > 'de-facto standard'?
    >
    > --
    > Andrew T.
    > pscode.org


    All of those techniques seemed ad-hoc. I would like to learn the right
    place to put the code? Is it "paint" or "paintComponent", or?
     
    Aaron Fude, Nov 7, 2008
    #3
  4. Aaron Fude

    Mayeul Guest

    Aaron Fude a écrit :
    > On Nov 6, 9:41 pm, Andrew Thompson <> wrote:
    >> On Nov 7, 11:52 am, Aaron Fude <> wrote:
    >>
    >>> How to do it?
    >>> I found a few ways to do it on the web,

    >> Why? It is not exactly common that a program needs a
    >> gradient or image BG to a panel.
    >>
    >>> ...but there's gotta be one de-
    >>> facto-standard way of doing it. What would that be?

    >> Why not use one of the techniques you found, and thereby
    >> make it (by force of numbers) one step closer to being a
    >> 'de-facto standard'?
    >>
    >> --
    >> Andrew T.
    >> pscode.org

    >
    > All of those techniques seemed ad-hoc. I would like to learn the right
    > place to put the code? Is it "paint" or "paintComponent", or?


    I think the javadoc is rather clear that a JComponent's background
    should be drawn in its paintComponent() method and that paint() should
    be left alone for this.

    It probably should be drawn first thing too, not touch the border insets
    if there are some, and honor isOpaque() (that is to say, do fill the
    background with opaque paint if isOpaque() is true.)

    As for how to actually draw the thing, it seems you already found
    working examples.

    --
    Mayeul
     
    Mayeul, Nov 7, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne  Wengert

    Create Gradient Background on Web Page

    Wayne Wengert, Sep 8, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    12,597
    Wayne Wengert
    Sep 8, 2004
  2. John M

    Gradient background

    John M, Dec 18, 2003, in forum: Java
    Replies:
    4
    Views:
    7,986
    Chris Smith
    Jan 9, 2004
  3. Rajesh.Rapaka

    paint my jpanel

    Rajesh.Rapaka, Apr 22, 2005, in forum: Java
    Replies:
    1
    Views:
    4,532
    Thomas Weidenfeller
    Apr 22, 2005
  4. Replies:
    4
    Views:
    4,639
    Brendan Guild
    Oct 23, 2005
  5. Peter Cheung

    can't stop JPanel paint

    Peter Cheung, Jul 14, 2011, in forum: Java
    Replies:
    2
    Views:
    530
    Roedy Green
    Jul 26, 2011
Loading...

Share This Page