Drop Icons or labels into a panel

I am trying to build an applet where labels with icons are draggable and can be dropped in a panel at the bottom of an applet. Eventually, depending on the shapes of the icons dropped, that shape will be painted into a canvas on the same applet. But for now I need to figure out a way to enable the drop capability to a swing container. Preferably, a jEditorPane. Is that possible?
Anyone?

[url http://java.sun.com/developer/JDCTechTips/2003/tt0318.html#1]DRAGGING TEXT AND IMAGES WITH SWING

Similar Messages

  • Mac: can I drag and drop files from Finder into Files panel

    I am relatively new to Mac so forgive me if this is obvious.
    I just switched from Windows to Mac and now something I used to
    know how to do in Windows I can't figure out how to do on Mac. In
    Windows I used to open an Explorer window over Dreamweaver, select
    some files, and drap and drop them into the Files panel in
    Dreamweaver, and they would be sucked in.
    Now on the Mac whenever I select the Finder window to select
    files to drag and drop, the Dreamweaver panels disappear
    completely, rather than just move beneath the Finder window. So
    when I'm ready to drag and drop there's no Dreamweaver to drop
    into. I see that if I put focus on Dreamweaver, then Finder won't
    disappear, and I can click on Finder to begin a drag without
    Dreamweaver disappearing but then it is unresponsive to a drop.
    In short, I can't seem to drag and drop files from Finder
    into Dreamweaver on the Mac. Am I missing something? I'm using
    Dreamweaver CS3 on Leopard if that makes any difference.
    Thanks,
    Jan

    I don't believe you can do this on the Mac platform. The only
    other thing you could try is to use Spaces and have the Finder open
    in one Space and then drag it over to Dreamweaver in another space.
    Outside of that I can't think of how this would work.

  • How to drag image in left panel then drop into right panel??

    Dear friends.
    I have following code, it is runnable, just add two jpg image files is ok, to run.
    I tried few days to drag image from left panel then drop into right panel or vice versa, but not success, can any GUI guru help??
    Thanks.
    Sunny
    [1]. main code/calling code:
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class ImagePanelCall extends JComponent {
         public  JSplitPane ImagePanelCall() {
              setPreferredSize(new Dimension(1200,300));
              JSplitPane          sp = new JSplitPane();
              sp.setPreferredSize(new Dimension(1200,600));
              sp.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
              add(sp);
              ImagePanel     ip = new ImagePanel();
              ImagePanel     ip1 = new ImagePanel();
              ip.setPreferredSize(new Dimension(600,300));
              ip1.setPreferredSize(new Dimension(600,300));
              sp.setLeftComponent(ip);// add left part
              sp.setRightComponent(ip1);// add right part
              sp.setVisible(true);
              return sp;
         public static void main(String[] args) {
              JFrame frame = new JFrame("Test transformable images");
              ImagePanelCall  ic = new ImagePanelCall();
              frame.setPreferredSize(new Dimension(1200,600));
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.getContentPane().add(ic.ImagePanelCall(), BorderLayout.CENTER);
              frame.pack();
              frame.setVisible(true);
    }[2]. code 2
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class ImagePanel extends JComponent {
         private static final Cursor DEFAULT_CURSOR = new Cursor(Cursor.DEFAULT_CURSOR);
         private static final Cursor MOVE_CURSOR = new Cursor(Cursor.MOVE_CURSOR);
         private static final Cursor VERTICAL_RESIZE_CURSOR = new Cursor(Cursor.N_RESIZE_CURSOR);
         private static final Cursor HORIZONTAL_RESIZE_CURSOR = new Cursor(Cursor.W_RESIZE_CURSOR);
         private static final Cursor NW_SE_RESIZE_CURSOR = new Cursor(Cursor.NW_RESIZE_CURSOR);
         private static final Cursor NE_SW_RESIZE_CURSOR = new Cursor(Cursor.NE_RESIZE_CURSOR);
         public Vector images;
         * Create an ImagePanel with two images in.
         * A MouseHandler instance is added as mouse listener and mouse motion listener.
         public ImagePanel() {
              images = new Vector();
              images.add(new TransformableImage("swing/dnd/Bird.gif"));
              images.add(new TransformableImage("swing/dnd/Cat.gif"));
              setPreferredSize(new Dimension(600,600));
              MouseHandler mh = new MouseHandler();
              addMouseListener(mh);
              addMouseMotionListener(mh);
         * Simply paint all the images contained in the Vector images, calling their method draw(Graphics2D, ImageObserver).
         public void paintComponent(Graphics g) {
              Graphics2D g2D = (Graphics2D)g;
              for (int i = images.size()-1; i>=0; i--) {     
                   ((TransformableImage)images.get(i)).draw(g2D, this);
         * Inner class defining the behavior of the mouse.
         final class MouseHandler extends MouseInputAdapter {
              private TransformableImage draggedImage;
              private int transformation;
              private int dx, dy;
              public void mouseMoved(MouseEvent e) {
                   Point p = e.getPoint();
                   TransformableImage image = getImageAt(p);
                   if (image != null) {
                        transformation = image.getTransformation(p);
                        setConvenientCursor(transformation);
                   else {
                        setConvenientCursor(-1);
              public void mousePressed(MouseEvent e) {
                   Point p = e.getPoint();
                   draggedImage = getImageAt(p);
                   if (draggedImage!=null) {
                        dx = p.x-draggedImage.x;
                        dy = p.y-draggedImage.y;
              public void mouseDragged(MouseEvent e) {
                   if (draggedImage==null) {
                        return;
                   Point p = e.getPoint();
                   repaint(draggedImage.x,draggedImage.y,draggedImage.width+1,draggedImage.height+1);
                   draggedImage.transform(p, transformation,dx,dy);
                   repaint(draggedImage.x,draggedImage.y,draggedImage.width+1,draggedImage.height+1);
              public void mouseReleased(MouseEvent e) {
                   Point p = e.getPoint();
                   draggedImage = null;
         * Utility method used to get the image located at a Point p.
         * Returns null if there is no image at this point.
         private final TransformableImage getImageAt(Point p) {
              TransformableImage image = null;
              for (int i = 0, n = images.size(); i<n; i++) {     
                   image = (TransformableImage)images.get(i);
                   if (image.contains(p)) {
                        return(image);
              return(null);
         * Sets the convenient cursor according the the transformation (i.e. the position of the mouse over the image).
         private final void setConvenientCursor(int transfo) {
              Cursor currentCursor = getCursor();
              Cursor newCursor = null;
              switch (transfo) {
                   case TransformableImage.MOVE : newCursor = MOVE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_TOP : newCursor = VERTICAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_BOTTOM : newCursor = VERTICAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_LEFT : newCursor = HORIZONTAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_RIGHT : newCursor = HORIZONTAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_TOP_LEFT_CORNER : newCursor = NW_SE_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_TOP_RIGHT_CORNER : newCursor = NE_SW_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_BOTTOM_LEFT_CORNER : newCursor = NE_SW_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_BOTTOM_RIGHT_CORNER : newCursor = NW_SE_RESIZE_CURSOR;
                        break;
                   default : newCursor = DEFAULT_CURSOR;
              if (newCursor != null && currentCursor != newCursor) {
                   setCursor(newCursor);
         public static void main(String[] args) {
              JFrame frame = new JFrame("Test transformable images");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.getContentPane().add(new ImagePanel(), BorderLayout.CENTER);
              frame.pack();
              frame.setVisible(true);
    }[3]. code 3
    import java.awt.*;
    import javax.swing.*;
    import java.awt.image.*;
    public final class TransformableImage extends Rectangle {
         public static final int MOVE = 0;
         public static final int RESIZE_TOP = 10;
         public static final int RESIZE_BOTTOM = 20;
         public static final int RESIZE_RIGHT = 1;
         public static final int RESIZE_LEFT = 2;
         public static final int RESIZE_TOP_RIGHT_CORNER = 11;
         public static final int RESIZE_TOP_LEFT_CORNER = 12;
         public static final int RESIZE_BOTTOM_RIGHT_CORNER = 21;
         public static final int RESIZE_BOTTOM_LEFT_CORNER = 22;
         public static final int BORDER_THICKNESS = 5;
         public static final int MIN_THICKNESS = BORDER_THICKNESS*2;
         private static final Color borderColor = Color.black;
         private Image image;
         * Create an TransformableImage from the image file filename.
         * The TransformableImage bounds (inherited from the class Rectangle) are setted to the corresponding values.
         public TransformableImage(String filename) {
              ImageIcon ic = new ImageIcon(filename);
              image = ic.getImage();
              setBounds(0,0,ic.getIconWidth(), ic.getIconHeight());
         * Draw the image rescaled to fit the bounds.
         * A black rectangle is drawn around the image.
         public final void draw(Graphics2D g, ImageObserver observer) {
              Color oldColor = g.getColor();
              g.setColor(borderColor);
              g.drawImage(image, x, y, width, height, observer);
              g.draw(this);
              g.setColor(oldColor);
         * Return an int corresponding to the transformation available according to the mouse location on the image.
         * If the point p is in the border, with a thickness of BORDER_THICKNESS, around the image, the corresponding
         * transformation is returned (RESIZE_TOP, ..., RESIZE_BOTTOM_LEFT_CORNER).
         * If the point p is located in the center of the image (i.e. out of the border), the MOVE transformation is returned.
         * We allways suppose that p is contained in the image bounds.
         public final int getTransformation(Point p) {
              int px = p.x;
              int py = p.y;
              int transformation = 0;
              if (py<(y+BORDER_THICKNESS)) {
                   transformation += RESIZE_TOP;
              else
              if (py>(y+height-BORDER_THICKNESS-1)) {
                   transformation += RESIZE_BOTTOM;
              if (px<(x+BORDER_THICKNESS)) {
                   transformation += RESIZE_LEFT;
              else
              if (px>(x+width-BORDER_THICKNESS-1)) {
                   transformation += RESIZE_RIGHT;
              return(transformation);
         * Move the left side of the image, verifying that the width is > to the MIN_THICKNESS.
         public final void moveX1(int px) {
              int x1 = x+width;
              if (px>x1-MIN_THICKNESS) {
                   x = x1-MIN_THICKNESS;
                   width = MIN_THICKNESS;
              else {
                   width += (x-px);
                   x = px;               
         * Move the right side of the image, verifying that the width is > to the MIN_THICKNESS.
         public final void moveX2(int px) {
              width = px-x;
              if (width<MIN_THICKNESS) {
                   width = MIN_THICKNESS;
         * Move the top side of the image, verifying that the height is > to the MIN_THICKNESS.
         public final void moveY1(int py) {
              int y1 = y+height;
              if (py>y1-MIN_THICKNESS) {
                   y = y1-MIN_THICKNESS;
                   height = MIN_THICKNESS;
              else {
                   height += (y-py);
                   y = py;               
         * Move the bottom side of the image, verifying that the height is > to the MIN_THICKNESS.
         public final void moveY2(int py) {
              height = py-y;
              if (height<MIN_THICKNESS) {
                   height = MIN_THICKNESS;
         * Apply a given transformation with the given Point to the image.
         * The shift values dx and dy are needed for move tho locate the image at the same relative position from the cursor (p).
         public final void transform(Point p, int transformationType, int dx, int dy) {
              int px = p.x;
              int py = p.y;
              switch (transformationType) {
                   case MOVE : x = px-dx; y = py-dy;
                        break;
                   case RESIZE_TOP : moveY1(py);
                        break;
                   case RESIZE_BOTTOM : moveY2(py);
                        break;
                   case RESIZE_LEFT : moveX1(px);
                        break;
                   case RESIZE_RIGHT : moveX2(px);
                        break;
                   case RESIZE_TOP_LEFT_CORNER : moveX1(px);moveY1(py);
                        break;
                   case RESIZE_TOP_RIGHT_CORNER : moveX2(px);moveY1(py);
                        break;
                   case RESIZE_BOTTOM_LEFT_CORNER : moveX1(px);moveY2(py);
                        break;
                   case RESIZE_BOTTOM_RIGHT_CORNER : moveX2(px);moveY2(py);
                        break;
                   default :
    }

    I gave you a simple solution in your other posting. You never responded to the suggestion stating why the given solution wouldn't work, so it can't be that urgent.

  • Drag and drop icons from onside of the split pane to the other side.

    Hello All,
    I am tring to write a program where i can drag and drop icons from the left side of the split pane to the right side. I have to draw a network on the right side of the split pane from the icons provided on the left side. Putting the icons on the labels donot work as i would like to drag multiple icons from the left side and drop them on the right side. CAn anyone please help me with this.
    Thanks in advance
    smitha

    The other option besides the drag_n_drop support
    http://java.sun.com/docs/books/tutorial/uiswing/dnd/intro.htmlis to make up something on your own. You could use a glasspane (see JRootPane api for overview) as mentioned in the tutorial.
    Here's another variation using an OverlayLayout. One advantage of this approach is that you can localize the overlay component and avoid some work.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    public class DragRx extends JComponent {
        JPanel rightComponent;
        BufferedImage image;
        Point loc = new Point();
        protected void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            if(image != null)
                g2.drawImage(image, loc.x, loc.y, this);
        public void setImage(BufferedImage image) {
            this.image = image;
            repaint();
        public void moveImage(int x, int y) {
            loc.setLocation(x, y);
            repaint();
        public void dropImage(Point p) {
            int w = image.getWidth();
            int h = image.getHeight();
            p = SwingUtilities.convertPoint(this, p, rightComponent);
            JLabel label = new JLabel(new ImageIcon(image));
            rightComponent.add(label);
            label.setBounds(p.x, p.y, w, h);
            setImage(null);
        private JPanel getContent(BufferedImage[] images) {
            JSplitPane splitPane = new JSplitPane();
            splitPane.setLeftComponent(getLeftComponent(images));
            splitPane.setRightComponent(getRightComponent());
            splitPane.setResizeWeight(0.5);
            splitPane.setDividerLocation(225);
            JPanel panel = new JPanel();
            OverlayLayout overlay = new OverlayLayout(panel);
            panel.setLayout(overlay);
            panel.add(this);
            panel.add(splitPane);
            return panel;
        private JPanel getLeftComponent(BufferedImage[] images) {
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.weightx = 1.0;
            gbc.weighty = 1.0;
            for(int j = 0; j < images.length; j++) {
                gbc.gridwidth = (j%2 == 0) ? GridBagConstraints.RELATIVE
                                           : GridBagConstraints.REMAINDER;
                panel.add(new JLabel(new ImageIcon(images[j])), gbc);
            CopyDragHandler handler = new CopyDragHandler(panel, this);
            panel.addMouseListener(handler);
            panel.addMouseMotionListener(handler);
            return panel;
        private JPanel getRightComponent() {
            rightComponent = new JPanel(null);
            MouseInputAdapter mia = new MouseInputAdapter() {
                Component selectedComponent;
                Point offset = new Point();
                boolean dragging = false;
                public void mousePressed(MouseEvent e) {
                    Point p = e.getPoint();
                    for(Component c : rightComponent.getComponents()) {
                        Rectangle r = c.getBounds();
                        if(r.contains(p)) {
                            selectedComponent = c;
                            offset.x = p.x - r.x;
                            offset.y = p.y - r.y;
                            dragging = true;
                            break;
                public void mouseReleased(MouseEvent e) {
                    dragging = false;
                public void mouseDragged(MouseEvent e) {
                    if(dragging) {
                        int x = e.getX() - offset.x;
                        int y = e.getY() - offset.y;
                        selectedComponent.setLocation(x,y);
            rightComponent.addMouseListener(mia);
            rightComponent.addMouseMotionListener(mia);
            return rightComponent;
        public static void main(String[] args) throws IOException {
            String[] ids = { "-c---", "--g--", "---h-", "----t" };
            BufferedImage[] images = new BufferedImage[ids.length];
            for(int j = 0; j < images.length; j++) {
                String path = "images/geek/geek" + ids[j] + ".gif";
                images[j] = ImageIO.read(new File(path));
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(new DragRx().getContent(images));
            f.setSize(500,400);
            f.setLocation(200,200);
            f.setVisible(true);
    class CopyDragHandler extends MouseInputAdapter {
        JComponent source;
        DragRx target;
        JLabel selectedLabel;
        Point start;
        Point offset = new Point();
        boolean dragging = false;
        final int MIN_DIST = 5;
        public CopyDragHandler(JComponent c, DragRx dr) {
            source = c;
            target = dr;
        public void mousePressed(MouseEvent e) {
            Point p = e.getPoint();
            Component[] c = source.getComponents();
            for(int j = 0; j < c.length; j++) {
                Rectangle r = c[j].getBounds();
                if(r.contains(p) && c[j] instanceof JLabel) {
                    offset.x = p.x - r.x;
                    offset.y = p.y - r.y;
                    start = p;
                    selectedLabel = (JLabel)c[j];
                    break;
        public void mouseReleased(MouseEvent e) {
            if(dragging && selectedLabel != null) {
                int x = e.getX() - offset.x;
                int y = e.getY() - offset.y;
                target.dropImage(new Point(x,y));
            selectedLabel = null;
            dragging = false;
        public void mouseDragged(MouseEvent e) {
            Point p = e.getPoint();
            if(!dragging && selectedLabel != null
                         && p.distance(start) > MIN_DIST) {
                dragging = true;
                copyAndSend();
            if(dragging) {
                int x = p.x - offset.x;
                int y = p.y - offset.y;
                target.moveImage(x, y);
        private void copyAndSend() {
            ImageIcon icon = (ImageIcon)selectedLabel.getIcon();
            BufferedImage image = copy((BufferedImage)icon.getImage());
            target.setImage(image);
        private BufferedImage copy(BufferedImage src) {
            int w = src.getWidth();
            int h = src.getHeight();
            BufferedImage dst =
                source.getGraphicsConfiguration().createCompatibleImage(w,h);
            Graphics2D g2 = dst.createGraphics();
            g2.drawImage(src,0,0,source);
            g2.dispose();
            return dst;
    }geek images from
    http://java.sun.com/docs/books/tutorial/uiswing/examples/components/index.html

  • Drag & drop images from Finder into new Photoshop layer?

    Is it possible to drag & drop images from Finder into a new Photoshop layer?
    I can do it from a web browser, but not the Finder.

    >I couldn't find a way to do so in Bridge, but also I never use that program. Never got into Bridge's workflow. >
    I really do suggest that you re-visit Bridge especially the CS4 version.
    I just cannot conceive of trying to use a Digital camera, a Scanner or the Creative Suite programs without using Bridge and ACR.
    I can even use it to read PDFs and inDesign documents (all pages!) without opening Acrobat or InD..
    >I usually keep a "work" window open with all the files I am using for a project, so it would be far more handy to be able to skim them in the Finder.
    It is now far more effective and efficient to do that in Bridge than in the Finder.
    This is where you would find the new Collections feature to be invaluable:
    Just select all the images and other files connected to a project from any folder and drag their icons into the same Collection.
    You then have all aliases (previewable at full-screen slide-view size with one click of the space bar in CS4) to ALL of your files which are now visible in. and openable from, a single panel.

  • Best practice to show ICON instead Label for ADF Component

    Hi,
    I am using JDeveloper 11.1.1.6.
    My requirement is to use Icons instead Label text for my ADF components. Those are in one Form layout wich means that if I just used a panelgroup horizontal and put then the image and then the input component, the panelForm Layout wont automatically align my components. So I was trying to fallow this link
    http://adfpractice-fedor.blogspot.co.uk/2011/08/panel-form-layout-and-labels-with-icons.html with no success.
    Anyone else could orientate me on the right path?
    Thank you

    You can try to use af:panelFormLayout and set "rows" property.
    Then set simple="true" on your input components.
    For example:
    <af:panelFormLayout id="pfl1" rows="2">
          <af:image source="image1.png" id="i1"/>
          <af:image source="image2.png" id="i2"/>
          <af:inputText label="Label 1" id="it1" simple="true"/>
          <af:inputText label="Label 2" id="it2" simple="true"/>
    </af:panelFormLayout>Dario

  • Adding a label on a panel

    i have around 7 buttons. Whenever i click on any 1 button, a label with an ImageIcon parameter needs to be displayed on a panel.
    when the user clicks the second button, another label with an ImageIcon gets added on the same panel(now the panel has first label+ second label).
    These labels can also be moved on the panel using mouse(i have the code to make the label move on the panel).
    How do i add these labels on my panel on their respective button clicks?? thanx in advance

    i have the following code which adds images on panel and also moves them.you can use any of your own images.i do not know how to add the data structure you suggested....so please help me...thanx in advance
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.datatransfer.*;
    import java.io.*;
    public class Post extends JFrame implements ActionListener,MouseListener,MouseMotionListener
         Container con;
         MenuBar mbar;
         Menu file,edit,view;
         JPanel p1;
         JPanel dropZone;
         private int xAdjustment;
         private int yAdjustment;
         Component dragComponent;
         int xpoint;
         int ypoint;
         Uml()
         super("Model Transformation Tool");
         con=getContentPane();
         Toolkit kit = Toolkit.getDefaultToolkit();
             final Clipboard clipboard =kit.getSystemClipboard();
         addMouseListener(this);
         addMouseMotionListener(this);
         ImageIcon act = new ImageIcon("..\\uml\\actor4.gif");
         JButton actor = new JButton(act);
         ImageIcon inher = new ImageIcon("..\\uml\\inher.gif");
         JButton inheritance = new JButton(inher);
         actor.setActionCommand("actor");
         actor.addActionListener(this);
         inheritance.setActionCommand("inheritance");
         inheritance.addActionListener(this);
         dropZone = new JPanel();
             dropZone.setBorder(BorderFactory.createLineBorder (Color.blue, 2));
               dropZone.setBackground(Color.WHITE);
         p1=new JPanel();
         con.setLayout(new BorderLayout());
         p1.setLayout(new FlowLayout());
         p1.add(actor);
         p1.add(inheritance);
         con.add(p1,BorderLayout.NORTH);
         con.add(dropZone, BorderLayout.CENTER);
         setVisible(true);
         public void actionPerformed(ActionEvent e)
              String tmp=e.getActionCommand();
              if("actor".equals(tmp))
              Icon icon1 = new ImageIcon("..\\uml\\actorfull.gif");
              JLabel label1=new JLabel(icon1);
              dropZone.add(label1);
              dropZone.revalidate();
              String aname=JOptionPane.showInputDialog("Enter the name of actor");
              JLabel actorname=new JLabel(aname);
              dropZone.add(actorname);
              dropZone.revalidate();
              if("inheritance".equals(tmp))
              Icon icon3 = new ImageIcon("..\\uml\\inher_full.gif");
              JLabel label3=new JLabel(icon3);
              dropZone.add(label3);
              dropZone.revalidate();                    
    }//actionPerformed
         public void mousePressed(MouseEvent e)
              Container container =  (Container)e.getSource();
              Component component =  container.findComponentAt(e.getX(), e.getY());
              if (component instanceof JPanel) return;
              dragComponent = component;
              xAdjustment = dragComponent.getLocation().x - e.getX();
              yAdjustment = dragComponent.getLocation().y - e.getY();
         **  Move the component around the panel
         public void mouseDragged(MouseEvent e)
              if (dragComponent == null) return;
              dragComponent.setLocation(e.getX() + xAdjustment, e.getY() + yAdjustment);
         **  Deselect the component
         public void mouseReleased(MouseEvent e)
              dragComponent = null;
         public void mouseClicked(MouseEvent e) {}
         public void mouseMoved(MouseEvent e) {}
         public void mouseEntered(MouseEvent e) {}
         public void mouseExited(MouseEvent e) {}
         public static void main(String args[])
         Toolkit kit = Toolkit.getDefaultToolkit();
         Dimension screenSize = kit.getScreenSize();
         int screenWidth = screenSize.width;
         int screenHeight = screenSize.height;
         Uml obj=new Uml();     
         obj.setBounds(0, 0, screenWidth, screenHeight-29);
         obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }//class

  • Placing icons and label inside a ToggleButtonBar

    As It's explain on subject, I try to create a custom ToggleButtonBar with icon and label on top.
    To do that, I create the class you can read below
    package
    import mx.controls.Button;
    import mx.controls.ToggleButtonBar;
    import mx.core.IFlexDisplayObject;
    public class IconToggleButtonBar extends ToggleButtonBar
    [Inspectable (enumeration = "left,right,top,bottom", defaultValue="left")]
    public var labelPlacement:String="left";
    override protected function createNavItem(label:String, icon:Class=null):IFlexDisplayObject
    var b:Button = Button (super.createNavItem(label,icon));
    b.labelPlacement= labelPlacement;
    return b;
    To use this class, I had done:
    <fx:Script >
    <![CDATA[
    [Embed (source= "icon/paramList/archive.png")]
    public var icon1:Class ;
    private var listeObject:Object={label:"Label1", icon : icon1};
    private var actesObject:Object={label:"Label2", icon : icon1};
    private var preimpObject:Object={label:"Label3", icon : icon1};
    private var amoamcObject:Object={label:"Label4", icon : icon1};
    private var agendaObject:Object={label:"Label5", icon : icon1};
    [bindable]
    public var buttons:Array = [listeObject, actesObject, preimpObject, amoamcObject, agendaObject];
    ]]>
    </fx:Script>
    <component:IconToggleButtonBar
    dataProvider="{buttons}"
    itemClick="changeBbHandler(event)"
    includeIn="tout"
    selectedIndex="-1"
    toggleOnClick="true"
    x="7" width="95%"     
    color="0xff0000"
    height="49"/>
    In my case, icon is visible on IconToggleButtonBar but no label appear.
    Is anyone can explain to me why?
    Thanks for helping

    I tried that first. Updating the script to this doesn't work.
    myXML.onLoad = function(){
    //Set varible to store the XML childNodes
    //This allows you to get the number of buttons in the XML file.
    //You'll use this tell flash how many times to loop the for loop.
    var linkname:Array = this.firstChild.childNodes;
    //Set a for loop
    for(i=0;i<linkname.length;i++){
    //Push the button name into the names Array
    names.push(linkname[i].attributes.NAME);
    //Push the button link into the links Array
    links.push(linkname[i].attributes.LINK);
    //Attach the button Movie Clip from the libray give it an instance name and place it on the next highest level
    this.attachMovie("button","btn"+i,this.getNextHighestDepth());
    //Set the y position of the buttons
    this["btn"+(i)]._y = yPosition;
    //Increace the varible yPosition 15 pixel each time the loop runs to place each button under each other
    yPosition = yPosition + 25
    //Place the button name from names Array into the blackTxt text box
    this["btn"+(i)].buttonText.Txt.text = (names[i]);
    //Assign the btnRelease function to the button onRelease state.
    this["btn"+(i)].onRelease = btnRelease;

  • Can no longer drop a MIDI file into iTunes library

    Using Tiger on a G4 iMac, I could drop a MIDI file into my iTunes library and convert it to an mp3 (or other format).
    Can't get this to happen now that I'm using Leopard on a new machine (see below) - or is there a different way of doing it in Leopard?
    With thanks,
    Gilly

    Answering my own question - had iTunes set to Show Duplicates - therefore couldn't see MIDI I dropped in.

  • My phone keeps resetting and then shows the icon to plug into itunes but when i do itunes tells me that it can't connect to my phone because it has a passcode and wants me to unlock it to connect. My phone only gives me the option to make emergency calls.

    My phone started resetting today over and over and then shows the icon to plug into itunes. When I tried plugging in, a message pops up saying that itunes can't connect because my phone has a passcode and i need to unlock it to connect. my phone won't let me do anything more than make an emergency call. it wont give me the option to enter my passcode to unlock the phone. What can I do?

    After a visit to the apple store, they were able to get through my pass code but unfortunately I found out that is was a problem with the logic board. Since Apple only wants to sell and not fix, I was able to locate an iphone repair near me that deals with logic boards and they are currently working on it right now. i should be getting it back soon. Im not sure if the problem you are experiencing is the same as i went through but it does sound like it may be also a hardware issue and would suggest searching online for an iphone repair place that can diagnose what exactly is wrong. Hope this helps.

  • I recently dropped my ipod 4G into water. Whenever i try to play music outloud or hooked up to headphones, it won't play. How do i fix it?

    I recently dropped my ipod 4G into water. Whenever i try to play music outloud or hooked up to headphones, it won't play. How do i fix it?

    What do y mean by still works? No sound from speaker or headphones ro all apps? If try then it really does not work.
    Apple will exchange your iPod for a refurbished one for $199 for 64 GB 4G and $99 for the other 4Gs. They do not fix yours.
      Apple - iPod Repair price                                             

  • I got locked out of Mac os 9 and now I can't get into OS 9 or OS X.  All I see is the Macintosh SE and a finder face and text that says "mac os 9.2 welcome to mac os".  I can't get into COntrol Panel to reset the password to allow me to get in.

    I got locked out of Mac os 9 and now I can't get into OS 9 or OS X.  All I see is the Macintosh SE and a finder face and text that says "mac os 9.2 welcome to mac os".  I can't get into COntrol Panel to reset the password to allow me to get in.

    Do you have OS X and OS 9 installed on your Mac? If so, startup with the Option key depressed. This will open the Startup Manager window. Select the OS you want to start from & click the right arrow.
     Cheers, Tom

  • HT1347 When I add a folder to the library, does that mean that 'later' when I drop a new file into that folder (already added) it will automatically end up in iTunes? (or do I have to add file/folder to library every time I have a new file??) I'm using XP

    When I add a folder to the library, does that mean that 'later' when I drop a new file into that folder (already added) it will automatically end up in iTunes? (or do I have to add file/folder to library every time I have a new file??) I'm using XP...

    iTunes does not actively scan the media folders.  If you manually add content to a folder, then you must add that content to iTunes manually via the File > Add File/Folder feature.
    The only folder that gets scanned is the "Automatically add to iTunes" folder.

  • I use to drag and drop an web address into a link toolbar, can't seem to figure out how to do this...?

    I just upgraded to Windows 7 and with it I got the latest Firefox. There is nothing like learning 2 things at one time. On my old XP and 3.? all I have to do was drag and drop a web address into a link toolbar. Saving all my frequent visited or just sights I want quick access to, to a toolbar quick button. I have been playing with this for days and decided to try this Forum. I did find the Bookmark toolbar, but cant seem to figure out what is if for or if you can drop into it. When I right click it and Customize, it shows me add on buttons, but nothing to do with web addresses or alike...
    Bottom line; I want to be able to drag and drop a web address into a toolbar for recall latter and be able to edit the address with a right click at a latter date in necessary...
    Thanks, Mike

    You can drag and drop the favicon also known as the [https://support.mozilla.com/en-US/kb/Site+Identity+Button site identity button], at the left hand edge of the location bar onto a toolbar to bookmark the site.

  • Labels in my Panel

    I'm sorry that I couldn't figure this out from the search. I tried a few things but none seemed to work.
    I have a panel that contains labels. The labels represent objects alive in my system. The Frame watches these objects and updates every second.
    I start the panel empty except for a static label at the top that says "objects".
    in each loop, I collect object names in an array and create labels for each. I want to replace the current panel content with the new labels. I have tried re instantiating the panel, re writing the panel's paint method to add new labels, but my panel remains looking the same. Can anyone help?
    Thanks

    Using awt Panels. I didn't want later users to have to have a higher version of java. I'm not married to the version though. Below is the code that I am using...
      // Creates the userDisplay panel
      // UserDisplay is defined in the Frame
        public void createUserDisplay(ArrayList users){
          users = users==null?new ArrayList():users;
          if(userDisplay != null){
            userDisplay.removeAll();
          }else{
            userDisplay = new Panel();
          int labelHeight = 8;
          int labelWidth = 24;
          userDisplay.setSize(labelWidth,0);
          userDisplay.setBackground(Color.white);
          userDisplay.setLayout(new java.awt.GridLayout(0,1));
          Label usersHeader = new Label();
          usersHeader.setSize(labelWidth,labelHeight);
          usersHeader.setBackground(Color.white);
          usersHeader.setFont(BIG);
          usersHeader.setText("USERS");
          usersHeader.setBounds(0,labelWidth,labelHeight,labelWidth);
          userDisplay.add(usersHeader);
          for(int a = 0; a < users.size(); a++){
            Label L = new Label();
            L.setFont(normal);
            L.setBounds(0,labelWidth + (a * labelHeight),labelHeight,labelWidth);
            L.setBackground(
              ((SimpleChat.User)users.get(a)).status == 1
              Color.yellow
              Color.white
            L.setSize(labelWidth,labelHeight);
            L.setText(((SimpleChat.User)users.get(a)).name);
            userDisplay.add(L);
            System.out.println("Added " + L.getText());
          }

Maybe you are looking for

  • Problem with file format in Email with abap

    Hi All, I am Using a function module (SO_NEW_DOCUMENT_ATT_SEND_API1) to send Mail with attachment with .TXT format.But This function module is allowing only 255 char.But the field length of my Internal table is 700 char.Is there any another way to pr

  • Insert into NVARCHAR2 columns(ORA_01461, ORA-01026)

    Hi, Oracle8i Client 8.1.5 (OCI8) Oracle9i Client 9.0.1 (OCI9) Oracle8i/9i DB I want to insert strings into a table with two NVARCHAR2 columns with OCI. NLS_NCHAR_CHARACTERSET is UTF8 (DB). The provided String is encoded in Windows-1252. The supplied

  • Closed captioning with Premiere Pro CS5.5, exported to wmv/mp4

    My employer suddenly has a push to be ADA compliant, so all videos going forward need to have captioning, and would prefer to have it closed captioned. I've read that you can add captions with Encore and output them to disc, but since all of the vide

  • SYNC of Calendar with Windows Live Mail

    Hi we urgently need a sync for free calendars i.e windows live mail or thunderbird/lightning . Does anybody know how to get?

  • Available disk space varies by 100 GB

    Recently I made a defrag on my computer, and for that I had to create a partition of 100 GB, because that's the lowest. After I've done that i deleted the partition. Now i remember it said something about deleting some space or something but I can't