Skin is drawing on top of components

I have a skin with HostComponent of SkinnableContainer. It looks like this:
<s:BitmapImage source="@Embed(source='/img/skinGraphics/footer.png')" />
    <s:Group id="contentGroup">
    </s:Group>
The skinnable container looks like this:
<s:SkinnableContainer>
     <s:HGroup width="1000">
        <s:HGroup width="100%"  height="100%" top="4" horizontalAlign="left" id="leftBtnGroup"/>   
        <s:HGroup height="100%" top="4" horizontalAlign="right" id="rightBtnGroup" />
    </s:HGroup>
</s:SkinnableContainer>
I dynamically add some buttons to the leftBtnGroup and the rightBtnGroup and they are being drawn behind the footer.png image. What am I doing wrong?
Thanks..

The footer is contained within the main view UI like this:
<s:SkinnableContainer skinClass="skins.BPSApplicationSkinGrey">
        <s:layout>
            <s:VerticalLayout />
        </s:layout>
        <view:TitleBar theModuleTitle="{breadCrumbStr}" top="43" left="0"/>
        <views:TestView id="testView" includeIn="TestView"/>
        <views:TestBrowser id="testBrowser" includeIn="TestBrowser"/>
        <com:Footer id="footer" bottom="8"/>
    </s:SkinnableContainer>
