Resize a component

hello,
I have a JPanel inside 3 components I want to change the size of
the componets wenn one click on the border of the components and move the mouse. the border is to move parallel with the curour of the Mouse.
how can I implement this ???
public void mouseDragged(MouseEvent e)
int x= e.getX();
int y= e.getY();
myComponent.setBounds(my_x, my_y, x,y); // it works not
thanks

public void mouseDragged(MouseEvent e)
int x= e.getX();
int y= e.getY();
myComponent.setBounds(my_x, my_y, x,y); // it
it works not
}Hello,
after you change layout of components you have to re-layout and repaint them. TrymyComponent.revalidate();
myComponent.setBounds(...);
myComponent.repaint();//if its a JComponent and
myComponent.invalidate;
myComponent.setBounds(...);
myComponent.validate();
myComponent.repaint();//for Componentsregards
tim

Similar Messages

  • Resizing Flexbook Component at Runtime

    I downloaded the Flexbook component online and have been
    messing around with it for a few days but still can't find out how
    to get this thing to resize during runtime. I did get it set up to
    size when Initializing the component by using the following code
    attached to this message. This is using embeded assets for the
    book. You can see my method I have been trying by looking at the
    resizeBook function. The resize does work but after a few resizes
    then things get slow or errors appear. So if someone that has done
    this can give me a few pointers on where I need to look or if
    anyone has any suggestions I would love to here it.

    quote:
    Originally posted by:
    JeffHouser
    Without drilling down to your code; this is conceptually how
    I'd approach it:
    1) Create a new component that extends Flexbook
    2) Overwrite the height and width properties to trigger an
    invalidatePropertes / invalidateSize invalidateDispayList . Also
    add variables (usually private) named "_heightChanged" or
    "_WidthChanged"
    3) in the commitProperties / measure / updateDisplayList
    check the "changed" variables and perform actions to do the
    resizing. You'll have to do some digging in the FlexBook code to
    figure it out what needs changing.
    The digging in the Flexbook code to see what needs to be
    changed is the issue I am having. I have been working on a new
    resize function which seems to be getting closer but still has
    weird results where the book appears to have shrunk when you
    rollover certain areas but there is residual images of the larger
    version showing.

  • Using Resize effect to resize the component to 100percent

    Hi all,
    I am using resize component to show the opening of a datagrid which contains itemrenderers.The number of itemrenderers is not fixed hence i want to use the resize effect to resize the grid from height=0 to height=100%. I m not getting any clue as to how to do percent resize with effects.
    Please share ur ideas.

    Thanks for your answer!
    I tried setting the font size to Auto, but the problem is that the text starts off really small, at about 12pt font. I really need it to start with large text, eg to start off as one word at say 60pt size, and be able to go down to two words on the top line and two words on the bottom line, at around 20 pt size. So it starts large, but goes down in size with the more text that is put in.
    I am making editable Avery Labels for teachers - 10 to a page - to put kids names in, or subjects and names.
    Also... is it possible to cenre the text vertically with in the text box?
    Thanks very much for your advice!

  • How to correctly resize a component after loading using SWFLoader

    In an app, I load SWFs into an AIR app, which manages them.
    The AIR app loads the SWF, then creates a 'master' component, which
    manages the loaded SWF. 'manages' means resize, move or provide
    persisted preference values.
    My own test Flex SWFs work OK, while another SWF does not.
    Here's a screenhot:
    http://www.flexolero.com/demos/Portal/shot.png
    Note, that only some part of the loaded Clock resized
    correctly.
    The actual resize is done like this:
    quote:
    public function resize( newW:int, newH:int ):void {
    var loadedSM:SystemManager = SystemManager( ( _inner as
    SWFLoader ).content );
    if ( ( null != _inner )
    && ( null != loadedSM )
    && ( null != loadedSM.application )
    // BindingUtils.bindProperty( lblFromRemote, "text",
    loadedSM.application, '_outChannel' );
    // loadedSM.application[ 'inChannel' ] = 'New';
    loadedSM.application[ 'width' ] = newW-20;
    loadedSM.application[ 'height' ] = newH-20;
    this.width = newW;
    this.height = newH;
    _inner.invalidateSize();
    drawHandles();
    If the Air app finishes loading the SWF, the master component
    attaches a method to the managed SWF:
    (_inner as UIComponent).addEventListener( Event.RENDER,
    fixSizes );
    Actually, Clock sample does not resize as expected at the
    first time it appears.
    Once the Clock is on stage, and I resize it using the mouse,
    it resized as expected.
    Could someone provide a hint?

    maybe you need to calculate scaleX, scaleY instead?
    "justria" <[email protected]> wrote in
    message
    news:g8fbml$e7c$[email protected]..
    > In an app, I load SWFs into an AIR app, which manages
    them. The AIR app
    > loads
    > the SWF, then creates a 'master' component, which
    manages the loaded SWF.
    > 'manages' means resize, move or provide persisted
    preference values.
    >
    > My own test Flex SWFs work OK, while another SWF does
    not. Here's a
    > screenhot:
    >
    >
    http://www.flexolero.com/demos/Portal/shot.png
    >
    > Note, that only some part of the loaded Clock resized
    correctly.
    >
    > The actual resize is done like this:
    >
    >
    quote:
    public function resize( newW:int, newH:int ):void {
    >
    > var loadedSM:SystemManager = SystemManager( ( _inner as
    SWFLoader
    > ).content );
    >
    > if ( ( null != _inner )
    > && ( null != loadedSM )
    > && ( null != loadedSM.application )
    > ) {
    > // BindingUtils.bindProperty( lblFromRemote, "text",
    > loadedSM.application, '_outChannel' );
    > // loadedSM.application[ 'inChannel' ] = 'New';
    > loadedSM.application[ 'width' ] = newW-20;
    > loadedSM.application[ 'height' ] = newH-20;
    > this.width = newW;
    > this.height = newH;
    > _inner.invalidateSize();
    >
    > drawHandles();
    > }
    >
    > }
    >
    >
    > If the Air app finishes loading the SWF, the master
    component attaches a
    > method to the managed SWF:
    >
    > (_inner as UIComponent).addEventListener( Event.RENDER,
    fixSizes );
    >
    > Actually, Clock sample does not resize as expected at
    the first time it
    > appears.
    >
    > Once the Clock is on stage, and I resize it using the
    mouse, it resized as
    > expected.
    >
    > Could someone provide a hint?
    >
    >
    >
    >
    >
    >
    >

  • Resizing custom component with fixed aspect ratio in designer

    Hello,
       I have a custom component that can have a fixed aspect ratio depending on certain property settings and I would like to know if there is any way to make the component resize in the designer in the same manner that the XCelcius built-in spreadsheet table component does?
      It is possible to workaround this somewhat by correcting the width or height of the component after resize, XCelsius sees the change and stores it correctly but sometimes the IDE "remembers" the old value. For example if the component changings its own height programmatically in response to a property and then, while keeping the current component selected, the user resizes the width XCelsius sometimes tries to put the old height back even through it has the correct height saved in the XLF and works fine when compiled.
      Is there a way to properly notify XCelsius IDE of a programmatic width/height change in the component itself in response to a property change?
    Thanks

    The SDK does not support reszing a component using a fixed aspect ratio.
    Do not set the width and height of your component directly. You can set the initial size when dropped onto the canvas using the measure function...
    A better approach is to let the user size the component on the Xcelsius canvas.
    And instead of rendering directly in your add-on, move that code into a child renderer. Then use your aspect ratio to calculate the max size the child renderer can be to fit in the component. Then center your child renderer in the component. That is what I did when I created AnyMap.
    |--------------------------------|
    | component on canvas            |
    |--------------------------------|
    |  |--------------------------|  |
    |  | centered child renderer  |  |
    |  |--------------------------|  |
    |  |                          |  |
    |  |                          |  |
    |  |                          |  |
    |  |--------------------------|  |
    |--------------------------------|
    Regards
    Matt

  • Is it possible to resize a Visual Component?

    I have a visual component that plays and MPG file, but it does not respond to the size I set for it with the setSize method. It sizes it to whatever it wants to. Has anyone seen anything like this? If so, how do I fix it?

    I meet the same problem when i want to resize the component which return by
    calling getVisualComponent();
    Someone can help us?

  • Resizing Accordian based on the content in each component within in it.

    Hi,
    I wanted to know whether is there a way to resize Accordion
    component based on the content in the present tab.In my Accordion I
    am using four Canvas as its four children.The data in each of the
    canvas changes based on the Accordian tab selected. I want to
    dynamically resize the entire accordion based on the content in the
    canvas for that tab.
    In short the height of the Accordion need to change
    dynamically based on the tab selected. I have tried using the
    resizeToContent property but this didn't solve the problem.
    Thanks,
    amar.

    Hi,
    We can resize it.Always give the height and weight in
    percentage format. and turn off the horizontal n vertical scroll
    policy in u r main application.
    Hopes it helps you...

  • Generalized Component Resizing

    Hey people,
    I wrote a "Component Resizer" which takes care of resizing components. Any component as opposed to just a window or a dialog.
    One problem I noticed while resizing dialogs for example was that when I resize the dialog, the internal panes do not get adjust themselves to the new contained size. Now this happens even if I am using say GridBagLayout or GridLayout.
    Another problem I noticed is that then a component inside a container is resized, the new size is retained until the parent container for this component itself is resized. Then it goes back to its original size. I guess this is because of the layout manager but then, this happens even when I use null layout. I have posted the code here (it's really long).
    Any suggestions?
    thanx,
    -vijai.
    Main resize handler:
    * Copyright (c) 2004,
    * Vijayaraghavan Kalyanapasupathy
    * [email protected]
    * See accompanying project license for license terms and agreement.
    * The use of the intellectual property contained herein is subject
    * to the terms of the license agreement. If no license agreement
    * can be found at the locations from where you obtained this
    * sofwtare/file/code fragment contact the author for the license.
    * Contributors: Vijayaraghavan Kalyanapasupathy
    * Created     : 4:03:42 AM, Dec 2, 2004
    * Project     : SwingComponents
    package org.swingcomponents.components;
    import java.awt.Component;
    import java.awt.Cursor;
    import java.awt.Dimension;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import javax.swing.JComponent;
    import org.apache.log4j.Logger;
    /**<p>
    * A configurable listener which can resize any component that can generate mouse drag and mouse events.
    * </p>
    * <p>
    * General model for this is that <br/>
    * <ul>
    *  <li> On demand resizing region margin
    *  <li> On demand resizing directions modification
    * </ul>
    * </p>
    * @author Vijayaraghavan Kalyanapasupathy
    public class ComponentResizer extends    MouseAdapter
                                  implements MouseListener,
                                             MouseMotionListener {
         static final int DEFAULT_MARGIN = 8;
          * The sensitivity on the left side within which a mouse drag is interpreted as a resize action.
         static int c_leftmargin   = DEFAULT_MARGIN;
          * The sensitivity on the right side within which a mouse drag is interpreted as a resize action.
         static int c_rightmargin  = DEFAULT_MARGIN;
          * The sensitivity on the top within which a mouse drag is interpreted as a resize action.
         static int c_topmargin    = DEFAULT_MARGIN;
          * The sensitivity on the bottom within which a mouse drag is interpreted as a resize action.
         static int c_bottommargin = DEFAULT_MARGIN;
          * Sets the default margins for all newly generated resizers.
          * @param p_top The new top margin
          * @param p_left The new left side margin
          * @param p_bottom The new bottom margin
          * @param p_right The new right side margin
         public static void setDefaultMargins(int p_top,int p_left,int p_bottom,int p_right) {
              c_logger.debug("Attempting to change application wide margins to: ("+p_top+","+p_left+","+p_bottom+","+p_right+")");
              c_leftmargin   = p_left > 0 ? p_left : c_leftmargin;
              c_rightmargin  = p_right > 0 ? p_right : c_rightmargin;
              c_topmargin    = p_top > 0 ? p_top : c_topmargin;
              c_bottommargin = p_bottom > 0 ? p_bottom : c_bottommargin;
              c_logger.debug("Changed application wide margins to: ("+c_topmargin+","+c_leftmargin+","+c_bottommargin+","+c_rightmargin+")");
          * Retrieves the default application wide left margin used for newly created resizers.
          * @return The default left margin
         public static int getDefaultLeftMargin() {
              return c_leftmargin;
          * Retrieves the default application wide top margin used for newly created resizers.
          * @return The default top margin
         public static int getDefaultTopMargin() {
              return c_topmargin;
          * Retrieves the default application wide right margin used for newly created resizers.
          * @return The default right margin
         public static int getDefaultRightMargin() {
              return c_rightmargin;
          * Retrieves the default application wide bottom margin used for newly created resizers.
          * @return The default bottom margin
         public static int getDefaultBottomMargin() {
              return c_bottommargin;     
          * The standard log4j logger that all instances of this class use
          * to log messages.
         static Logger c_logger = Logger.getLogger(ComponentResizer.class);
         /* The cursors for each direction */
         /** The top resize cursor */
         static final Cursor c_topcursor         = Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR);
         /** The left side resize cursor */
         static final Cursor c_leftcursor        = Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR);
         /** The right side resize cursor */
         static final Cursor c_rightcursor       = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
         /** The bottom resize cursor */
         static final Cursor c_bottomcursor      = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
         /** The topleft resize cursor */
         static final Cursor c_topleftcursor     = Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR);
         /** The topright resize cursor */
         static final Cursor c_toprightcursor    = Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR);
         /** The bottomleft resize cursor */
         static final Cursor c_bottomleftcursor  = Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR);
         /** The bottomright resize cursor */
         static final Cursor c_bottomrightcursor = Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR);
          * Method that performs initialization stuff.
         protected void InitializeResizer() {
              c_logger.debug("Initializing resizer: ");
              m_leftmargin   = c_leftmargin;
              m_rightmargin  = c_rightmargin;
              m_bottommargin = c_bottommargin;
              m_topmargin    = c_topmargin;
              c_logger.debug("Initialized default margins from application wide settings: ("+m_topmargin+","+m_leftmargin+","+m_bottommargin+","+m_rightmargin+")");
              c_logger.debug("Setting default resize options: ");
              m_allowTopLeftResize    = m_allowTopRightResize    = true;
              m_allowBottomLeftResize = m_allowBottomRightResize = true;
              m_allowLeftResize       = m_allowRightResize       = true;
              m_allowTopResize        = m_allowBottomResize      = true;
              c_logger.debug("Getting component default cursor: ");
              m_componentcursor = m_component.getCursor();
         /** The resizer specific left side margin */
         int m_leftmargin;
         /** The resizer specific top margin */
         int m_topmargin;
         /** The resizer specific right side margin */
         int m_rightmargin;
         /** The resizer specific bottom margin */
         int m_bottommargin;
         /** Indicates that top side resizing should be allowed. */
         boolean m_allowTopResize;
         /** Indicates that bottom side resizing should be allowed. */
         boolean m_allowBottomResize;
         /** Indicates that left side resizing should be allowed. */
         boolean m_allowLeftResize;
         /** Indicates that right side resizing should be allowed. */
         boolean m_allowRightResize;
         /** Indicates that top left resizing should be allowed. */
         boolean m_allowTopLeftResize;
         /** Indicates that top right resizing should be allowed. */
         boolean m_allowTopRightResize;
         /** Indicates that bottom left resizing should be allowed. */
         boolean m_allowBottomLeftResize;
         /** Indicates that bottom right resizing should be allowed. */
         boolean m_allowBottomRightResize;
         /** The component that we are focussing on */
         Component m_component = null;
         /** The layout key for the component */
         String m_layoutkey = null;
          * Creates a new component resizer that attaches itself as a mouse listener and
          * as a mouse motion listener to the given component.
          * @param p_component The component to attach the listener to.
          * @param p_layoutkey The key used in the layout manager of the component's parent for this object.
         public ComponentResizer(Component p_component,String p_layoutkey) {
              super();
              m_component = p_component;
              m_layoutkey = p_layoutkey;
              if(m_component != null) {
                   c_logger.debug("Initializing resizer for: "+m_component);
                   InitializeResizer();
                   m_component.getToolkit().setDynamicLayout(true);
                   m_component.addMouseListener(this);
                   m_component.addMouseMotionListener(this);
              }else {
                   c_logger.warn("Component is null: ");
          * Sets the resizer specific bottom margin.
          * @param p_bottommargin The bottommargin to set.
         public void setBottomMargin(int p_bottommargin) {
              c_logger.debug("Attempting to set top margin to: "+p_bottommargin);
              m_bottommargin = p_bottommargin > 0 ? p_bottommargin : m_bottommargin;
              c_logger.debug("Bottom margin set to: "+m_bottommargin);
          * Sets the resizer specific left side margin.
          * @param p_leftmargin The leftmargin to set.
         public void setLeftMargin(int p_leftmargin) {
              c_logger.debug("Attempting to set left margin to: "+p_leftmargin);
              m_leftmargin = p_leftmargin > 0 ? p_leftmargin : m_leftmargin;
              c_logger.debug("Left margin set to: "+m_leftmargin);
          * Sets the resizer specific right side margin.
          * @param p_rightmargin The rightmargin to set.
         public void setRightMargin(int p_rightmargin) {
              c_logger.debug("Attempting to set right margin to: "+p_rightmargin);
              m_rightmargin = p_rightmargin > 0 ? p_rightmargin : m_rightmargin;
              c_logger.debug("Right margin set to: "+m_rightmargin);
          * Sets the resizer specific top margin.
          * @param p_topmargin The topmargin to set.
         public void setTopMargin(int p_topmargin) {
              c_logger.debug("Attempting to set top margin to: "+p_topmargin);
              m_topmargin = p_topmargin > 0 ? p_topmargin : m_topmargin;
              c_logger.debug("Top margin set to: "+m_topmargin);
          * Returns the bottom margin.
          * @return Returns the bottommargin.
         public int getBottomMargin() {
              return m_bottommargin;
          * Returns the left margin.
          * @return Returns the leftmargin.
         public int getLeftMargin() {
              return m_leftmargin;
          * Returns the right margin.
          * @return Returns the rightmargin.
         public int getRightMargin() {
              return m_rightmargin;
          * Returns the top margin.
          * @return Returns the topmargin.
         public int getTopMargin() {
              return m_topmargin;
          * @return Returns the allowBottomLeftResize.
         public boolean isAllowBottomLeftResize() {
              return m_allowBottomLeftResize;
          * @return Returns the allowBottomResize.
         public boolean isAllowBottomResize() {
              return m_allowBottomResize;
          * @return Returns the allowBottomRightResize.
         public boolean isAllowBottomRightResize() {
              return m_allowBottomRightResize;
          * @return Returns the allowLeftResize.
         public boolean isAllowLeftResize() {
              return m_allowLeftResize;
          * @return Returns the allowRightResize.
         public boolean isAllowRightResize() {
              return m_allowRightResize;
          * @return Returns the allowTopLeftResize.
         public boolean isAllowTopLeftResize() {
              return m_allowTopLeftResize;
          * @return Returns the allowTopResize.
         public boolean isAllowTopResize() {
              return m_allowTopResize;
          * @return Returns the allowTopRightResize.
         public boolean isAllowTopRightResize() {
              return m_allowTopRightResize;
          * @param p_allowBottomLeftResize The allowBottomLeftResize to set.
         public void setAllowBottomLeftResize(boolean p_allowBottomLeftResize) {
              c_logger.debug("Setting bottom left resizing to: "+p_allowBottomLeftResize);
              m_allowBottomLeftResize = p_allowBottomLeftResize;
          * @param p_allowBottomResize The allowBottomResize to set.
         public void setAllowBottomResize(boolean p_allowBottomResize) {
              c_logger.debug("Setting bottom resizing to: "+p_allowBottomResize);
              m_allowBottomResize = p_allowBottomResize;
          * @param p_allowBottomRightResize The allowBottomRightResize to set.
         public void setAllowBottomRightResize(boolean p_allowBottomRightResize) {
              c_logger.debug("Setting bottom right resizing to: "+p_allowBottomRightResize);
              m_allowBottomRightResize = p_allowBottomRightResize;
          * @param p_allowLeftResize The allowLeftResize to set.
         public void setAllowLeftResize(boolean p_allowLeftResize) {
              c_logger.debug("Setting left resizing to: "+p_allowLeftResize);
              m_allowLeftResize = p_allowLeftResize;
          * @param p_allowRightResize The allowRightResize to set.
         public void setAllowRightResize(boolean p_allowRightResize) {
              c_logger.debug("Setting right side resizing to: "+p_allowRightResize);
              m_allowRightResize = p_allowRightResize;
          * @param p_allowTopLeftResize The allowTopLeftResize to set.
         public void setAllowTopLeftResize(boolean p_allowTopLeftResize) {
              c_logger.debug("Setting top left resizing to: "+p_allowTopLeftResize);
              m_allowTopLeftResize = p_allowTopLeftResize;
          * @param p_allowTopResize The allowTopResize to set.
         public void setAllowTopResize(boolean p_allowTopResize) {
              c_logger.debug("Setting top side resizing to: "+p_allowTopResize);
              m_allowTopResize = p_allowTopResize;
          * @param p_allowTopRightResize The allowTopRightResize to set.
         public void setAllowTopRightResize(boolean p_allowTopRightResize) {
              c_logger.debug("Setting top right resizing to: "+p_allowTopRightResize);
              m_allowTopRightResize = p_allowTopRightResize;
          * Following are the methods that do all the real stuff.
         /* We define constants that allow us to determine where the cursor is. */
         static final int TOP         = 0x0001;
         static final int BOTTOM      = 0x0002;
         static final int LEFT        = 0x0100;
         static final int RIGHT       = 0x0200;
         static final int TOPLEFT     = 0x0101;
         static final int TOPRIGHT    = 0x0201;
         static final int BOTTOMLEFT  = 0x0102;
         static final int BOTTOMRIGHT = 0x0202;
         static final int UNKNOWN     = 0x0000;
         protected int whereX(int p_x) {
              // check if on left side
              if(p_x >= 0 &&
                 p_x <= m_leftmargin) {
                   c_logger.debug("Cursor is on LEFT");
                   return LEFT;
              // check if on right side
              if(p_x <= m_component.getWidth() &&
                 p_x >= m_component.getWidth()-m_rightmargin) {
                   c_logger.debug("Cursor is on RIGHT");
                   return RIGHT;
              return UNKNOWN;
         protected int whereY(int p_y) {
              // check if on top side
              if(p_y >= 0 &&
                 p_y <= m_topmargin) {
                   c_logger.debug("Cursor is on TOP");
                   return TOP;
              // check if on bottom side
              if(p_y <= m_component.getHeight() &&
                 p_y >= m_component.getHeight()-m_bottommargin) {
                   c_logger.debug("Cursor is on BOTTOM");
                   return BOTTOM;
              return UNKNOWN;
         protected int where(int p_x,int p_y) {
              c_logger.debug("Determining pointer location: ");
              int l_composite = (whereX(p_x) | whereY(p_y));
              switch(l_composite) {
                   case LEFT:
                        c_logger.debug("Left");
                        break;
                   case RIGHT:
                        c_logger.debug("Right");
                        break;
                   case BOTTOM:
                        c_logger.debug("Bottom");
                        break;
                   case TOP:
                        c_logger.debug("Top");
                        break;
                   case TOPLEFT:
                        c_logger.debug("Top left");
                        break;
                   case TOPRIGHT:
                        c_logger.debug("Top right");
                        break;
                   case BOTTOMLEFT:
                        c_logger.debug("Bottom left");
                        break;
                   case BOTTOMRIGHT:
                        c_logger.debug("Bottom right");
                        break;
              return l_composite;
          * The component's default cursor.
         Cursor m_componentcursor;
         boolean m_resizingcursor;
         boolean m_dragready;
         protected void changeCursor(int p_where) {
              c_logger.debug("Changing cursor: ");
              m_resizingcursor = true;
              switch(p_where) {
                   case LEFT:
                        if(m_allowLeftResize) {
                             m_component.setCursor(c_leftcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   case RIGHT:
                        if(m_allowRightResize) {
                             m_component.setCursor(c_rightcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   case TOP:
                        if(m_allowTopResize) {
                             m_component.setCursor(c_topcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   case BOTTOM:
                        if(m_allowBottomResize) {
                             m_component.setCursor(c_bottomcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   case TOPLEFT:
                        if(m_allowTopLeftResize) {
                             m_component.setCursor(c_topleftcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   case TOPRIGHT:
                        if(m_allowTopRightResize) {
                             m_component.setCursor(c_toprightcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   case BOTTOMLEFT:
                        if(m_allowBottomLeftResize) {
                             m_component.setCursor(c_bottomleftcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   case BOTTOMRIGHT:
                        if(m_allowBottomRightResize) {
                             m_component.setCursor(c_bottomrightcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   default:
                        c_logger.debug("Reverting to default component cursor: ");
                        m_resizingcursor = false;
                        m_component.setCursor(m_componentcursor);
                        break;
         protected void modifyBounds(int p_newx,int p_newy,int p_newwidth,int p_newheight) {
              m_component.setBounds(p_newx,p_newy,p_newwidth,p_newheight);
              m_component.setSize(p_newwidth,p_newheight);
              /*if(m_component.getParent() != null) {
                   LayoutManager l_manager = m_component.getParent().getLayout();
                   if(l_manager != null) {
                        l_manager.removeLayoutComponent(m_component);
                        l_manager.addLayoutComponent(m_layoutkey,m_component);
              if(m_component instanceof JComponent) {
                   ((JComponent) m_component).setPreferredSize(new Dimension(p_newwidth,p_newheight));
              m_component.repaint();
         protected void resizeLeft(MouseEvent p_e) {
              c_logger.debug("Resizing left side: ");
              if(p_e.getX() <= m_component.getWidth()-m_leftmargin-m_rightmargin-4) {
                   int l_newx = m_component.getX();
                   int l_newwidth = m_component.getWidth();
                   c_logger.debug("Eligible for leftward resize: ");
                   if(p_e.getX() <= 0) {
                        c_logger.debug("Leftward drag: ");
                        l_newx = p_e.getX()+m_component.getX();
                        l_newwidth = m_component.getWidth()-p_e.getX();
                   }else {
                        c_logger.debug("anti-Leftward drag: ");
                        l_newx = m_component.getX()-p_e.getX();
                        l_newwidth = m_component.getWidth()-p_e.getX();
                   c_logger.debug("Component new X: "+l_newx);
                   c_logger.debug("Component new W: "+l_newwidth);
                   modifyBounds(l_newx,m_component.getY(),l_newwidth,m_component.getHeight());
         protected void resizeBottom(MouseEvent p_e) {
              c_logger.debug("Resizing bottom side: ");
              if(p_e.getY() >= m_topmargin+m_bottommargin+4) {
                   c_logger.debug("Eligible for bottom side resize: ");
                   int l_newheight = p_e.getY();
                   c_logger.debug("Component new H: "+l_newheight);
                   modifyBounds(m_component.getX(),m_component.getY(),m_component.getWidth(),l_newheight);
         protected void resizeRight(MouseEvent p_e) {
              c_logger.debug("Resizing right side: ");
              if(p_e.getX() >= m_leftmargin+m_rightmargin+4) {
                   c_logger.debug("Eligible for right side resize: ");
                   int l_newwidth = p_e.getX();
                   c_logger.debug("Component new W: "+l_newwidth);
                   modifyBounds(m_component.getX(),m_component.getY(),l_newwidth,m_component.getHeight());
         protected void resizeTop(MouseEvent p_e) {
              c_logger.debug("Resizing top side: ");
              if(p_e.getY() <= m_component.getHeight()-m_topmargin-m_bottommargin-4) {
                   int l_newy = m_component.getY();
                   int l_newheight = m_component.getHeight();
                   c_logger.debug("Eligible for top side resize: ");
                   if(p_e.getY() <= 0) {
                        c_logger.debug("Topward drag: ");
                        l_newy = m_component.getY()+p_e.getY();
                        l_newheight = m_component.getHeight()-p_e.getY();
                   }else {
                        c_logger.debug("anti-Topward drag: ");
                        l_newy = m_component.getY()+p_e.getY();
                        l_newheight = m_component.getHeight()-p_e.getY();
                   c_logger.debug("Component new Y: "+l_newy);
                   c_logger.debug("Component new H: "+l_newheight);
                   modifyBounds(m_component.getX(),l_newy,m_component.getWidth(),l_newheight);
         protected void resizeBottomLeft(MouseEvent p_e) {
              c_logger.debug("Resizing southwest...");
              resizeBottom(p_e);
              resizeLeft(p_e);
         protected void resizeBottomRight(MouseEvent p_e) {
              c_logger.debug("Resizing southeast...");
              resizeBottom(p_e);
              resizeRight(p_e);
         protected void resizeTopLeft(MouseEvent p_e) {
              c_logger.debug("Resizing northwest...");
              resizeTop(p_e);
              resizeLeft(p_e);
         protected void resizeTopRight(MouseEvent p_e) {
              c_logger.debug("Resizing northeast...");
              resizeTop(p_e);
              resizeRight(p_e);
         /* (non-Javadoc)
          * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
         public void mouseDragged(MouseEvent p_e) {
              c_logger.debug("Dragged at: "+p_e.getX()+","+p_e.getY());
              if(m_resizingcursor) {
                   c_logger.debug("Resizing... ");
                   switch(m_component.getCursor().getType()) {
                        case Cursor.E_RESIZE_CURSOR:
                             resizeRight(p_e);
                             break;
                        case Cursor.SE_RESIZE_CURSOR:
                             resizeBottomRight(p_e);
                             break;
                        case Cursor.N_RESIZE_CURSOR:
                             resizeTop(p_e);
                             break;
                        case Cursor.NE_RESIZE_CURSOR:
                             resizeTopRight(p_e);
                             break;
                        case Cursor.S_RESIZE_CURSOR:
                             resizeBottom(p_e);
                             break;
                        case Cursor.SW_RESIZE_CURSOR:
                             resizeBottomLeft(p_e);
                             break;
                        case Cursor.NW_RESIZE_CURSOR:
                             resizeTopLeft(p_e);
                             break;
                        case Cursor.W_RESIZE_CURSOR:
                             resizeLeft(p_e);
                             break;
         /* (non-Javadoc)
          * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
         public void mouseMoved(MouseEvent p_e) {
              c_logger.debug("Moved at: "+p_e.getX()+","+p_e.getY());
              changeCursor(where(p_e.getX(),p_e.getY()));
         /* (non-Javadoc)
          * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
         public void mouseClicked(MouseEvent p_e) {
              c_logger.debug("Clicked at: "+p_e.getX()+","+p_e.getY());
         /* (non-Javadoc)
          * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
         public void mouseEntered(MouseEvent p_e) {
              c_logger.debug("Entered at: "+p_e.getX()+","+p_e.getY());
         /* (non-Javadoc)
          * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
         public void mouseExited(MouseEvent p_e) {
              c_logger.debug("Exited at: "+p_e.getX()+","+p_e.getY());
              if(!m_dragready) {
                   changeCursor(UNKNOWN);
         /* (non-Javadoc)
          * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
         public void mousePressed(MouseEvent p_e) {
              c_logger.debug("Pressed at: "+p_e.getX()+","+p_e.getY());
              if(m_resizingcursor) {
                   m_dragready = true;
         /* (non-Javadoc)
          * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
         public void mouseReleased(MouseEvent p_e) {
              c_logger.debug("Released at: "+p_e.getX()+","+p_e.getY());
              m_dragready = false;
    }Test file:
    * Copyright (c) 2004,
    * Vijayaraghavan Kalyanapasupathy
    * [email protected]
    * See accompanying project license for license terms and agreement.
    * The use of the intellectual property contained herein is subject
    * to the terms of the license agreement. If no license agreement
    * can be found at the locations from where you obtained this
    * sofwtare/file/code fragment contact the author for the license.
    * Contributors: Vijayaraghavan Kalyanapasupathy
    * Created     : 4:55:08 AM, Dec 2, 2004
    * Project     : SwingComponents
    package org.swingcomponents.tests;
    import java.awt.Color;
    import java.awt.Dimension;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    import javax.swing.border.LineBorder;
    import org.netbeans.lib.awtextra.AbsoluteConstraints;
    import org.netbeans.lib.awtextra.AbsoluteLayout;
    import org.swingcomponents.components.ComponentResizer;
    * @author Vijayaraghavan Kalyanapasupathy
    public class TestComponentResizer {
         public static void testUndecoratedDialog() {
              try {
                   JDialog.setDefaultLookAndFeelDecorated(false);
                   JDialog l_dialog = new JDialog(new JFrame());
                   JDialog.setDefaultLookAndFeelDecorated(true);
                   l_dialog.setUndecorated(true);
                   l_dialog.setLocation(400,500);
                   l_dialog.setSize(300,300);
                   l_dialog.setVisible(true);
                   l_dialog.setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE);
                   l_dialog.setBackground(Color.BLACK);
                   JPanel l_panel = new JPanel();
                   l_panel.setBorder(LineBorder.createGrayLineBorder());
                   l_dialog.getContentPane().add(l_panel);
                   ComponentResizer l_resizer = new ComponentResizer(l_dialog,null);
                   l_dialog.pack();
                   l_dialog.show();
              }catch (Throwable t) {
                   t.printStackTrace(System.err);
         public static void testJTextArea() {
              try {
                   JFrame l_frame = new JFrame("Test DropDownDialog") {
                        public Dimension getPreferredSize() {
                             return new Dimension(800,600);
                   JTextArea l_area = new JTextArea(10,40);
                   ComponentResizer l_resizer = new ComponentResizer(l_area,null);
                   l_frame.getContentPane().setLayout(new AbsoluteLayout());
                   l_frame.getContentPane().add(l_area, new AbsoluteConstraints(300,400,300,300));
                   l_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   l_frame.pack();
                   l_frame.show();
              }catch(Throwable t) {
                   t.printStackTrace(System.err);
         public static void main(String[] args) {
              testJTextArea();
              //testUndecoratedDialog();
    }

    Apologies,
    I have left out the AbsoluteLayout and AbsoluteConstraints, but the same effect can supposedly be achieved using null layout and absolute positioning. This doesn't work for me, so if you would like those files (from netBeans) I will post them as well.
    thanx,
    -vijai.

  • Resize component in live view

    Hi there,
    I'm working on a component, which is different as I've done
    in the past. On off possible properties that can be modified is an
    image background, which would be used as preview in the Live View,
    when the component is placed to the Stage, during development. OK,
    this isn't complicated. The issue is that any background image has
    different dimension. I need to resize the component on the Stage,
    when the user changes the background image. Is it possible from the
    component actionscript code to resize the component instance on the
    Stage? When I try to change the size via the setSize method, the
    component is resized, but this change isn't visible during
    development in the Flash IDE. I have to manually resize the
    component on the Stage to see, how the result will look, or I can
    publish and preview the compiled SWF.
    Does anybody have some solution for this issue?
    Thank you,
    Michal

    This is my code :
    public class ResizeComponent extends javax.swing.JFrame {
    public ResizeComponent() {
    initComponents();
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
    jPanel1 = new javax.swing.JPanel();
    lbImage = new javax.swing.JLabel();
    lbText = new javax.swing.JLabel();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Resize Component");
    jPanel1.setLayout(null);
    jPanel1.setBackground(new java.awt.Color(0, 0, 0));
    lbImage.setIcon(new javax.swing.ImageIcon("C:\\Users\\admin\\Desktop\\117.jpg"));
    jPanel1.add(lbImage);
    lbImage.setBounds(10, 10, 200, 300);
    lbText.setFont(new java.awt.Font("Tahoma", 1, 34));
    lbText.setForeground(new java.awt.Color(0, 0, 204));
    lbText.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lbText.setText("Dian Sastro");
    jPanel1.add(lbText);
    lbText.setBounds(10, 320, 200, 30);
    getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width-227)/2, (screenSize.height-385)/2, 227, 385);
    }// </editor-fold>
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new ResizeComponent().setVisible(true);
    // Variables declaration - do not modify
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lbImage;
    private javax.swing.JLabel lbText;
    // End of variables declaration
    Can you help me?

  • How to resize media's visual component resolution

    Hello dear:
    How to resize visual component resolution?
    example:
    I have a movie,this movie's resolution is 800*600dpi,I want this movie's visual component is 600*520.
    Thanks

    public Dimension getPreferredSize() {
                   int w = 0, h = 0;
                   if (vc != null) {
                        Dimension size = vc.getPreferredSize();
                        w = size.width;
                        h = size.height;
                   if (cc != null) {
                        Dimension size = cc.getPreferredSize();
                        if (w == 0)
                             w = size.width;
                        h += size.height;
                   if (w < 160)
                        w = 160;
                   return new Dimension(w, h);
    these codes can't change movie's aspect ratio,eg one movie resolution is 600*500,I can't change this movie resolution to 400*400 on playing. The Transcode.java is chanage the movie file resolution, not my expect.
    I wish the one movie resolution is 600*500,this movie full window in the JPanel that resolution is 400*400.

  • Resizing component in JScrollPane

    Hi!
    I want to do the following: when the button pressed, resize the component(JPanel) inside the JScrollPane.
    I tried the following code:
    jPanel1.setPreferredSize(new Dimension(400, 300));
    jScrollPane1.getViewport().add(jPanel1, null);
    void jButton1_actionPerformed(ActionEvent e)
    jPanel1.setPreferredSize(new Dimension(4000, 3000));
    When I press the button, nothing happens.
    Please help.

    Thank you, Stas, but it didn't work. Now my code is:
    void jButton1_actionPerformed(ActionEvent e)
    jPanel1.setPreferredSize(new Dimension(4000, 3000));
    ((Component)jScrollPane1).invalidate();
    jScrollPane1.validate();
    jScrollPane1.repaint();
    I expected my horizontal and vertical bars to change ( the sign that the panel's size changed), but they didn't.

  • How to resize JPanel at Runtime ??

    Hi,
    Our Project me t a problem as below, we hope to resize JPanel at Runtime , not at design time, ie, when we first click the button called "Move JPanel" , then we click the JPanel, then we can drag it around within main panel, but we hope to resize the size of this JPanel when we point to the border of this JPanel then drag its border to zoom in or zoom out this JPanel.
    Please advice how to do that??
    Thanks in advance.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.util.Vector;
    import javax.swing.*;
    import javax.swing.border.LineBorder;
    import javax.swing.event.*;
    public class ResizeJPanels extends JPanel
        protected JLabel label1, label2, label3, label4, labeltmp;
        protected JLabel[] labels;
        protected JPanel[] panels;
        protected JPanel selectedJPanel;
        protected JButton btn  = new JButton("Move JPanel");
        int cx, cy;
        protected Vector order = new Vector();      
         public static void main(String[] args)
            JFrame f = new JFrame("Test");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new ResizeJPanels().GroupJLabels());
            f.setSize(600,700);
            f.setLocation(200,200);
            f.setVisible(true);
         private MouseListener ml = new MouseAdapter() {  
              public void mousePressed(MouseEvent e) {   
                   Point p = e.getPoint();      
                   JPanel jp = new JPanel();
                   jp.setLayout(null);
                   Component[] c = ((JPanel)e.getSource()).getComponents();
                   System.out.println("c.length = " + c.length);      
                   for(int j = 0; j < c.length; j++) {        
                        if(c[j].getBounds().contains(p)) {     
                             if(selectedJPanel != null && selectedJPanel != (JPanel)c[j])
                                  selectedJPanel.setBorder(BorderFactory.createEtchedBorder());
                             selectedJPanel = (JPanel)c[j];            
                             selectedJPanel.setBorder(BorderFactory.createLineBorder(Color.green));
                             break;             
                        add(jp);
                        revalidate();
    public JPanel GroupJLabels ()
              setLayout(null);
            addLabels();
            label1.setBounds( 125,  150, 125, 25);
            label2.setBounds(425,  150, 125, 25);
            label3.setBounds( 125, 575, 125, 25);
            label4.setBounds(425, 575, 125, 25);
            //add(btn);
            btn.setBounds(10, 5, 205, 25);
                add(btn);
           determineCenterOfComponents();
            ComponentMover mover = new ComponentMover();
             ActionListener lst = new ActionListener() {
                 public void actionPerformed(ActionEvent e) {
                     ComponentMover mover = new ComponentMover();
                           addMouseListener(mover);
                           addMouseMotionListener(mover);
              btn.addActionListener(lst);
              addMouseListener(ml); 
              return this;
        public void paintComponent(final Graphics g)
             super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
             Point[] p;
            g2.setStroke(new BasicStroke(4f));
           for(int i = 0 ; i < order.size()-1; i++) {
                JPanel l1 = (JPanel)order.elementAt(i);
                JPanel l2 = (JPanel)order.elementAt(i+1);
                p = getCenterPoints(l1, l2);
                g2.setColor(Color.black);
               // g2.draw(new Line2D.Double(p[0], p[1]));            
        private Point[] getCenterPoints(Component c1, Component c2)
            Point
                p1 = new Point(),
                p2 = new Point();
            Rectangle
                r1 = c1.getBounds(),
                r2 = c2.getBounds();
                 p1.x = r1.x + r1.width/2;
                 p1.y = r1.y + r1.height/2;
                 p2.x = r2.x + r2.width/2;
                 p2.y = r2.y + r2.height/2;
            return new Point[] {p1, p2};
        private void determineCenterOfComponents()
            int
                xMin = Integer.MAX_VALUE,
                yMin = Integer.MAX_VALUE,
                xMax = 0,
                yMax = 0;
            for(int i = 0; i < labels.length; i++)
                Rectangle r = labels.getBounds();
    if(r.x < xMin)
    xMin = r.x;
    if(r.y < yMin)
    yMin = r.y;
    if(r.x + r.width > xMax)
    xMax = r.x + r.width;
    if(r.y + r.height > yMax)
    yMax = r.y + r.height;
    cx = xMin + (xMax - xMin)/2;
    cy = yMin + (yMax - yMin)/2;
    private class ComponentMover extends MouseInputAdapter
    Point offsetP = new Point();
    boolean dragging;
    public void mousePressed(MouseEvent e)
    Point p = e.getPoint();
    for(int i = 0; i < panels.length; i++)
    Rectangle r = panels[i].getBounds();
    if(r.contains(p))
    selectedJPanel = panels[i];
    order.addElement(panels[i]);
    offsetP.x = p.x - r.x;
    offsetP.y = p.y - r.y;
    dragging = true;
    repaint(); //added
    break;
    public void mouseReleased(MouseEvent e)
    dragging = false;
    public void mouseDragged(MouseEvent e)
    if(dragging)
    Rectangle r = selectedJPanel.getBounds();
    r.x = e.getX() - offsetP.x;
    r.y = e.getY() - offsetP.y;
    selectedJPanel.setBounds(r.x, r.y, r.width, r.height);
    //determineCenterOfComponents();
    repaint();
    private void addLabels()
    label1 = new JLabel("Label 1");
    label2 = new JLabel("Label 2");
    label3 = new JLabel("Label 3");
    label4 = new JLabel("Label 4");
    labels = new JLabel[] {
    label1, label2, label3, label4
    JLabel jl = new JLabel("This is resizeable JPanel at Runtime");
    jl.setBackground(Color.green);
    jl.setOpaque(true);
              jl.setFont(new Font("Helvetica", Font.BOLD, 18));
    JPanel jp = new JPanel();
    jp.setLayout(new BorderLayout());
    panels = new JPanel[]{jp};
              jp.setBorder(new LineBorder(Color.black, 3, false));
    jp.setPreferredSize(new Dimension(400,200));
    jp.add(jl, BorderLayout.NORTH);
    for(int i = 0; i < labels.length; i++)
    labels[i].setHorizontalAlignment(SwingConstants.CENTER);
    labels[i].setBorder(BorderFactory.createEtchedBorder());
    jp.add(labels[i], BorderLayout.CENTER);
    jp.setBounds(100, 100, 400,200);
    add(jp);

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.MouseInputAdapter;
    public class Resizing extends JPanel {
        public Resizing() {
            super(null);
            addPanel();
            PanelControlAdapter control = new PanelControlAdapter(this);
            addMouseListener(control);
            addMouseMotionListener(control);
        private void addPanel() {
            JLabel jl = new JLabel("This is resizeable JPanel at Runtime");
            jl.setBackground(Color.green);
            jl.setOpaque(true);
            jl.setFont(new Font("Helvetica", Font.BOLD, 18));
            JPanel jp = new JPanel();
            jp.setLayout(new BorderLayout());
            jp.setBorder(new LineBorder(Color.black, 3, false));
            jp.add(jl, BorderLayout.NORTH);
            jp.setBounds(50,50,400,200);
            add(jp);
        public static void main(String[] args) {
            JFrame f = new JFrame("Test");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new Resizing());
            f.setSize(500,400);
            f.setLocation(100,100);
            f.setVisible(true);
    class PanelControlAdapter extends MouseInputAdapter {
        Resizing host;
        Component selectedComponent;
        LineBorder black;
        LineBorder green;
        Point offset = new Point();
        Point start = new Point();
        boolean dragging = false;
        boolean resizing = false;
        public PanelControlAdapter(Resizing r) {
            host = r;
            black = new LineBorder(Color.black, 3, false);
            green = new LineBorder(Color.green, 3, false);
        public void mouseMoved(MouseEvent e) {
            Point p = e.getPoint();
            boolean hovering = false;
            Component c = host.getComponent(0);
            Rectangle r = c.getBounds();
            if(r.contains(p)) {
                hovering = true;
                if(selectedComponent != c) {
                    if(selectedComponent != null)  // reset
                        ((JComponent)selectedComponent).setBorder(black);
                    selectedComponent = c;
                    ((JComponent)selectedComponent).setBorder(green);
                if(overBorder(p))
                    setCursor(p);
                else if(selectedComponent.getCursor() != Cursor.getDefaultCursor())
                    selectedComponent.setCursor(Cursor.getDefaultCursor());
            if(!hovering && selectedComponent != null) {
                ((JComponent)selectedComponent).setBorder(black);
                selectedComponent = null;
        private boolean overBorder(Point p) {
            Rectangle r = selectedComponent.getBounds();
            JComponent target = (JComponent)selectedComponent;
            Insets insets = target.getBorder().getBorderInsets(target);
            // Assume uniform border insets.
            r.grow(-insets.left, -insets.top);
            return !r.contains(p);
        private void setCursor(Point p) {
            JComponent target = (JComponent)selectedComponent;
            AbstractBorder border = (AbstractBorder)target.getBorder();
            Rectangle r = target.getBounds();
            Rectangle ir = border.getInteriorRectangle(target, r.x, r.y, r.width, r.height);
            int outcode = ir.outcode(p.x, p.y);
            Cursor cursor;
            switch(outcode) {
                case Rectangle.OUT_TOP:
                    cursor = Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR);
                    break;
                case Rectangle.OUT_TOP + Rectangle.OUT_LEFT:
                    cursor = Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR);
                    break;
                case Rectangle.OUT_LEFT:
                    cursor = Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR);
                    break;
                case Rectangle.OUT_LEFT + Rectangle.OUT_BOTTOM:
                    cursor = Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR);
                    break;
                case Rectangle.OUT_BOTTOM:
                    cursor = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
                    break;
                case Rectangle.OUT_BOTTOM + Rectangle.OUT_RIGHT:
                    cursor = Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR);
                    break;
                case Rectangle.OUT_RIGHT:
                    cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
                    break;
                case Rectangle.OUT_RIGHT + Rectangle.OUT_TOP:
                    cursor = Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR);
                    break;
                default:
                    cursor = Cursor.getDefaultCursor();
            selectedComponent.setCursor(cursor);
        public void mousePressed(MouseEvent e) {
            Point p = e.getPoint();
            if(selectedComponent != null) {
                Rectangle r = selectedComponent.getBounds();
                if(selectedComponent.getCursor() == Cursor.getDefaultCursor()) {
                    offset.x = p.x - r.x;
                    offset.y = p.y - r.y;
                    dragging = true;
                } else {
                    start = p;
                    resizing = true;
        public void mouseReleased(MouseEvent e) {
            dragging = false;
            resizing = false;
        public void mouseDragged(MouseEvent e) {
            Point p = e.getPoint();
            if(dragging || resizing) {
                Rectangle r = selectedComponent.getBounds();
                if(dragging) {
                    r.x = p.x - offset.x;
                    r.y = p.y - offset.y;
                    selectedComponent.setLocation(r.x, r.y);
                } else if(resizing) {
                    int type = selectedComponent.getCursor().getType();
                    switch(type) {
                        case Cursor.N_RESIZE_CURSOR:
                            r.height -= p.y - start.y;
                            r.y = p.y;
                            break;
                        case Cursor.NW_RESIZE_CURSOR:
                            r.width -= p.x - start.x;
                            r.x = p.x;
                            r.height -= p.y - start.y;
                            r.y = p.y;
                            break;
                        case Cursor.W_RESIZE_CURSOR:
                            r.width -= p.x - start.x;
                            r.x = p.x;
                            break;
                        case Cursor.SW_RESIZE_CURSOR:
                            r.width -= p.x - start.x;
                            r.x = p.x;
                            r.height += p.y - start.y;
                            break;
                        case Cursor.S_RESIZE_CURSOR:
                            r.height += p.y - start.y;
                            break;
                        case Cursor.SE_RESIZE_CURSOR:
                            r.width += p.x - start.x;
                            r.height += p.y - start.y;
                            break;
                        case Cursor.E_RESIZE_CURSOR:
                            r.width += p.x - start.x;
                            break;
                        case Cursor.NE_RESIZE_CURSOR:
                            r.width += p.x - start.x;
                            r.height -= p.y - start.y;
                            r.y = p.y;
                            break;
                        default:
                            System.out.println("Unexpected resize type: " + type);
                    selectedComponent.setBounds(r.x, r.y, r.width, r.height);
                    start = p;
    }

  • Is there a way to get a resized element height by ILayoutElement??

    Hi all,
    I am currently working on a means of layout out dynamic text and want my layout to check the RichText component to determine if it has enough space horizontally to fit in the available real estate.  For example, if the available browser width is 300px, and the RichText is 200px, everything is fine and the component can be placed without modification.
    However, if the browser is 300px and the component is 400px, I want to resize the component to fit into the available space and trigger the RichText to present its content in a multi-line format.  I'm really close to a solution, but Ive been unable to find out if there is any means to get the height that the component will be once the width resize is complete.
    The crux of this approach relies upon using ILayoutElement within the layout and resizing as follows:
    element.setLayoutBoundsSize(target.width-HorizontalGap, NaN)
    Now I know that setting the height to NaN causes this method to set the elements height to its preferred height.  I've checked the other available methods such as element.getLayoutBoundsHeight(), element.getPreferredBoundsHeight(), element.getMaxboundsHeight() but these all appear to return the height as if the resize for multi-line didn't exist.
    My question is that I would like to find a way to figure out what the new height is GOING to be once the width resize occurs.
    Any thoughts?  Thanks in advance!
    PS. While stepping through, I noticed there is a protected $height that appears to have the correct height, but there doesn't seem to be a way to access it.  Do I need to subclass ILayoutElement to make this value available or is there something Im not seeing.
    Cheers!

    ok so as it turns out, the $height in the component appears to only be the height of a single line.  What I really want is the complete height of the component when I allow Flex to resize.  For example:
    I have 200px of available space and the RichText has 300px of text.  I want to know the height of the entire component once Flex has resized it to multi-line so that I can tell how far down my next line needs to be.  To accomplish this, I'm doing the following:
    if(element.getLayoutBoundsWidth() > target.width)
         element.setLayoutBoundsSize(target.width, NaN);  // I'm not setting the height of the component because Flex is doing that based upon the width
    The problem is that even after calling setLayoutBoundsSize(), when I call element.getLayoutBoundsHeight() (or element.getLayoutBoundsHeight(true) ), it's still giving me the height of a single line of text and not the total height with multi-line.  I need a way to tell the entire height of the component after Flex has resized for multi-line.
    Thanks so much and I appreciate any help I can get.

  • Component size do not display correctly

    When we put an input text component on a page without resizing it, it takes a default size in the visual page designer, but not in the JSP. thus, when it is displayed in the browser, it takes the browser's default size for this component, which is different from the visual page designer default size.
    Workaround : always resize a component, even if the default size suit your needs. Resizing twice to revert to the default size is Ok:
    Bug removal : there are several ways to remove this bug :
    1) Change the default size to match what is used by Firefox and IE (not very robust because although those two browsers use the same default size, it might be different in other browsers or futur versions.)
    2) Make the default size explicit in the visual page designer AND in the JSP (better)
    3) Idem #2 plus make it equal to the default size in the main browsers (even better)
    4) Idem #3 + make the default size user configurable. The best way to do this, in my opinion, would be to register the default size when a component that was just inserted is resized. Il would make it very easy to insert a series of component with the same size.
    Someting else that is missing is a way to easily insert a series of identical components. Here are two suggestions :
    1) When the user clicks on a component in the palette and then in the page, the mouse pointer should remain the cross, making it possible to click several time and insert several components without returning to the palette. Pressing ESC (for example) would return to the default mouse pointer.
    2) I should be possible to drag/duplicate instead of drag/move. A good solution would be to use Ctrl+drag to duplicate.

    Hi,
    Thanks for your observation and valuable suggestion. I have filed a bug on your behalf.
    Thanks
    MJ

  • Video Player Component using Flash Player 6

    I'm streaming video using Flash Player 6. The problem I am
    having is that the video will only play at a super small size,
    something like 180 x 60 (that's a guess). Is there a way to play
    the video at the 320 width that I redered it as?
    I'm using Flash Player 6 because some code that came with my
    purchased Flash Template does not work unless it's published to
    Flash Plaey 6.
    Thanks in advance!

    Hello Melissa,
    I might not be understanding the question right, but if you
    are using Flash
    Player 6, and the Flash Player 6 video player component, you
    can resize the
    video by resizing the component on the stage (just drag and
    make it larger).
    Let me know if that works for you.
    Jesse H.
    Adobe Community Expert
    My site:
    http://www.jharding.com
    Free Blog Radio:
    http://www.tornadostream.com
    > I'm streaming video using Flash Player 6. The problem I
    am having is
    > that the
    > video will only play at a super small size, something
    like 180 x 60
    > (that's a
    > guess). Is there a way to play the video at the 320
    width that I
    > redered it as?
    > I'm using Flash Player 6 because some code that came
    with my
    > purchased Flash
    > Template does not work unless it's published to Flash
    Plaey 6.
    > Thanks in advance!

Maybe you are looking for

  • How do you "power search"on the new  itunes?

    How does one power search on the new itunes? Is it still possible?

  • RFC call in a Webdynpro Java help?

    Hi all, I need used in my webdynpro Java a FM that I created in R3. Exactly I need load in a combo box  the results of my function module. I do it this but not works correctly. I think thats my code is not correctly..Anybody can help me? public void

  • Max  date in analytic function

    I have records that has repeating load dates. I would like to pick the records that has the maximum load_dates. My source data looks like this - ( select 60589 as C_number, to_date('01/08/2012','DD/MM/YYYY') as load_dt from dual union all select 6076

  • IOS 4.2.1 on iPhone 4 and WPA2 Personal

    Since 4.2.1 my iPhone 4 has refused to connect to my Airport Extreme or TC networks UNLESS you turn all security off. Have tried all the usual reset to factory defaults but have been unable to get the iPhone 4 to play ball and cannot revert to an ear

  • BAPI_GETFLIGHT vs BAPI_SFLIGHT_GETLIST

    Dear all, I am a newby in netweaver Webdynpro and running the very good tutorial SDN provide us. For the first time, I am trying to connect to a SAP IDES standard system 4.6C. I used the BAPI_GETFLIGHT tutorial, unfortunately I can't find this BAPI.