Results 1 to 2 of 2
  1. #1
    Gloomy is offline Member
    Join Date
    Jul 2010
    Location
    Wollongong, NSW, Australia
    Posts
    6
    Rep Power
    0

    Default adding background image to jtabbedpane

    Hey, is it possible to add a background image to a jtabbedpane?

    Ive been looking around and all i can find are examples of setting the color but thats not what im after.


    I thought it would be something similar to the add COLOR background but this gives me a compiling error

    Java Code:
            JTabbedPane tabbedPane = new JTabbedPane();
            ImageIcon icon = createImageIcon("http://www.java-forums.org/images/photo.gif");
            tabbedPane.setBackground(icon);
            
            TESTING panel1 = new TESTING();
            tabbedPane.addTab("Fisrt tab", panel1);
    If this cant be done is there a way I can make an ImageIcon a tab itself? or somehow make it to perform like a tab?

    -----------------

    Just thought i might add Im after a rounded corners look to the tabs themselves, with a custom gradient as their background colour, not just the plain default one colour thats there already, if there is a way I can do this without having to make the image with photoshop then add it like ive been doing, please tell me the key words i should be seraching for :)
    Last edited by Gloomy; 08-09-2010 at 09:13 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Since a JTabbedPane inherits from JComponent, why not just override its paintComponent method as we do for a JPanel and draw in there. If you do this, then you'll need to make sure that the components added have their opaque properties set to false.

Similar Threads

  1. Dynamically adding JPanels to the JTabbedPane !!
    By Stephen Douglas in forum New To Java
    Replies: 1
    Last Post: 04-12-2010, 05:54 PM
  2. Adding contents inside the JTabbedPane
    By javanewbie in forum New To Java
    Replies: 1
    Last Post: 05-27-2009, 12:02 PM
  3. Problem Adding Content To JTabbedPane
    By JDCAce in forum AWT / Swing
    Replies: 5
    Last Post: 10-18-2008, 09:45 AM
  4. Adding information to a JTable in a JTabbedPane
    By bigpappatrader in forum AWT / Swing
    Replies: 0
    Last Post: 12-05-2007, 07:09 AM
  5. Adding Tabs to JTabbedPane
    By blackstone in forum AWT / Swing
    Replies: 2
    Last Post: 11-14-2007, 03:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •