Background Image on a Component

How do I add a background image to a component, in this case, a scrollpane containing a drawing area. This is for a level editor for my game. I want a level's background image to be drawn and tiled so the user can get a better preview of what the level will really look like. Is there an easy way to do this?

Do you have a little code-snippet on how to use this
class? The only things I've ever needed to do in
graphics is loading, transforming, and drawing images,
so I'm a bit in the dark on anything outside that.I think something like this will do it. I don't know for sure though since I've never used it:
private BufferedImage bImage;
// ... constructors, code blahdy blah, construct the bufferedimage here etc.
public void paintComponent(Graphics g) {
  // the Rectangle2D in user space used to anchor and replicate the texture:
  Rectangle2D anchor = new Rectangle2D.Double(0,0,20,20);
  // the actual paint object:
  TexturePaint tpaint = new TexturePaint(bImage, anchor);
  Graphics2D g2d = (Graphics2D) g;
  g2d.setPaint(tpaint);
  // g2d.fillRect(0,0,getWidth(), getHeight());
}

Similar Messages

  • Background Image in JTable headers

    Hi
    I used the following article http://java.sun.com/products/jfc/tsc/articles/swing2d/index.html
    to create a background image in my java application and then also how to make the table "see through".
    I have managed this apart from one small problem. The tabele headers appear white.
    I have tried everything but with no success. Please help. Below is the code i am using for the header
    JTableHeader tableHead;
    DefaultTableCellRenderer header = new DefaultTableCellRenderer() {
    boolean isSelected = false;
    Color selectionColor;
    // we'll use a translucent version of the table's default
    // selection color to paint selections
    Color oldCol = table.getSelectionBackground();
    selectionColor = new Color(oldCol.getRed(), oldCol.getGreen(), oldCol.getBlue(), 128);
    // need to be non-opaque since we'll be translucent
    setOpaque(false);
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    // save the selected state since we'll need it when painting
    this.isSelected = isSelected;
    if (table != null) {
    JTableHeader header = table.getTableHeader();
    if (header != null) {
    header.setResizingAllowed(false);
    header.setReorderingAllowed(false);
    setForeground(Color.black);
    setHorizontalAlignment(CENTER);
    setFont((new java.awt.Font("Dialog", 1, 14)));
    setHorizontalAlignment(CENTER);
    setFont((new java.awt.Font("Dialog", 1, 14)));
    return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    // since DefaultTableCellRenderer is really just a JLabel, we can override
    // paintComponent to paint the translucent selection when necessary
    public void paintComponent(Graphics g) {
    if (isSelected) {
    g.setColor(selectionColor);
    g.fillRect(0, 0, getWidth(), getHeight());
    super.paintComponent(g);
    table.getTableHeader().setDefaultRenderer(header);

    This thread shows the easiest way I've found to paint a background image on a component:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=316074
    However, a JTableHeader will be a little more difficult since it uses the renderer to paint each cell. The renderer must be made opaque to the image can be seen:
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TableHeaderImage extends JFrame
        ImageIcon icon = new ImageIcon("mong.jpg");
        public TableHeaderImage()
            JTable table = new JTable(5, 5);
            JTableHeader header = new JTableHeader( table.getColumnModel() )
                public void paintComponent(Graphics g)
                    //  Scale image to size of component
                    Dimension d = getSize();
                    g.drawImage(icon.getImage(), 0, 0, d.width, d.height, null);
                    setOpaque( false );
                    super.paintComponent(g);
            ((JComponent)header.getDefaultRenderer()).setOpaque(false);
            table.setTableHeader( header );
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            JScrollPane scrollPane = new JScrollPane( table );
            getContentPane().add( scrollPane );
        public static void main(String[] args)
            JFrame frame = new TableHeaderImage();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.pack();
            frame.setLocationRelativeTo( null );
            frame.setVisible(true);
    }

  • ADF panelGroup component's background image in CSS does not render

    Hi,
    I have an issue with the panelGroup component, where a background-image specified in the styleClass DOES NOT RENDER when deployed on the OAS. It works fine when I run the page on my local OC4J.
    I've verified that the image I use is deployed correctly on the server.
    We are using :
    JDeveloper Studio Edition: 10.1.3.3.0.4157 (Build JDEVADF_10.1.3.3.0_NT_070619.1129.4157)
    Oracle Application Server: 10.1.3.5.0 running on RHEL 5.
    I'm customizing pages of an ADF application to change the branding and skinning. The page header region used in the application uses a 'panelPageHeader' and the image I need to introduce is part of branding and must be rendered above the application menus (2 levels: 1->MenuTabs, 2-MenuBar).
    If it would help to see how my page renders locally, here's the link: http://tech-nik-alley.blogspot.com/2010/09/adf-panelgroups-background-image.html
    (The brightly colored bar above the menus is newly introduced, ABC_Lightbar.jpg).
    Using an objectImage with my light_bar image as source, directly in the facet menu2, causes the alignment of all pages to get disrupted. Hence the work-around of using the image as a background.
    A copy of my pageHeader region is below, with comments. The panelGroup component newly introduced is in the facet "menu2". I've added the CSS definitions in the page as comments as appropriate.
    Any pointers on how to debug further, work-arounds etc. are appreciated.
    TIA and regards
    Deepak.
    =====MY PAGE HEADER REGION====
    <af:regionDef var="attr">
    <af:panelPageHeader styleClass="ss0" > <!—ss0 is "padding:0px;margin-left:14%;margin-right:14%;margin-top:0px;margin-bottom:0px;display:block;background-color:transparent;" -->
    <f:facet name="branding">     
    <af:panelGroup styleClass="ss_brand"> <!--ss_brand is "display:block;margin-bottom:12px" -->
    <af:objectImage shortDesc="#{imageBean['SS_COMPANY_LOGO'].description}"
    source="#{imageBean['SS_COMPANY_LOGO'].physicalName}"/>
    </af:panelGroup>
    </f:facet>
    <f:facet name="menuGlobal" >
    <af:panelGroup layout="horizontal" styleClass="ss00" rendered="#{attr.globalMenuShown}">     <!—ss00 is "margin-right:10px;" -->
    <f:facet name="separator">
    <af:objectImage source="#{imageBean['SS_GLOBAL_SEPARATOR'].physicalName}" shortDesc=""/>
    </f:facet>
    <af:menuButtons>
    <af:goMenuItem text="#{sessionBean.authenticated?pageHeaderBean.loggedInUserInfo:messageBean.SS_GEN_GUEST}"/>
    </af:menuButtons>
    <af:menuButtons startDepth="0" var="menuGlobal" value="#{menuModel.model}">
    <f:facet name="nodeStamp">
    <af:goMenuItem text="#{menuGlobal.label}"
    destination="#{menuGlobal.fileName}"
    rendered="#{menuGlobal.type=='global' &amp;&amp; menuGlobal.rendered}"
    />
    </f:facet>
    </af:menuButtons>
    </af:panelGroup>
    </f:facet>
    <f:facet name="menu1" >
    </f:facet>
    <f:facet name="menu2" >     <!-- facet menu2 originally has a 'menuTabs' (level 1 menu) on top of a 'menuBar' (level 2 menu) -->
                        <!-- Change required: introduce a light_bar image above level 1 menu (menuTabs). The image spans the page -->
    <af:panelGroup rendered="#{skinFamily.menuLayout=='horizontal' and attr.otherMenuShown}">
         <!--Change: new panelGroup introduced, with a background image in the styleClass -->
    <af:panelGroup layout="vertical" styleClass="pageHeaderLightBar"> <!-- pageHeaderLightBar is "background-image:url(/ss/skin/ABC/images/ABC_lightbar.jpg); " -->
    <!--<af:objectImage source="/ss/skin/ABC/images/ABC_lightbar.jpg"/>-->     <!--Specifying the image directly, disrupts the all other OOTB pages-->
    <af:objectSpacer width="22px"/>
    </af:panelGroup>
    <af:panelGroup styleClass="pageHeaderMenuLevelOne"> <!-- Another place where a back-ground image is used for a panelGroup using the styleclass -->
    <af:menuTabs startDepth="0" var="menuTab" value="#{menuModel.model}">     <!-- The level 2 menu using menuTabs -->
    <f:facet name="nodeStamp">
    <af:goMenuItem text="#{menuTab.label}"
    destination="#{menuTab.fileName}"
    rendered="#{menuTab.rendered and menuTab.type!='global'}"/>
    </f:facet>
    </af:menuTabs>
    <af:menuBar startDepth="1" var="menuBar" value="#{menuModel.model}">     <!--The level 2 menu using a menuBar -->
    <f:facet name="nodeStamp">
    <af:goMenuItem text="#{menuBar.label}"
    destination="#{menuBar.fileName}"
    rendered="#{menuBar.rendered}" />
    </f:facet>
    </af:menuBar>
    </af:panelGroup>
    </af:panelGroup>
    </f:facet>
    </af:panelPageHeader>
    </af:regionDef>
    ===================================

    'background-image:url("../image/Sunset.jpg")' is a relative URL... relative to the final generated markup. It should be wrong like 99% of the times. You should rather use a styleClass and deal with the background-image with skinning as the skinning engines knows how to deal with such urls. Note that you'll most likely have to define a new resource loader and servlet mapping for the ResourceServlet. I know someone made a blog entry about that, was it Frank or Shay? Hmmm cannot remember... Maybe John as well. Anyway a Google search should yield good results for adf resource loader I think.
    Regards,
    ~ Simon

  • Problem with Background image and JFrame

    Hi there!
    I've the following problem:
    I created a JFrame with an integrated JPanel. In this JFrame I display a background image. Therefore I've used my own contentPane:
    public class MContentPane extends JComponent{
    private Image backgroundImage = null;
    public MContentPane() {
    super();
    * Returns the background image
    * @return Background image
    public Image getBackgroundImage() {
    return backgroundImage;
    * Sets the background image
    * @param backgroundImage Background image
    public void setBackgroundImage(Image backgroundImage) {
    this.backgroundImage = backgroundImage;
    * Overrides the painting to display a background image
    protected void paintComponent(Graphics g) {
    if (isOpaque()) {
    g.setColor(getBackground());
    g.fillRect(0, 0, getWidth(), getHeight());
    if (backgroundImage != null) {
    g.drawImage(backgroundImage,0,0,this);
    super.paintComponent(g);
    Now the background image displays correct. But as soon as I click on some combobox that is placed within the integrated JPanel I see fractals of the opened combobox on the background. When I minimize
    the Frame they disappear. Sometimes though I get also some fractals when resizing the JFrame.
    It seems there is some problem with the redrawing of the background e.g. it doesn't get redrawn as often as it should be!?
    Could anyone give me some hint, on how to achieve a clear background after clicking some combobox?
    Thx in advance

    I still prefer using a border to draw a background image:
    import java.awt.*;
    import java.awt.image.*;
    import javax.swing.border.*;
    public class CentredBackgroundBorder implements Border {
        private final BufferedImage image;
        public CentredBackgroundBorder(BufferedImage image) {
            this.image = image;
        public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
            int x0 = x + (width-image.getWidth())/2;
            int y0 = y + (height-image.getHeight())/2;
            g. drawImage(image, x0, y0, null);
        public Insets getBorderInsets(Component c) {
            return new Insets(0,0,0,0);
        public boolean isBorderOpaque() {
            return true;
    }And here is a demo where I load the background image asynchronously, so that I can launch the GUI before the image is done loading. Warning: you may find the image disturbing...
    import java.awt.*;
    import java.io.*;
    import java.net.URL;
    import javax.imageio.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class BackgroundBorderExample {
        public static void main(String[] args) throws IOException {
            JFrame.setDefaultLookAndFeelDecorated(true);
            JFrame f = new JFrame("BackgroundBorderExample");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JTextArea area = new JTextArea(24,80);
            area.setForeground(Color.WHITE);
            area.setOpaque(false);
            area.read(new FileReader(new File("BackgroundBorderExample.java")), null);
            final JScrollPane sp = new JScrollPane(area);
            sp.setBackground(Color.BLACK);
            sp.getViewport().setOpaque(false);
            f.getContentPane().add(sp);
            f.setSize(600,400);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
            String url = "http://today.java.net/jag/bio/JagHeadshot.jpg";
            final Border bkgrnd = new CentredBackgroundBorder(ImageIO.read(new URL(url)));
            Runnable r = new Runnable() {
                public void run() {
                    sp.setViewportBorder(bkgrnd);
                    sp.repaint();
            SwingUtilities.invokeLater(r);
    }

  • Background image not cached in browser

    Hi,
    Using JDeveloper 11g R1.
    We have a template, with a PanelGroupLayout component with a background image, like follows:
    <af:panelGroupLayout layout="horizontal"
    inlineStyle="width:100%; height:2px; background-image:url(&quot;images/separacioRalles.jpg&quot;); background-repeat:repeat-x;"
    id="pt_pgl5">
    In runtime, the request made by the browser includes and _adf.ctrl-state=xxxxxx parameter, which I supose causes the browser not checking the cache.
    image/jpeg     http://127.0.0.1:7101/ViewController-context-root/faces/images/separacioRalles.jpg?_adf.ctrl-state=1bn1yq032y_79
    Is there any way to avoid this _adf.ctrl-state? or another way to set the desired background?
    Thanks,
    Roger

    Hi Frank,
    Not working fine at all.
    I tried as you said:
    <af:panelGroupLayout layout="horizontal"
    inlineStyle="width:100%; height:2px; background-repeat:repeat-x; background-image:url(&quot;/images/separacioRalles.jpg&quot;);"
    id="pt_pgl5">
    and this is the request received on the server:
    127.0.0.1 - weblogic [28/ago/2009:10:39:58 +0200] "GET /images/separacioRalles.jpg HTTP/1.1" 404 1214
    Comparing with an af:image component:
    <af:image shortDesc="asdf"
    source="/images/help.gif" id="pt_i1"/>
    the request received on the server:
    127.0.0.1 - weblogic [28/ago/2009:10:39:58 +0200] "GET /ViewController-context-root/images/help.gif HTTP/1.1" 304 0
    If I put the contextroot in the background-image:url (background-image:url(&quot;/ViewController-context-root/images/separacioRalles.jpg&quot;), it works fine.
    127.0.0.1 - weblogic [28/ago/2009:10:44:28 +0200] "GET /ViewController-context-root/images/separacioRalles.jpg HTTP/1.1" 304 0
    So seems that the background image url is not built in the same way as using af:image component.
    Roger B

  • How to create a background image for each item in a List object

    Hello.
    I am trying to create a background image that displays whenever a user posts something to a list.  For example when a user posts text it would appear in a list.  The new item in the list would contain a specific background image with the users text appearing on top of the background image.  I do not want a background image for the entire list, rather each item within the list.
    I am not sure how clear this is so I added an image below.  When a user enters text in and clicks the "post-it" button their text would appear below with the sticky note background. 
    I am not sure which list type would be best for this problem or how to create insert the image, so I am open to suggestions. 
    Thank you for your help.  Any advice or guidance will be greatly appreciated!

    Hi
    the easiest way would be with itemRenderer.
    You have to do two things:
    1. In your list declaration use a item renderer: <mx:List itemRenderer="myRenderer"/>
    2. create a flex component myRenderer that will be the single item. This can be a canvas with a background image and a text field on it.
    When you add a new item to the list, a new myRenderer item will be created and the data property will be passed to it. So you have to put "data" in your textField.
    If you need more help try looking at Tour de Flex samples, they're pretty easy.
    Andrei

  • How to load a background Image on a JDialog object

    Hi All, Actually i am new to java programing and i am stuck in this problem. I am developing a java application which is dialog based (using JDialog objects) and i want to load a background image on my dialog. I hope this could be done and i really appreciate your help because i must deliver this project and this is a user interface requirement.

    Try something along the lines of this: Create a new class called BackgroundImagePanel and have it extend JPanel.
    Have an attribute in the class for your image, and a method to set it.
    Override isOpaque() to return true.
    Override the paintComponenet method as such:
    public void paintComponent (Graphics g) {
    super.paintComponent(g);
    if( image == null ) return;
    Icon icon = new ImageIcon(image);
    icon.paintIcon(this, g, x, y);
    Add this panel to your JDialog and then add other component to this panel.
    You might have to tweak this a bit, but it should get you close...
    Bill

  • How to insert a background image in VGroup in Flex Mobile

    I want to insert a background image for this VGroup. Help me out. I'm new to Flex !!
    I'm using this code in Flex Mobile Application
    <s:VGroup height="100%" width="100%"
              paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">   
        <s:List id="homeList" height="100%"
                labelField="title"
                dataProvider="{homeNews}">
            <s:layout>
                <s:TileLayout requestedColumnCount="1"
                              verticalGap="5"/>
            </s:layout>
            <s:itemRenderer>
                <fx:Component>
                    <s:ItemRenderer>
                        <s:VGroup>
                            <s:BitmapImage source="{data.source}"/>
                            <s:Label text="{data.title}" />
                        </s:VGroup>
                    </s:ItemRenderer>
                </fx:Component>
            </s:itemRenderer>
        </s:List>
    </s:VGroup>

    I don't think you can add a background image to a VGroup directly, nor can VGroup be skinned.
    As far as I am aware there are probably 2 solutions
    1) use a SkinnableContainer instead skin the container to have a background image and set its layout to VerticalLayout
    2) enclose the VGroup in a Group with a BasicLayout. you can then add a background image to the Group and overlay the VGroup

  • How to stretch background image, How to change show detail item header

    Hello all I have a few questions I would like to pose humbly to your collective wisdom, FYI I use Jdeveloper 11.1.3 and ADF Fusion
    First, how do I stretch the background Image? I have a background image in a show detail item but it is very small. 400 by 400. Thing is it's just a pic of the color red gradually moving from bright to dark in the image. So stretching it should not make it look horrible, but also repeating it makes it look silly, because you have 50 little images of dark red to bright red, instead of one big image of dark red to bright red. Can this be done and how?
    Secondly how do I change the header of the show detail item in a Panel Accordion? I have 8 Show detail items, in the middle of my page and the user can click and switch between which one is open, which makes for a nice effect, but I would like to give each of the show detail items a particular color. I did this with the backgrounds but I can't do it with the header, which are always visible, while only one background is visible at a time. I tried using the skinning technique but I wasn't able to change the header (I changed the background so the skinning was done correctly). I used
    af|panelAccordion::header
      color: blue;
      font-family: Arial, Helvetica, sans-serif;
      background: Maroon;
      background-color: Maroon;
    }Because I read in the Fusion Guide (or somewhere) that the show detail item cannot be skinned and therefore doesn't have a property like af panel Accordion.
    Can it though be achieved through some other means?
    Third when I drop the data control on the page and if I pick search form, why can't I use the CreateInsert button? Why can't I use the form to Create new rows? It keeps giving me some type of error, like Row is out of bounds or something? Is that some mistake with my database, or page, or is it not possible to do it like that?
    I welcome your words of guidance and also happy new year Huzzah!!!
    Edited by: Dino2dy on Jan 4, 2011 2:01 AM

    Thanks I haven't really had time to play around with this, as I have other concerns, but I do plan on coming back to it, and it is one of the things about ADF that really is bothersome. Creatively it means I can choose between 2 styles when making an app Blaf Rich and Fusion (the other ones are just worse versions of the two) while I will concede that the superb out of the box functionalities and things I can do declaratively probably mean I won't have a Dreamweaver type freedom of design I thought there might be a way to do some of these custom design changes.
    A few questions though
    When you skin the accordion are you able to propagate the changes to show detail item headers? Because that is one thing that I really want to change, just the color of the headers but I was unable to do so.
    Also there is a component that is not part of a panel accordion or panel tabbed called panel box. Again I changed the backgrounds to great effect but I need to change the panel header and in this I failed.
    Granted I used the css color attribute for both not a picture so maybe that is the reason. Just wondering if you succeeded.
    Cheers

  • Can't get rid of background image of toolbar buttons

    I am just a front-end developer and responsible for the front-end look of an ADF application that we are creating: We are using jDeveloper 11.1.1.4.0 (and we cannot upgrade due to being told no...so I cannot USE the skin editor which when I tried to use, migrates the files).
    I have created the necessary directories and files per tutorials I have been reading up on...
    skins directory - (new directory)
    skin.css (new file)
    Web-Inf -
    trinidad-skins.xml (new file and correctly configured)
    trinidad-config.xml (existing file but updated to use the new skin)
    Within the trinidad-skins.xml file I have the the new skin specified and is extending the "fusionFx-v1.desktop" default theme being used.
    Now the problem... I cannot get the background images to be overwritten or disabled for af|toolbar::item within the .css file
    I have looked up information about how to overwrite this and I tried to use the
    -tr-inhibit: background-image; within the .css declaration like this
    <code>
    af|toolbar::item {
    -tr-inhibit: background-image;
    </code>
    That was unsuccessful. I even just tried standard background {none;} and that was a no go as wel.
    What am I doing wrong here? This is driving me nuts... they made this skinning stuff way too complicated IMO. I don't see why I can't just add a class to the component within the property inspector of that component and then be able to reference it via normal css conventions... but nope BREAKS grrr... And I'm advanced level CSS coder! This stuff has me absolutely clueless and ready to just quit!
    Any suggestions or help is appreciated! And again... I cannot use the skin editor! Everytime I tried to, it prompted me to migrate the application and I cannot do this since there are about 5 other developers working on this application (we use clearcase for version control).
    Thanks,
    Michael

    I can't use the stand alone skin editor since it will want me to migrate the project files (developed in 11.1.1.4) and all files are source controlled via ClearCase.
    I have been experimenting...This is the code on the .jspx page
    <code>
    <af:panelGroupLayout id="header" styleClass="headerParent">
    <af:panelGroupLayout id="topLinkBar" layout="horizontal" styleClass="topLinkBar AFStretchWidth">
    <af:outputLabel value="#{customeradminportalviewcontrollerBundle.CUSTOMER_ACCOUNT}" styleClass="customerLabel"/>
    <af:outputText value="outputText2012" styleClass="customerOutput"/>
    <af:toolbox id="topLinkToolBox" styleClass="topLinkToolBox">
    <af:toolbar id="topLinkToolBar" styleClass="topLinkToolBar">
    <af:commandToolbarButton text="#{customeradminportalviewcontrollerBundle.HELP}" id="ctb2"/>
    <af:commandToolbarButton text="#{customeradminportalviewcontrollerBundle.POWER_INVOICE}" id="ctb1"/>
    <af:commandToolbarButton text="#{customeradminportalviewcontrollerBundle.CONTRACT}" id="ctb3"/>
    <af:commandToolbarButton text="#{customeradminportalviewcontrollerBundle.SIGNOUT}" id="ctb4"/>
    </af:toolbar>
    </af:toolbox>
    </af:panelGroupLayout>
    </af:panelGroupLayout>
    </code>
    Here is the CSS code
    <code>
    #topLinkToolBar af|commandToolbarButton {
    background-image: none;
    background-color: transparent;
    border: 0;
    </code>
    That WILL NOT get rid of the background images on the buttons! However if I do the !important hack within the CSS like this:
    <code>
    #topLinkToolBar af|commandToolbarButton {
    background-image: none!important;
    background-color: transparent!important;
    border: 0!important;
    </code>
    Then BOOM it works... I do NOT want to use the !important hack since that will cause problems in CSS inheritance and cascading...
    What am I doing wrong?
    Also how do I (if possible) target a specific ID used? For example the af:toolbar has an ID of "topLinkToolBar" how can I target that within the CSS? I know I can target it via class attribute like this:
    <code>
    af:toolbar.topLinkToolBar
    </code>
    but how would I do the same if I wanted to only apply to a component with a particular ID?
    Thank you everyone for all your patience, suggestions and help with this... I'm totally new to this type of environment and it's been a slow and frustrating learning experience!
    Michael

  • How to change background images in s:application

    hello!
    i want to make a webside by flex4 as  this web http://www.templatemonster.com/flash-cms-templates/29930.html
    But i don't know how to make change background images by click and make sound when load page.
    Can u help me ,please. sorry i write E not well.
    Thanks so much
    BUI THI PHUONG THANH- FROM VIETNAM

    Hi,
    please create a sink for your application inside that put your image.And apply that skin to your application on any click.
    Below is the code.
    Main Application
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/halo" xmlns:mx1="library://ns.adobe.com/flex/mx">
        <fx:Script>
            <![CDATA[
                protected function btn_click(evt:MouseEvent):void {
                    this.setStyle("skinClass", MySkinClass);
            ]]>
        </fx:Script>
        <s:Button label="Change BackGroundImage" click="btn_click(event);"/>
    </s:Application>
    MySkinClass
    <?xml version="1.0" encoding="utf-8"?>
    <s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx">
        <!-- host component -->
        <fx:Metadata>
            [HostComponent("spark.components.supportClasses.SkinnableComponent")]
        </fx:Metadata>
        <s:states>
            <s:State name="normal" />
            <s:State name="disabled" />
        </s:states>
        <s:BitmapImage source="@Embed('image1.jpg')"  smooth="true" left="0" right="0"  top="0" bottom="0"  />
    </s:Skin>
    with Regards,
    Shardul Singh Bartwal

  • Background Image on a Report Region

    Greetings,
    Is it possible to put a background image on a report region? Using the code shown below I can get an image on most other region types, but the code simply doesn't work on a report region.
    Thanks in advance for your help, Tony
    REGION HEADER
    <table width="100%" cellspacing="0" cellpadding="0" border="0" align="left"
    background = "#WORKSPACE_IMAGES#image.jpg">
    <tr height="500px" align="left" valign="top">
    <td>
    REGION FOOTER
    </td>
    </tr>
    </table>

    cloaked wrote:
    Greetings fac586,
    Been reading up on CSS's. I guess the main aspect is to determine the CSS component that deals with the Tabular Form in the Template I am using and modify it. I would need to modify the background attribute of the Tabular Fom, right?
    Gotta crawl before I walk, so I am also assuming that I would modify the CSS initially with a hard-coded background image. Then, if I get that to work I would make the image dynamic based on the criteria in a database. Am I on the right track?
    Is there a common attribute/component in the Apex Template CSS's for Tabular Forms? I've tried to find it, but am not sure what I'm looking for.Tabular forms can be created using any report template&mdash;built-in or custom&mdash;so the CSS will differ by theme and template.
    Yes, you can define background images for report templates, but It's not appropriate to do what you're trying to do at the report template level. Templates are static and defined at design-time. Challenging Apex Page - Grid with 100+ items - Suggestions Needed. This needs to be dynamic and determined at run-time.

  • Background image under a list

    Hello!
    I need to view a background image under a list.
    I've done this for a panel overriding the paint method but for a list it doesn't go.
    Can someone help me?
    Thanks

    I believe that my code is right..
    I extends List component and override the paint method.
    First, I draw the image, then I call the super method.
    Then, in a main method I add the list to a panel.
    Where I'm wrong?
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.List;
    import java.awt.Toolkit;
    public class ListBg extends List{
         private static final long serialVersionUID = 1L;
         Image image;
         public ListBg(){
              super();
              Toolkit toolkit = Toolkit.getDefaultToolkit();
         image = toolkit.getImage("C:/Programmi/image.jpg");
         public void print(Graphics g){
              g.drawImage(image,0,0,this);
              super.print(g);
    }

  • TextField on top of background image

    How can I put a textField on top of a background image with JSC?

    How can I put a textField on top of a background image with JSC?I believe that when you put a background image in JSC... everything else would go on top of the background image. You set the background image by selecting the Background Image property under the Appearance part of the Properties panel. There you can select the image you want to set as background.
    On the other hand, if you insert a separate image component instead of the background image... there you may have to tell your textField to go on top of the image. You do this by right-clicking the textField and selecting the Bring To Front option.
    Franklin Angulo

  • JMenuItem Background Image

    i am trying to put a background image for a JMenuItem (i am kinda adding skinning abilites to my application....)
    this is wut i have...
    public class MenuListItem extends JMenu {
      String text;
      public MenuListItem(String _text) {
        text = _text;
      public void paintComponent(Graphics g) {
        try {
          super.paintComponent(g);
          g.setColor(Color.WHITE);
          g.setFont(new Font("Arial", Font.PLAIN, 10));
          g.drawImage(GRAPHICS.getGraphics("Menu"), 0, 0, Color.WHITE, this);
          g.drawString(text, 32, 0); //starts at 32 cause im gonna to have an icon there...
        } catch(Exception e) {
          e.printStackTrace();
    }it draws the background image but not my text :( .... any ideas?
    ty

    Paint the image first, then call super.paintComponent(). Make sure the component is not opaque so the background doesn't draw in super.paintComponent()

Maybe you are looking for

  • Very frustrated with lack of customer service on rebate offer

    Back in August I upgraded my cable service with Comcast and became a new Verizon customer. I was informed of a rebate that paid back $50 on each smartphone purchased. Since I ordered the phones (iPhone 4) directly from the website and did not deal di

  • Lightning to 30-pin Adapter issues - flimsy and won't work with cases

    Anyone else having issues with the Lightning to 30-pin Adapter/Connectors? When applied to my Sony docking stations (numerous btw), the iPhone 5 barely rests securely on the connector AND the Lightning pin itself won't even fit or connect on the phon

  • In Ap invoice grid is showing no value when send for approval

    Dear Experts, There are 3-4 purchase invoice send for approval when it is open by approving authority the detail grid i.e. where the item details are shown is blank only gross total and net total in footer is showing value and header values. This all

  • Tax configuration

    hai everybody when ever i m trying to maintain record for tax type mwst it is giving an error called "tax code in taxinj is invalid" can anybody guide where i have to search to fix this and maintain taxes for my docs thank you so much

  • XML doc into Database?

    I was given a large xml document (300pgs), and I'd like to get all fo that data into an Access DB. Can anyone tell me if this is possible and give me some hints. I know Access is not preferred, but the client has set specifications. Thanks, Stephen