The buttons are attached on the enterState() function of testBroswer.
public function enterState():void{
                btnDelete = new Button();
                btnDelete.setStyle("skinClass", skins.FooterButtonGreenSkin);
                btnDelete.addEventListener(MouseEvent.CLICK, deleteBtnClickHandler);
                parentDocument.footer.addLeftButton(btnDelete);
                btnDelete.label = "DELETE TEST";
public function addLeftButton(btn:Button):void{
                leftBtnGroup.addElement(btn);

Similar Messages

  • How can I draw on top of an image?

    I'm using a JApplet with three JPanel's inside of it.
    Inside one of those JPanel's I would like to place an image and a button. When the button is clicked, I want to draw an oval on top of the image . Each subsequent time the button is clicked, the oval will move to a different location.
    So here are my questions:
    1) What should I use to draw the image? (a JLabel with an ImageIcon on it?)
    2) Could I simply use g.drawOval() in paintComponent() to directly draw on top of the image/JLabel?
    Any help will be greatly appriciated.

    Here's a sample to study;-import java.awt.*;
    import java.awt.event.*;
    public class DrawOnImage extends java.applet.Applet{
      int xPos, yPos;
      Image img;
      public void init() {
        add(new Label("Hello World") );
        Button press = new Button("press");
        add(press);
        press.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e){
            xPos = (int)(Math.random()*270);
            yPos = (int)(Math.random()*170)+30;
            repaint();
        img = getImage(getDocumentBase(), "anImage.JPG");
      public void paint(Graphics g){
        g.drawImage(img,0,30,this);
        if(yPos>=30)g.fillOval(xPos, yPos, 45, 45);
    }

  • Draw on top of the system's Window Chrome?

    We'd like to use the system chrome for our desktop app, but we'd also like to be able to draw on top of it. We would like to show a button that prompts them to purchase the trial version of our software for example, or notify them that there is an update available. I don't want to use custom Chrome because we want whatever is there by default. We simply want to draw on top of it. Is that an option? My Googling and experiments have not yielded much!
    Many thanks for any help you can offer!

    You can uninstall your current Persona and revert to the Default theme (Tools > Add-ons > Themes).
    See [[Personas]] and http://kb.mozillazine.org/Themes (Lightweight theme)

  • Photo editor: fade a photo and draw on top of it?

    I want to "fade" JPG pictures of people and then draw on top of them with a brush tool to emphasize posture (for instructional purposes) and save as a JPG. By "fade" I mean lighten the pic so that my drawn lines will stand out.
    It appears that GIMP will do this. Can you also do that with SeaShore? In their documentation it is not clear to me; I get bogged down with tech lingo about layers and transparent colors and so on. My goal is to find a tool to do the above without getting something way more sophisticated than I need. Thanks for any help.
    Fran

    I'm not familar with GIMP, but I can shed some light onto the layers and transparency you would need to use.
    Layers are quite simple. They are like a stack of papers, you can see the page on top, and the page below if it sticks out beyond the edges of the top sheet. The same is true in photo programs. You will see the top layer, and things behind it will be obscured by the objects or images on the top layer.
    Transparency is the "fade" you are looking for. Note that Opacity is the opposite of transparency (as in 100% opaque is 0% transparent). My reducing transparency on a layer, you allow the layers behind it to become partially visible, IE you allow them to sneak through.
    To accomplish your goal, should should take the images, and fade them by reducing their opacity. I would start with reducing it to 70%, but you'll have to play with it to get things just right.
    After doing this, create a new layer, and be sure the new layer is on top off the image layer. In this new layer, take a brush tool and draw whatever you like. You should see you drawing ontop of the photo. If not, I suspect you have actually placed your line layer behind your photo layer, and you should simply trade their locations.
    Hope this helps,

  • Drawing on top

    Is it possible to layer a see through pane on top of my contents pane so that i can effectively draw on top of my current image without having to call paintComponent().
    how can i do it?

    from the desciption of panes glasspane seems to be what you want but i never have done anything with theese panes so don't count on it.

  • HOWTO: Draw on top of a JPanel without it beeing repainted?

    Hey,
    I have made a JPanel which draws some graphics with the use of the paintComponent() method. What I want now is a layer on top of this JPanel where I can draw a filled circle where the mousepointer is. How can this be achieved without the underlying JPanel beeing redrawn?
    - KHM

    Reminds me of The Glass Pane example
    http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html

  • Alarm status drawing iow: recolour JInternalFrame components

    Greetings,
    Please have a look at this picture. It's a low res snapshot of
    a few quite complicated components. Most of the functionality isn't
    visible nor relevant in the example. What you're looking at is a real time
    process of some sort. Things can go wrong in that process. In a previous
    version of my views I'd turn the background colour of some components
    red/yellow/green according to the 'alarm status' of the process. One of
    my customers suggested the idea of turning everything red/yellow/green
    inside those JInternalFrames (that's what you're looking at in the example).
    Of course one fool can ask more than a dozen of wise men can answer
    and I am not that wise, so my question is: how would one change the
    colour of all components that are part of a JInternalFrame (or any
    other container) such that the colour wouldn't be 100% opague but
    still visible by itself and still showing the information originally present
    in each individual component. iow, as if a transparent monochrome
    filter were positioned in front of that entire JContainer.
    In a naive way I like the idea; if the idea turns out to be too complicated
    to realize I'd be happy with visual alternatives also. (such as big arrows
    pointing to the JContainer where the alarm happened).
    Note that these appliations run in a 'factory' environment where people
    either hardly watch the screens or they watch them at quite a great
    distance. The changing colours should just attract their attention so they
    will walk/run/drive/ride to the screens for a second inspection.
    Any ideas are appreciated.
    kind regards,
    Jos

    Not sure I understand the question, but I keyed in on:
    as if a transparent monochrome filter were positioned in front of that entire JContainer.So maybe you could use a GlassPane:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class GlassPaneTest extends JFrame
        public GlassPaneTest()
            final JComponent glassPane = new JComponent()
                public void paintComponent(Graphics g)
                    g.setColor( getBackground() );
                    g.fillRect(0, 0, getSize().width, getSize().height);
            glassPane.setOpaque( false );
            glassPane.setBackground( new Color(240, 20, 20, 100) );
            setGlassPane( glassPane );
            glassPane.addKeyListener( new KeyAdapter()
                public void keyPressed(KeyEvent e)
                    e.consume();
            glassPane.addMouseListener( new MouseAdapter()
                public void mousePressed(MouseEvent e)
                    e.consume();
            final JButton button = new JButton( "Click Me" );
            button.setMnemonic('c');
            button.addActionListener( new ActionListener()
                public void actionPerformed(ActionEvent e)
                       glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                       glassPane.setVisible( true );
                       glassPane.requestFocus();
                       Thread thread = new Thread()
                            public void run()
                                try { this.sleep(5000); }
                                catch (InterruptedException ie) {}
                                 glassPane.setVisible( false );
                                 glassPane.setCursor(null);
                    thread.start();
            getContentPane().add(new JLabel("NORTH"), BorderLayout.NORTH );
            getContentPane().add( button );
            getContentPane().add(new JTextField(), BorderLayout.SOUTH);
        public static void main(String[] args)
            GlassPaneTest frame = new GlassPaneTest();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.setSize(300, 300);
            frame.setLocationRelativeTo( null );
            frame.setVisible(true);
    }The Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html]How to Use Glass Panes shows how you can also do a simple drawing (your arrow?) on the glass pane.

  • Any App for Drawing on top of iMovie film?

    Hi,
    im trying to find an app or some software for Imovie which could allow me to draw with my mouse on to my moving films. Ive seen the FX used in adverts and music videos where flowers for example grow up buildings and are animated , coming to life over the actual film itself. Its not a cartoonr app but something obviusly a bit more advanced. Any ideas. It dosent even have to be for Imovie really I just want to source this product.
    I want to make a music video and be able to draw things over me as if Im being covered in drawing.

    If you want to draw something on top the image in your component then
    simply call Graphics.drawImage() before drawing shapes in the same paing method.
    If you want to produce copy of image with some text drawn on top of it
    then you have to get Graphics from the image (BufferedImage.getGraphics())
    and use it to draw shapes/text.
    Easiest way to load/save image from BufferedImage is to use ImageIO.

  • Drawing on top of a component

    Hi there.
    if I have JPanel that contains a JLabel that contains is a 600x800 image, how can i draw a shape like circle on top of the image? I would like to be able to see the image with the circle on it. How can i make this possible?
    Right now i can draw the circle on its own JPanel, but that is not what i want.
    Thanks

    Notably, that you have a inner class referencing
    image variables defined in the class it's nested in.Inner classes can access all members of the declaring class,
    even private members. In fact, the inner class itself is said to be
    a member of the class; therefore, following the rules of
    object-oriented engineering, it should have access to all
    members of the class.
    The inner class does nothing to set it's own size,
    , since as far as that JLabel instance knows, it
    contains nothing.
    But this is not corrected, it's
    only relying on the BorderLayout to fill the frame
    with the label.
    While your sample works fine as is, it's not very
    portable. As the OP posted after, he attempted to
    use your code adding a JPanel in between the content
    pane and the label, and it wouldn't work because of
    the layout issues. To solve that, one might tend
    towards defining a null layout and setting the bounds
    explicitly, or one might add a setMinimumSize or
    setPreferredSize call to get a size.
    But that's adding more code to fix a problem that has
    a much simpler solution. Which is to just give the
    label the image directly, let the label size itself
    automatically based on that image, let the label draw
    the image itself and only override paint to get the
    custom drawing done on top.
    Myself, I understand what you were saying in your
    code. But clearly the OP did not, and I suspect was
    heading to starting patching what wasn't working by
    applying more code when one could more cleanly use
    less code and take advantage of what JLabel will
    already do for you.Agreed. But this problem can also be easily solved with "setPreferredSize(new Dimension(200,200));" in the constructor of "Picture".

  • Drawing on top of a gif image.

    I need to be able to have a JPanel that holds a .gif image, have another JPanel over top of it that can be drawn upon. An example of this is placing a map on a table and laying a piece of clear plastic over top of it, then drawing on the plastic the route you want to take. Just as in this example, I want to be able to erase lines on the top image, but I can probably figure that part out OK, I just need the code to layer the drawing panel on top on the image.
    How can this be done?
    Thanks.

    Exactly what problem are you having with getting a layered pane? The Java Tutorial on this site can give you all the basics regarding setting one up.

  • How to get Border to draw only top and bottom?

    Does anyone know a way to get a Border to only draw on specific sides? i.e. create an EtchedBorder, then only have it draw the border on the top and bottom?

    You can easily make your own border class and draw it yourself. Open up the source for Etched Border, copy it to your own border class, then modify it. That is legal to do. Then, you can provide the ability to allow the sides to be painted as options to your class. It is actually pretty easy to do.

  • Drawing on top camera view

    i just begining to create an application for mobile phone. Im have tried to put the camera preview (VideoControl) on GameCanvas.
    but i can't draw something else on top of the preview window because it is always covered by the preview.
    So, how can i do that? How can i draw something else on top of the camera preview?
    TiA

    but i want it stay visible... so it seems impossible... am i right?
    and another question : i can't get a snapshot if the controller is invisible? is there anyway to get a snapshot while the controller (the camera preview) is invisible???
    TiA

  • Drawing on top of an image

    Hello!
    I am trying to create a Panel on which I can draw stuff using the mouse. I have managed to get it working, apart from one small part. I want to have an image (jpg) as a background, and as soon as I try to add an image either the image does not show or the drawing stuff stops working.
    Here is my working drawing code (i.e. without image):
    public void paintComponent(Graphics g) {
             super.paintComponent(g);
             if (image == null || image.getWidth(null) != getWidth()
                   || image.getHeight(null) != getHeight()) {
                image = (BufferedImage) createImage(getWidth(), getHeight());
                graph = (Graphics2D) image.getGraphics();
                graph.fillRect(0, 0, getWidth(), getHeight());
                graph.setColor( Color.white );
                graph.setStroke(new BasicStroke(3));
                graph.addRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                      RenderingHints.VALUE_ANTIALIAS_ON));
             Rectangle r = g.getClipBounds();
             g.drawImage(image, r.x, r.y, r.x + r.width, r.y + r.height, r.x, r.y,
                   r.x + r.width, r.y + r.height, null);
             if (endPoint != null) {
                g.setColor(currentColor);
                if (shapeType == 0)
                   g.drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y);
                if (shapeType == 1)
                   g.drawOval(pn.x, pn.y, pn.width, pn.height);
                if (shapeType == 2)
                   g.drawRect(pn.x, pn.y, pn.width, pn.height);
             public void mouseDragged( MouseEvent m ) {
                if (shapeType > 3 && shapeType != 8)
                   return;
                if (endPoint == null)
                   endPoint = new Point();
                repaint(pn.x, pn.y, pn.width + 1, pn.height + 1);
                pn.x = Math.min(startPoint.x, m.getX());
                pn.y = Math.min(startPoint.y, m.getY());
                pn.width = Math.abs(m.getX() - startPoint.x);
                pn.height = Math.abs(m.getY() - startPoint.y);
                if (shapeType == 0) {
                   endPoint.setLocation(m.getPoint().getLocation());
                if (shapeType == 3) {
                   graph.setColor(currentColor);
                   graph.drawLine(startPoint.x, startPoint.y, m.getX(), m.getY());
                   startPoint = m.getPoint();
                repaint(pn.x, pn.y, pn.width + 1, pn.height + 1);
             public void mouseReleased(MouseEvent m) {
                if (endPoint != null)
                   draw();
                endPoint = null;
             public void mousePressed(MouseEvent m) {
                startPoint = m.getPoint();
             public void draw() {
                graph.setColor(currentColor);
                if (shapeType == 0)
                   graph.drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y);
                if (shapeType == 1)
                   graph.drawOval(pn.x, pn.y, pn.width, pn.height);
                if (shapeType == 2)
                   graph.draw(pn);
                repaint(pn.x, pn.y, pn.width + 1, pn.height + 1);
             }To me it seemed logical to add:
    graph.drawImage(my_gif, 0, 0, this);at the end of the if statement, but that did not work.
    Where and how should I add the image?
    Thanks!

    Thanks for answering!
    Here is the entire code:
    import java.awt.BasicStroke;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.Point;
    import java.awt.Rectangle;
    import java.awt.RenderingHints;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.image.BufferedImage;
    import javax.swing.JApplet;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    @SuppressWarnings("serial")
    public class ImageExample extends JApplet {
       private static final Dimension DRAWING_AREA_SIZE = new Dimension(300,300);
       private static final Point DRAWING_AREA_UPPER_LEFT = new Point(100,50);
       private static final Color BACKGROUND_COLOR = Color.black;
       private Image my_gif;
       private Color currentColor = Color.white;
       private JLabel currentColorIndicator;
       private JPanel pane = new JPanel(null);
       Point startPoint, endPoint;
       Rectangle pn = new Rectangle();
       BufferedImage image;
       Graphics2D graph;
       int shapeType = 3;
       public void init() {
          setContentPane(pane);
          my_gif = getImage( getDocumentBase(), "fractal.gif" );
          pane.setOpaque(true);
          pane.setBackground(BACKGROUND_COLOR);
          createColorMap();
          DrawingPanel drawingPanel = new DrawingPanel();
          drawingPanel.setBounds(DRAWING_AREA_UPPER_LEFT.x, DRAWING_AREA_UPPER_LEFT.y, DRAWING_AREA_SIZE.width,
                DRAWING_AREA_SIZE.height);
          pane.add(drawingPanel);
       // Private methods
       private void createColorMap() {
          ColorPickerListener listener = new ColorPickerListener();
          JLabel colorText = new JLabel("Color");
          colorText.setBounds(10, DRAWING_AREA_UPPER_LEFT.y-20, 50, 25);
          colorText.setForeground(Color.white);
          pane.add(colorText);
          JLabel redColor = new JLabel("");
          redColor.addMouseListener(listener);
          redColor.setBackground(Color.RED);
          redColor.setBounds(10, DRAWING_AREA_UPPER_LEFT.y+10, 50, 30);
          redColor.setOpaque(true);
          pane.add(redColor);
          JLabel blueColor = new JLabel("");
          blueColor.addMouseListener(listener);
          blueColor.setBackground(Color.blue);
          blueColor.setBounds(10, DRAWING_AREA_UPPER_LEFT.y+40, 50, 30);
          blueColor.setOpaque(true);
          pane.add(blueColor);
          JLabel whiteColor = new JLabel("");
          whiteColor.addMouseListener(listener);
          whiteColor.setBackground(Color.white);
          whiteColor.setBounds(10, DRAWING_AREA_UPPER_LEFT.y+70, 50, 30);
          whiteColor.setOpaque(true);
          pane.add(whiteColor);
          JLabel greenColor = new JLabel("");
          greenColor.addMouseListener(listener);
          greenColor.setBackground(Color.green);
          greenColor.setBounds(10, DRAWING_AREA_UPPER_LEFT.y+100, 50, 30);
          greenColor.setOpaque(true);
          pane.add(greenColor);
          JLabel blackColor = new JLabel("");
          blackColor.addMouseListener(listener);
          blackColor.setBackground(Color.black);
          blackColor.setBounds(10, DRAWING_AREA_UPPER_LEFT.y+130, 50, 30);
          blackColor.setOpaque(true);
          pane.add(blackColor);
          JLabel grayColor = new JLabel("");
          grayColor.addMouseListener(listener);
          grayColor.setBackground(Color.gray);
          grayColor.setBounds(10, DRAWING_AREA_UPPER_LEFT.y+160, 50, 30);
          grayColor.setOpaque(true);
          pane.add(grayColor);
          JLabel yellowColor = new JLabel("");
          yellowColor.addMouseListener(listener);
          yellowColor.setBackground(Color.yellow);
          yellowColor.setBounds(10, DRAWING_AREA_UPPER_LEFT.y+190, 50, 30);
          yellowColor.setOpaque(true);
          pane.add(yellowColor);
          // Display currently chosen color
          JLabel currentColorText = new JLabel("Current");
          currentColorText.setBounds(10, DRAWING_AREA_UPPER_LEFT.y+230, 50, 25);
          currentColorText.setForeground(Color.white);
          pane.add(currentColorText);
          currentColorIndicator = new JLabel("");
          currentColorIndicator.setBounds(10, DRAWING_AREA_UPPER_LEFT.y+260, 50, 30);
          updateCurrentColorLabel();
          currentColorIndicator.setOpaque(true);
          pane.add(currentColorIndicator);
       private void updateCurrentColorLabel() {
          currentColorIndicator.setBackground(currentColor);
          currentColorIndicator.setForeground(new Color(255 - currentColor.getRed(), 255 - currentColor.getGreen(),
                255 - currentColor.getBlue()));
       // Private classes
       private class DrawingPanel extends JPanel implements MouseListener, MouseMotionListener {
          BufferedImage image;
          public DrawingPanel() {
             addMouseMotionListener(this);
             addMouseListener(this);
          public void paintComponent(Graphics g) {
             super.paintComponent(g);
             if (image == null || image.getWidth(null) != getWidth()
                   || image.getHeight(null) != getHeight()) {
                image = (BufferedImage) createImage(getWidth(), getHeight());
                graph = (Graphics2D) image.getGraphics();
                graph.fillRect(0, 0, getWidth(), getHeight());
                graph.setColor( Color.white );
                graph.setStroke(new BasicStroke(3));
                graph.addRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                      RenderingHints.VALUE_ANTIALIAS_ON));
                graph.drawImage(my_gif, 0, 0, this);
                System.out.println(my_gif + " <- my_gif");
                System.out.println(my_gif.getWidth(this) + " <- my_gif.getWidth(this)");
                System.out.println(my_gif.getHeight(this) + " <- my_gif.getheight(this)");
             Rectangle r = g.getClipBounds();
             g.drawImage(image, r.x, r.y, r.x + r.width, r.y + r.height, r.x, r.y,
                   r.x + r.width, r.y + r.height, null);
             if (endPoint != null) {
                g.setColor(currentColor);
                if (shapeType == 0)
                   g.drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y);
                if (shapeType == 1)
                   g.drawOval(pn.x, pn.y, pn.width, pn.height);
                if (shapeType == 2)
                   g.drawRect(pn.x, pn.y, pn.width, pn.height);
             public void mouseDragged( MouseEvent m ) {
                if (shapeType > 3 && shapeType != 8)
                   return;
                if (endPoint == null)
                   endPoint = new Point();
                repaint(pn.x, pn.y, pn.width + 1, pn.height + 1);
                pn.x = Math.min(startPoint.x, m.getX());
                pn.y = Math.min(startPoint.y, m.getY());
                pn.width = Math.abs(m.getX() - startPoint.x);
                pn.height = Math.abs(m.getY() - startPoint.y);
                if (shapeType == 0) {
                   endPoint.setLocation(m.getPoint().getLocation());
                if (shapeType == 3) {
                   graph.setColor(currentColor);
                   graph.drawLine(startPoint.x, startPoint.y, m.getX(), m.getY());
                   startPoint = m.getPoint();
                repaint(pn.x, pn.y, pn.width + 1, pn.height + 1);
             public void mouseReleased(MouseEvent m) {
                if (endPoint != null)
                   draw();
                endPoint = null;
             public void mousePressed(MouseEvent m) {
                startPoint = m.getPoint();
             public void draw() {
                graph.setColor(currentColor);
                if (shapeType == 0)
                   graph.drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y);
                if (shapeType == 1)
                   graph.drawOval(pn.x, pn.y, pn.width, pn.height);
                if (shapeType == 2)
                   graph.draw(pn);
                repaint(pn.x, pn.y, pn.width + 1, pn.height + 1);
             public void mouseClicked(MouseEvent arg0) {}
             public void mouseEntered(MouseEvent arg0) {         }
             public void mouseExited(MouseEvent arg0) {         }
             public void mouseMoved(MouseEvent arg0) {         }
       //Listeners
       private class ColorPickerListener extends MouseAdapter {
          public void mouseClicked(MouseEvent e) {
             JLabel color = (JLabel) e.getSource();
             currentColor = color.getBackground();
             updateCurrentColorLabel();
    }So the problem might be that the system.outs in there put out:
    sun.awt.image.ToolkitImage@1a0c10f <- my_gif
    -1 <- my_gif.getWidth(this)
    -1 <- my_gif.getheight(this)I don't know how to fix so that the height and width are set. Isn't it enough to do the:
          my_gif = getImage( getDocumentBase(), "fractal.gif" );before initializing the drawing panel?
    Thanks again!

  • How to draw line to connect components dynamically??

    Dear Friends:
    I have following code is for drag/drop label, I hope to draw straight line to connect any TWO or more labels within this panel,
    [1]. keep all connected line
    [2]. can draw dynamically,
    I search quite a while with google, still very confused,
    Can any guru throw aome light how to do
    [1]. code 1:
    package swing.dnd;
    import java.awt.*;
    import javax.swing.*;
    public class TestDragComponent extends JFrame {
         public TestDragComponent() {
              super("Test");
              Container c = getContentPane();
              c.setLayout(new GridLayout(1,2));
              c.add(new MoveableComponentsContainer());
              c.add(new MoveableComponentsContainer());
              pack();
              setVisible(true);
         public static void main(String[] args) {
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              catch (Exception ex) {
                   System.out.println(ex);
              new TestDragComponent();
    [2]. Code 2:
    package swing.dnd;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import java.awt.dnd.*;
    import java.awt.datatransfer.*;
    import java.awt.image.*;
    import java.awt.dnd.DragSource;
    import java.awt.dnd.DropTarget;
    public class MoveableComponentsContainer extends JPanel {     
         public DragSource dragSource;
         public DropTarget dropTarget;
         private static BufferedImage buffImage = null; //buff image
         private static Point cursorPoint = new Point();
         public MoveableComponentsContainer() {
              setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.white, Color.gray));
              setLayout(null);
              dragSource = new DragSource();
              ComponentDragSourceListener tdsl = new ComponentDragSourceListener();
              dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, new ComponentDragGestureListener(tdsl));
              ComponentDropTargetListener tdtl = new ComponentDropTargetListener();
              dropTarget = new DropTarget(this, DnDConstants.ACTION_MOVE, tdtl);
              setPreferredSize(new Dimension(400,400));
              addMoveableComponents();
         private void addMoveableComponents() {
              MoveableLabel lab = new MoveableLabel("label 1");
              add(lab);
              lab.setLocation(10,10);
              lab = new MoveableLabel("label 2");
              add(lab);
              lab.setLocation(40,40);
              lab = new MoveableLabel("label 3");
              add(lab);
              lab.setLocation(70,70);
              lab = new MoveableLabel("label 4");
              add(lab);
              lab.setLocation(100,100);
         final class ComponentDragSourceListener implements DragSourceListener {
              public void dragDropEnd(DragSourceDropEvent dsde) {
              public void dragEnter(DragSourceDragEvent dsde)  {
                   int action = dsde.getDropAction();
                   if (action == DnDConstants.ACTION_MOVE) {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
                   else {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
              public void dragOver(DragSourceDragEvent dsde) {
                   int action = dsde.getDropAction();
                   if (action == DnDConstants.ACTION_MOVE) {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
                   else {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
              public void dropActionChanged(DragSourceDragEvent dsde)  {
                   int action = dsde.getDropAction();
                   if (action == DnDConstants.ACTION_MOVE) {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
                   else {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
              public void dragExit(DragSourceEvent dse) {
                 dse.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
         final class ComponentDragGestureListener implements DragGestureListener {
              ComponentDragSourceListener tdsl;
              public ComponentDragGestureListener(ComponentDragSourceListener tdsl) {
                   this.tdsl = tdsl;
              public void dragGestureRecognized(DragGestureEvent dge) {
                   Component comp = getComponentAt(dge.getDragOrigin());
                   if (comp != null && comp != MoveableComponentsContainer.this) {
                        cursorPoint.setLocation(SwingUtilities.convertPoint(MoveableComponentsContainer.this, dge.getDragOrigin(), comp));
                        buffImage = new BufferedImage(comp.getWidth(), comp.getHeight(), java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE);//buffered image reference passing the label's ht and width
                        Graphics2D graphics = buffImage.createGraphics();//creating the graphics for buffered image
                        graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));     //Sets the Composite for the Graphics2D context
                        boolean opacity = ((JComponent)comp).isOpaque();
                        if (opacity) {
                             ((JComponent)comp).setOpaque(false);                         
                        comp.paint(graphics); //painting the graphics to label
                        if (opacity) {
                             ((JComponent)comp).setOpaque(true);                         
                        graphics.dispose();
                        remove(comp);
                        dragSource.startDrag(dge, DragSource.DefaultMoveDrop , buffImage, cursorPoint, new TransferableComponent(comp), tdsl);     
                        revalidate();
                        repaint();
         final class ComponentDropTargetListener implements DropTargetListener {
              private Rectangle rect2D = new Rectangle();
              Insets insets;
              public void dragEnter(DropTargetDragEvent dtde) {
                   Point pt = dtde.getLocation();
                   paintImmediately(rect2D.getBounds());
                   rect2D.setRect((int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),buffImage.getWidth(),buffImage.getHeight());
                   ((Graphics2D) getGraphics()).drawImage(buffImage,(int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),MoveableComponentsContainer.this);
                   dtde.acceptDrag(dtde.getDropAction());
              public void dragExit(DropTargetEvent dte) {
                   paintImmediately(rect2D.getBounds());
              public void dragOver(DropTargetDragEvent dtde) {
                   Point pt = dtde.getLocation();
                   paintImmediately(rect2D.getBounds());
                   rect2D.setRect((int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),buffImage.getWidth(),buffImage.getHeight());
                   ((Graphics2D) getGraphics()).drawImage(buffImage,(int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),MoveableComponentsContainer.this);
                   dtde.acceptDrag(dtde.getDropAction());
              public void dropActionChanged(DropTargetDragEvent dtde) {
                   Point pt = dtde.getLocation();
                   paintImmediately(rect2D.getBounds());
                   rect2D.setRect((int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),buffImage.getWidth(),buffImage.getHeight());
                   ((Graphics2D) getGraphics()).drawImage(buffImage,(int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),MoveableComponentsContainer.this);
                   dtde.acceptDrag(dtde.getDropAction());
              public void drop(DropTargetDropEvent dtde) {
                   try {
                        paintImmediately(rect2D.getBounds());
                        int action = dtde.getDropAction();
                        Transferable transferable = dtde.getTransferable();
                        if (transferable.isDataFlavorSupported(TransferableComponent.COMPONENT_FLAVOR)) {
                             Component comp = (Component) transferable.getTransferData(TransferableComponent.COMPONENT_FLAVOR);
                             Point location = dtde.getLocation();
                             if (comp == null) {
                                  dtde.rejectDrop();
                                  dtde.dropComplete(false);
                                  revalidate();
                                  repaint();
                                  return;                              
                             else {                         
                                  add(comp, 0);
                                  comp.setLocation((int)(location.getX()-cursorPoint.getX()),(int)(location.getY()-cursorPoint.getY()));
                                  dtde.dropComplete(true);
                                  revalidate();
                                  repaint();
                                  return;
                        else {
                             dtde.rejectDrop();
                             dtde.dropComplete(false);
                             return;               
                   catch (Exception e) {     
                        System.out.println(e);
                        dtde.rejectDrop();
                        dtde.dropComplete(false);
    Thanks so much for any help.
    Reagrds
    sunny

    Craig Wood's code here might do what you want
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=015259

  • [svn:fx-trunk] 5170: Round 2 of bug fixes for the Spark skins for Halo components.

    Revision: 5170
    Author: [email protected]
    Date: 2009-03-04 17:50:32 -0800 (Wed, 04 Mar 2009)
    Log Message:
    Round 2 of bug fixes for the Spark skins for Halo components. Thanks to Alex for help with the data grid issues.
    Bugs fixed:
    SDK-19655 - Setting rowCount property on DataGrid causes extra blank row to be displayed
    SDK-19652 - Items in a DataGrid do not line up after scrolling.
    SDK-19605 - disabled Halo ColorPicker with Gumbo skin draws too dark
    SDK-19596 - When you have a single button on an Alert, the left edge looks flatter than the right
    SDK-19585 - Menus compiled with the halo theme in Flex 4 have a different backgroundColor than in Flex 3
    SDK-19665 - Halo List with Gumbo skin doesnt draw the alternating item color all the way to the right edge of the control if VScrollBar is present
    SDK-19651 - odd header rendering issue on Halo DataGrid with Gumbo skin
    QA Notes: The alert layout code was positioning the buttons/text on sub-pixel boundaries if the width or height of the alert was an odd number of pixels. We always snap to pixel boundaries now, but this may cause bitmap compare issues with Alert.
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-19655
    http://bugs.adobe.com/jira/browse/SDK-19652
    http://bugs.adobe.com/jira/browse/SDK-19605
    http://bugs.adobe.com/jira/browse/SDK-19596
    http://bugs.adobe.com/jira/browse/SDK-19585
    http://bugs.adobe.com/jira/browse/SDK-19665
    http://bugs.adobe.com/jira/browse/SDK-19651
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/DataGrid.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/alertClasses/AlertForm.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/core/ScrollControlBase.as
    flex/sdk/trunk/frameworks/projects/halo/defaults.css
    flex/sdk/trunk/frameworks/projects/sparkskins/src/mx/skins/spark/ColorPickerSkin.mxml

Maybe you are looking for

  • Mini DisplayPort to Dual-Link DVI Adapter

    Hi, I am using the Apple Mini DisplayPort to Dual-Link DVI adapter to connect my 30" Apple Cinema Display (Aluminum) to my MacBook Pro 13" Retina, I am passing through the Belkin Thunderbolt Dock, so I connect the Dock to the MBP via the Thunderbolt

  • Free Gift Code I received yesterday with purchase is expired!!!!

    I Just bought the special U2 ipod. It's supposed to come with "exclusive" U2 content.... I'm very irritated because the "exclusive" content turns out to actually be a Gift Card for a free video download from the iTunes store. On the bottom of the car

  • Snote-Urgent

    Hi All, 1.pls what is the importance of the Snote? 2.how do we use perticular snote for user-exits to devleop a object? Regards M.Srinivas,

  • Iphoto mountain lion untitled

    Hi After upgrading to Moutain Lion a few days ago, I am noticing that I have many duplicate photos in my library now. Sometimes up to 5 copies of the same photo. They are mostly titled "untitled" instead of their correct IMG_5654 for example. I have

  • Audition 5.5 with Premiere CS5

    I have production Premium CS5 installed on my Windows 7 machine.  I have just installed Audition 5.5 and the Edit in Audition command is greyed out in Premiere.  Is there any way to make Premiere recognise Audition 5.5 or do I have to do and export/i