How to draw a shape to Panel instead of draw to Frame

I have a Frame and add a Panel into this Frame. I want to draw a shape to Panel instead of draw to Frame. how do i do?

You can do two different things:
1) For temporary drawings that will disappear when the component is repainted, you can use getGraphics() on the Panel, draw on the Graphics, then dispose the Graphics.
2) For persistant drawings, subclass Panel and override the paint(Graphics g) method. Anything in there will be painted along with the panel. Start with super.paint(g); when you override for good coding practice.

Similar Messages

  • How to draw 2D shapes on the image generated by JMF MediaPlayer?

    Hello all:
    IS there any way that we can draw 2D shapes on the image generated by JMF
    MediaPlayer?
    I am currently working on a project which should draw 2D shapes(rectangle, circle etc) to
    mark the interesting part of image generated by JMF MediaPlayer.
    The software is supposed to work as follows:
    1> first use will open a mpg file and use JMF MediaPlayer to play this video
    2> if the user finds some interesting image on the video, he will pause the video
    and draw a circle to mark the interesting part on that image.
    I know how to draw a 2D shapes on JPanel, however, I have no idea how I can
    draw them on the Mediaplayer Screen.
    What technique I should learn to implement this software?
    any comments are welcome.
    thank you
    -Daniel

    If anyone can help?!
    thank you
    -Daniel

  • After editing a photo in another program, the photos return to the library at the end of the grid panel instead of at their original loacation.  How do I avoid this or alternatively, is there a quick way of moving them back to their original position inst

    After editing a photo in another program, the photos return to the library at the end of the grid panel instead of at their original loacation.  How do I avoid this or alternatively, is there a quick way of moving them back to their original position instead of clicking and dragging them?

    Sort your photos by File Name or Capture Date
    Use View->Sort

  • How do I tile the Dreamweaver panels and document windows to tile instead of being superimposed?

    How do I tile the Dreamweaver panels and document windows to tile instead of being superimposed?

    I'm not sure what may be causing your issue on the right side of the screen, other than possibly your application frame is wider than your screen size so you aren't able to drag the window tab far enough to get the highlighting effect. Make sure your application frame is maximized to your screen by hitting the middle button in the top right of the window so it changes to the double square icon. That way, you'll know whether the edge is off screen or not.
    Only certain windows can be brought to the top or bottom since those are reserved for toolbars and the Properties Inspector respectively.

  • How to draw rectanlge in the panel, clear, repaint?

    when i was taking my coding, i found a problem which i could not solve.So, i hope someone can help. Thank you.
    the question :
    1. how to draw Rectangle in the Panel?
    2. how to clear?
    3. how to repaint?
    The following is my coding.
    import javax.swing.*;
    import java.awt.*;
    public class DrawScreen extends JFrame {
    Color rectColor=Color.white;
    int hight=100;
    Panel Button_panel = new Panel();
    Button button1 = new Button();
    Button button2 = new Button();
    Button button3 = new Button();
    Panel Draw_Panel = new Panel();
    public DrawScreen(String title) {
         super(title);
         try {
         Init();
         catch(Exception e) {
         e.printStackTrace();
    private void Init() throws Exception {
    setResizable(false);
    setFont(new Font("Serif",Font.ITALIC,12));
         this.getContentPane().setLayout(null);
         Button_panel.setBackground(SystemColor.control);
         Button_panel.setLocale(java.util.Locale.getDefault());
         Button_panel.setBounds(new Rectangle(14, 17, 118, 259));
         Button_panel.setLayout(null);
         button1.setLabel("Draw Square");
         button1.setBounds(new Rectangle(0, 69, 115, 22));
         button2.setLabel("Colour Red");
         button2.setBounds(new Rectangle(0, 111, 115, 22));
         button3.setLabel("Clear Screen");
         button3.setBounds(new Rectangle(2, 152, 115, 22));
         Draw_Panel.setBackground(Color.white);
         Draw_Panel.setBounds(new Rectangle(138, 15, 254, 266));
    //     System.out.println(Draw_Panel.getBounds());
         this.getContentPane().setBackground(Color.white);
         this.getContentPane().add(Button_panel, "East");
         Button_panel.add(button3, null);
         Button_panel.add(button2, null);
         Button_panel.add(button1, null);
         this.getContentPane().add(Draw_Panel, "West");
         addWindowListener(new java.awt.event.WindowAdapter(){
              public void windowClosing(java.awt.event.WindowEvent e){
                   System.exit(0);
    button1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    button1ActionPerformed(evt);
    button2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    button2ActionPerformed(evt);
    button3.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    button3ActionPerformed(evt);
    pack();
    private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
         hight=(int)(Math.random()*100);
         rectColor=Color.black;
    repaint();
    private void button2ActionPerformed(java.awt.event.ActionEvent evt) {
         rectColor=Color.red;
    repaint();
    private void button3ActionPerformed(java.awt.event.ActionEvent evt) {
    rectColor=Color.white;
    repaint();
    public void paint(Graphics g){
         g.setColor(rectColor);
         g.drawRect(50, 50,hight,hight);
    public static void main(String[] args) {
    DrawScreen ds=new DrawScreen("Square Plotter");
         ds.setSize(600,350);
         ds.setVisible(true);

    Few changes and it works:
    import javax.swing.*;
    import java.awt.*;
    public class DrawScreen extends JFrame
         Color  rectColor    = Color.white;
         int    hight        = 100;
         Panel  Button_panel = new Panel();
         Button button1      = new Button();
         Button button2      = new Button();
         Button button3      = new Button();
         DPanel Draw_Panel   = new DPanel();
    public DrawScreen(String title)
         super(title);
         setResizable(false);
    //     setFont(new Font("Serif",Font.ITALIC,12));
    //     this.getContentPane().setLayout(null);
         Button_panel.setBackground(SystemColor.control);
         Button_panel.setLocale(java.util.Locale.getDefault());
         Button_panel.setBounds(new Rectangle(14, 17, 118, 259));
         Button_panel.setLayout(null);
         button1.setLabel("Draw Square");
         button1.setBounds(new Rectangle(0, 69, 115, 22));
         button2.setLabel("Colour Red");
         button2.setBounds(new Rectangle(0, 111, 115, 22));
         button3.setLabel("Clear Screen");
         button3.setBounds(new Rectangle(2, 152, 115, 22));
         Draw_Panel.setBackground(Color.white);
         Draw_Panel.setBounds(new Rectangle(138, 15, 254, 266));
    //  System.out.println(Draw_Panel.getBounds());
    //     this.getContentPane().setBackground(Color.white);
         this.getContentPane().add(Button_panel, "East");
         Button_panel.add(button3);
         Button_panel.add(button2);
         Button_panel.add(button1);
         this.getContentPane().add(Draw_Panel, "Center");
         addWindowListener(new java.awt.event.WindowAdapter()
              public void windowClosing(java.awt.event.WindowEvent e)
                   System.exit(0);
         button1.addActionListener(new java.awt.event.ActionListener()
              public void actionPerformed(java.awt.event.ActionEvent evt)
                   button1ActionPerformed(evt);
         button2.addActionListener(new java.awt.event.ActionListener()
              public void actionPerformed(java.awt.event.ActionEvent evt)
              button2ActionPerformed(evt);
         button3.addActionListener(new java.awt.event.ActionListener()
              public void actionPerformed(java.awt.event.ActionEvent evt)
                   button3ActionPerformed(evt);
    //     pack();
    private void button1ActionPerformed(java.awt.event.ActionEvent evt)
         hight=(int)(Math.random()*100);
         rectColor=Color.black;
         repaint();
    private void button2ActionPerformed(java.awt.event.ActionEvent evt)
         rectColor=Color.red;
         repaint();
    private void button3ActionPerformed(java.awt.event.ActionEvent evt)
         rectColor=Color.white;
         repaint();
    public class DPanel extends JPanel
    public DPanel()
    public void paintComponent(Graphics g)
         super.paintComponent(g);
         g.setColor(rectColor);
         g.drawRect(50, 50,hight,hight);
    public static void main(String[] args)
         DrawScreen ds=new DrawScreen("Square Plotter");
         ds.setSize(600,350);
         ds.setVisible(true);
    }Noah

  • How can i use shape tweening and motion tweenin together on a movie clip?(where is looping whitch was in propertise panel in CS5?)

    how can show animation (shape and motion tween) witch i was created in Scens1-MovieClip in time line?
    there was an option (looping) in CS5 but how can i do it in CC and CS6?

    shape tweening can only be applied to raw drawn shapes, no movieclips.  IF you wanted to do a shape tween to a movieclip it would have to be done within the timeline in the movieclip.

  • How do I use shapes I create in Adobe Shape?

    All the shapes you create with Adobe Shape are stored in a CC Library.  This means you can access them in other desktop, mobile, and web apps.  Detailed instructions below.
    How to access your shapes in Creative Cloud
    Desktop: In order for this to work, you must have the most recent version of Illustrator and Photoshop.
    Open Adobe Illustrator on your desktop.
    Open the Libraries panel (Windows > Libraries)
    Your shapes should be present in your Libraries.  If you don’t see them there, select the libraries drop down to see if you saved your shapes in a different library.
    Now, you can drag the shape onto your canvas.
    At this point,  you can continue working with your shape, by adding editing.  Or, you can simply save the file.  Of course, after you save it to your desktop, you can email, post online, etc.
    Mobile apps:
    Open Adobe Illustrator Draw and open a drawing.
    Tap the Shapes icon to open the Shapes menu.
    Tap a library name to view the shapes in the Creative Cloud Library. Tap Change Library to select another library.
    Select your shape by tapping on it.
    Active Slide or Tocuh Slide. You can use Adobe Slide or Touch Slide to place the shape on the canvas. Access Touch Slide by tapping on the circular icon at the top of the menu bar.
    Place the shape.  Once you have activated Touch Slide, you will see a light rendition of your shape on the canvas.  Simply double tap on the shape outline to stamp the shape in place.
    Web:
    Navigate to https://assets.adobe.com/
    Select the Libraries menu item (left menu on the page)
    Select the desired library (if this is your first time using Libraries, you will only have one).
    This page provide a preview only.
    Also, here’s a great walk through video that may be useful: http://helpx.adobe.com/mobile-apps/how-to/shape-get-started.html?set=mobile-apps--fundamen tals--adobe-shape-cc

    I use Illustrator CC not Illustrator CC 2014 where can I find "Open the Libraries panel (Windows > Libraries)" and How can get the vector file from adobe shape cc?

  • How can I share shapes created with Adobe Shape?

    You can access your shapes in the Libraries panel within Photoshop and Illustrator.  If you would like to share the file with another person, simply drag the shape onto your canvas and then save the shape as a new file.  From here, you can email the file or add it to a shared drive. 

    Your shapes should be automatically saved to the Creative Cloud.  I’m going to explain how you can access them below.
    How to access your shapes in other apps
    Desktop: In order for this to work, you must have the most recent version of Illustrator and Photoshop. 
    Open Adobe Illustrator on your desktop.
    Open the Libraries panel (Windows > Libraries)
    Your shapes should be present in your Libraries.  If you don’t see them there, select the libraries drop down to see if you saved your shapes in a different library.
    Now, you can drag the shape onto your canvas. Or, right click and select "Use in document"
    At this point,  you can continue working with your shape, by adding editing.  Or, you can simply save the file.  Of course, after you save it to your desktop, you can email, post online, etc.
    Mobile apps:
    Open Adobe Illustrator Draw and open a drawing.
    Tap the Shapes icon to open the Shapes menu.
    Tap a library name to view the shapes in the Creative Cloud Library. Tap Change Library to select another library.
    Select your shape by tapping on it.
    Active Slide or Tocuh Slide. You can use Adobe Slide or Touch Slide to place the shape on the canvas. Access Touch Slide by tapping on the circular icon at the top of the menu bar. 
    Place the shape.  Once you have activated Touch Slide, you will see a light rendition of your shape on the canvas.  Simply double tap on the shape outline to stamp the shape in place.
    Web:
    Navigate to https://assets.adobe.com/
    Select the Libraries menu item (left menu on the page)
    Select the desired library (if this is your first time using Libraries, you will only have one).
    This page provide a preview only.
    Also, here’s a great walk through video that may be useful: http://helpx.adobe.com/mobile-apps/how-to/shape-get-started.html?set=mobile-apps--fundamen tals--adobe-shape-cc

  • How do you crop shapes?

    I was making a video the other day and I wanted to crop an image so it would fit into a thought bubble I had put on the screen. but I was only able to figure out how to crop top, left, right and bottom. I wasn't able to crop in shapes at all. How do you do this?

    How to draw shapes with a curve:
    http://help.adobe.com/en_US/premierepro/cs/using/WS86176DC4-85CA-4593-8050-DACFEBCBA0B9a.h tml
    When you draw your shape its a open bezier
    when you are finished its a closed bezier
    When you turn it into a shape to use as a matte for the track matte effect you change the Graphic Type to filled bezier and set the color to pure white.
    If you need to animate the matte you place a garbage matte on a white solid instead of using the Titler. Unfortunately the garbage matte does not go beyond 16 points and no bezier handles.
    You can feather a matte by adding a Fast/Gaussian Blur to the shape.

  • How do I edit shapes created by Adobe Shape?

    Shapes created in Adobe Shape can be modified in Illustrator or Photoshop and saved as a separate file. However, your new file will not be updated in Adobe Shape. 

    Your shapes should be automatically saved to the Creative Cloud.  I’m going to explain how you can access them below.
    How to access your shapes in other apps
    Desktop: In order for this to work, you must have the most recent version of Illustrator and Photoshop. 
    Open Adobe Illustrator on your desktop.
    Open the Libraries panel (Windows > Libraries)
    Your shapes should be present in your Libraries.  If you don’t see them there, select the libraries drop down to see if you saved your shapes in a different library.
    Now, you can drag the shape onto your canvas. Or, right click and select "Use in document"
    At this point,  you can continue working with your shape, by adding editing.  Or, you can simply save the file.  Of course, after you save it to your desktop, you can email, post online, etc.
    Mobile apps:
    Open Adobe Illustrator Draw and open a drawing.
    Tap the Shapes icon to open the Shapes menu.
    Tap a library name to view the shapes in the Creative Cloud Library. Tap Change Library to select another library.
    Select your shape by tapping on it.
    Active Slide or Tocuh Slide. You can use Adobe Slide or Touch Slide to place the shape on the canvas. Access Touch Slide by tapping on the circular icon at the top of the menu bar. 
    Place the shape.  Once you have activated Touch Slide, you will see a light rendition of your shape on the canvas.  Simply double tap on the shape outline to stamp the shape in place.
    Web:
    Navigate to https://assets.adobe.com/
    Select the Libraries menu item (left menu on the page)
    Select the desired library (if this is your first time using Libraries, you will only have one).
    This page provide a preview only.
    Also, here’s a great walk through video that may be useful: http://helpx.adobe.com/mobile-apps/how-to/shape-get-started.html?set=mobile-apps--fundamen tals--adobe-shape-cc

  • How to draw text vertically, or in an angle

    please help me how to draw text vertically, or in an angle

    I robbed the framework from Dr Las or 74phillip (don't remember which) ...
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class AngleText extends JPanel {
      private int      degrees = 16;
      private JSpinner degreesSpinner;
      public AngleText () {
        setBackground ( Color.WHITE );
      }  // AngleText constructor
      protected void paintComponent ( Graphics _g ) {
        super.paintComponent ( _g );
        Graphics2D g = (Graphics2D)_g;
        g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
        AffineTransform at = AffineTransform.getRotateInstance ( Math.toRadians ( degrees ) );
        Font f =  g.getFont();
        g.setFont ( f.deriveFont ( at ) );
        g.drawString ( "Rotating Text!", getWidth()/2, getHeight()/2 );
        g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
      }  // paintComponent
      public JPanel getUIPanel () {
        SpinnerModel degreesModel = new SpinnerNumberModel (
                                      degrees  // initial
                                     ,0        // min
                                     ,360      // max
                                     ,2        // step
        degreesSpinner = new JSpinner ( degreesModel );
        degreesSpinner.addChangeListener ( new DegreesTracker() );
        JPanel panel = new JPanel();
        panel.add ( degreesSpinner );
        return panel;
      }  // getUIPanel
      //  DegreesTracker
      private class DegreesTracker implements ChangeListener {
        public void stateChanged ( ChangeEvent e ) {
          Integer i = (Integer)((JSpinner)e.getSource()).getValue();
          degrees   = i.intValue ();
          repaint();
      }  // DegreesTracker
      //  main
      public static void main ( String[] args ) {
        JFrame f = new JFrame ( "AngleText" );
        f.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
        AngleText app = new AngleText();
        f.getContentPane().add ( app );
        f.getContentPane().add ( app.getUIPanel(), BorderLayout.SOUTH );
        f.setSize ( 200, 200 );
        f.setVisible ( true );
      }  // main
    }  // AngleText

  • How to add a border for Panel (jdk 1.1) ?

    how to add a border for Panel (jdk 1.1) ?

    Border's are a Swing feature, you will have to draw one by yourself (extend Panel and override paint()).

  • How to draw smooth curve in Hyperdraw??

    Okay, I've checked the manual 4x and have been playing with Hyperdraw for 30 minutes and still can't figure out how to draw a smooth bell curve in the Hypereditor... In Cubase, I would take the pencil tool and draw a nice curve but can't seem to figure out how do the same in Logic!
    Could someone pleeeeease lend me a clue...?
    Thanks.

    RealDave wrote:
    "The name on the package may say "Apple," but this is definitely not your typical mac application!"
    Yes, Logic was an acquisition. It has remained to this day "The Redheaded Stepchild". If they ever take
    some engineers off the iOS projects and put them on Logic, the application may shape up. Don't get your hopes too high though. iOS is where they make all the Money. Logic is small potatoes in Apples big picture.
    PS: This message will soon disappear because it contains truth.
    To give them credit, Logic made a HUGE jump in usability when it hit Logic 8.
    I mean, MASSIVE.
    It's actually usable by mortals now.
    Even among professional tools, there are well-designed ones and completely arcane ones with the same functionality.
    Logic grew over decades of adding an extra little limb here, and growing a third chin down there, etc., at the behest of a hundred studio techs missing this or that and calling up the engineers or higher-uppers. It was an extremely powerful, but utterly convoluted MESS.
    The fact that you can now explain the basic structure of Logic 8 in less than three minutes (the fact that it HAS a "basic structure", rather than just a kraken-like reenactment of 80 years of studio development known as "The Environment") makes a huge difference, and, though they've confused people who've whittled the beast into shape over the past twenty years by trying to make the application "Logical" (including key commands), the benefits to users are, IMHO, tremendous.
    I know a number of people who wouldn't have considered working with Logic before (Nuendo users), and now that Logic 9 appears to have fixed many of the most glaring bugs in Logic 8, are adding it to their toolset.

  • Shape Object panel disapear in french version of MOTION3 !

    I found a bug in motion 3. It's about shapes and paintings.
    When you draw a shape with the paint tools and make few changes in the in the shape object panel, this panel disapears. You can't access any paramaters after that.
    I found a solution
    This bug appears when you use the French version of motion 3 (PPC and Intel MAC).
    Use a litle program call LANGSWITCH to switch in the ENGLISH version of motion and the bug disapear. Very strange.
    Hope this topic can help the french users.
    Cheers
    Sorry for my ENGLICH, I'm french

    Thank you very much for your update, Ravikumar, I appreciate it.
    I run the command on English version OS and French version OS, please see the result below, the first one is from English version OS. 
    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.
    C:\Users\Administrator>systeminfo | findstr "Memory"
    Total Physical Memory: 955 MB
    Available Physical Memory: 375 MB
    Virtual Memory: Max Size: 1,979 MB
    Virtual Memory: Available: 1,380 MB
    Virtual Memory: In Use: 599 MB
    C:\Users\Administrator>
    I ran the command systeminfo | findstr "Mémoire" and got the result below.
    Microsoft Windows [version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. Tous droits réservés.
    C:\Users\Administrateur>systeminfo | findstr "Mémoire"
    Mémoire physique totale: 2 047 Mo
    Mémoire physique disponible: 1 213 Mo
    Mémoire virtuelle : taille maximale: 4 095 Mo
    Mémoire virtuelle : disponible: 3 095 Mo
    Mémoire virtuelle : en cours d'utilisation: 1 000 Mo
    C:\Users\Administrateur>
    Can guys who are in charge of French version OS have a look on this problem ? Thanks.
    Jemy

  • How to make smart shape buttons turn colors after clicking on them?

    How to make smart shape buttons turn colors after clicking on them?  I am using buttons as links to learning paths and would like users to know which buttons they have allready clicked on when returning to main menu.

    This is reply I got from Adobe support.  I will try and let you all know what works best:
    Here is the workflow which you can follow to achieve this functionality.
    Puspendra: You can choose image button and then choose from the available image buttons, or click on the folder icon when you select the image button and choose from the Gallery of Captivate 6.
    Puspendra: Few image buttons change color on hover or onclicked, these effects are predefined in them.
    Puspendra: Or you can edit that button on which you are working, from properties Panel.
    Puspendra: The Post and Cancel button on this thread seems like a transparent button in Captivate with different fill and stroke color, and transparency is also less, and with corner radius of 0.
    Puspendra: You will find these all optionns, when you will click on that button and then click on the properties panel.

Maybe you are looking for

  • Safari doesn't display PDFs anymore

    Hi all, after reinstalling 10.8.2 on a Late 2012 mini, Safari does not show PDF files in its window (I have to download the file and open it in other apps). Have I lost an extension or something? How can I fix this please? Thanks

  • Need help for creation of aging report of customer

    Hi Experts,                  I am going to create aging report for custer so have a need of basic concept of creation of aging report. Thanks and Regards vijay Edited by: vijay dwivedi on Mar 9, 2009 1:19 AM

  • Attaching Files to a Z program

    Hi, I want to know if it is possible to attach a file pdf or word to a program not standard. And if it is possible, how can i do that? Thanks in advance Best regards

  • Airplay screen mirroring on 4:3 projector, resolution problems.

    Hi! I have an iPad 3, an ATV3 and a NEC NP400 projector which I'm trying to get to work together. I'm not sure about the projectors resolution, but i know it has a 4:3 aspect ratio. I've tried to use screen mirroring with both the ATV 3 and a VGA ada

  • I want to renew my one year cc subcriptions

    I want to renew my one year cc subscription but the options shows only switch plan or cancel plan ? i renewed my payment details through edit payment details too. Still it's not working .. I didn't see any option to renew. How to renew !! Please help