Component resizing behaviour when maximized

I am wanting to change the behaviour when the main frame is re-sized that only one Jlist in a component consiting of multiple JLists is the only component resized.
This is currently occuring, however it is the last JList, i wish to be able to nominate the JList that will be resized.
i.e. the "Name" JList, no the "Up Rate" Jlist.
This is the gui non-maximized:
http://img225.imageshack.us/img225/5061/guinormal8xd.png
This is the gui maximized as is:
http://img225.imageshack.us/img225/9296/guimaximised5tb.png
This is the gui as i would like it:
http://img215.imageshack.us/img215/8238/guimaximised11el.png
Can anyone give me a few pointers as to how to achieve this?

[url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]How to Use Layout Managers
For example when using a BorderLayout. You could add one list to the "WEST" and one to the "CENTER". As the frame is resized the available space will be added (or removed) from the component in the center.
Or, I believe a GridBadLayout has weightX paramenter which allows you to specify which component gets extra space when the frame is resized.

Similar Messages

  • Cursor behaviour when quick key zooming

    Is there a way to change the cursor behaviour when using a quick key (cmd-space) zoom?
    When laying out complex forms i often need to quickly zoom in to accurately position (say) a checkbox i've just place on the page, but if i cmd-space zoom i have to then click the arrow tool before i can continue positioning the element in question.
    Not a big problem with one element but if i need to zoom in tight to reposition a number of elements i've selected, the need to click the arrow tool after the zoom causes that selection to deselect. Which means zooming in on each one to position it.
    In short, is there any way for acrobat to revert to the current tool after a quick key zoom?

    JFrame.setDefaultLookAndFeelDecorated(true) has bugs! I agree. I created my own lookAndFeel extending mostly from MetalUI components. I then made my own RootPaneUI and TitlePane, so I was knee deep in the MetalRootPaneUI code. You cannot fix the flicker problem. When resizing, the new bounds are determined and then setBounds is called on the window, either a Frame or Dialog. The setBounds call forces lightWeight components to repaint(), causing the flicker.
    sometimes, when resizing, the resize cursor will not be reset after resizing.I found this one two. I actually fixed this one. In the MetalRootPaneUI.MouseInputHandler.mouseEntered(line:878):public void mouseEntered(MouseEvent ev)
      Window w = (Window)ev.getSource();
      // change this line to the one below it
      //lastCursor = w.getCursor();
      lastCursor = Cursor.getPredefinedCursor(0);//should work now
      mouseMoved(ev);
    }What appears to happen is when a Dialog is closed over a JFrame, the cursor gets screwed up somehow. I was able to recreate the bug. I simply made a JFrame with a button that created a dialog. I then used the titleBar's closeButton to close the dialog. Just after clicking the closeButton, I moved my mouse quickly over the edge of the dialog before it had a chance to disappear. Sometimes I was fast enough and the cursor got stuck. The above code is all I could do to fix it.
    The resizing was filckery or slow whether I used the real MetalRootPaneUI or my own. I also tried the dynamicLayout and noerasebackground with unacceptable trade-offs. Luckily my app only has one JFrame. So, I only setDefaultLookAndFeelDecorated JDialogs, which are never resizable in my app. This means that my JFrame is the only window in the app that uses the OS TitleBar rather than my own. Although, my JFrame resizes without flickering.

  • 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.

  • JTextField resizing behaviour.

    I would like to know how to consistently configure a JTextField to have a fixed size no matter the container's layout, the look and feel, and the field content.
    Here is an example :
    import javax.swing.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    public class DemoDateField2 {
        private static int currentLookAndFeelId;
        public static void main(String[] args) {
            final JTextField fixedColumnsField = new JTextField("It has 10 columns", 10);
            final JTextField notFixedColumnsField = new JTextField("It has no fixed columns");
            JComboBox comboBox = new JComboBox();
            comboBox.setPrototypeDisplayValue("01 Jan 1970");
            comboBox.setEditable(true);
            comboBox.setModel(new DefaultComboBoxModel(new String[]{"01 Jan 1970", "02 Jan 1970", "03 Jan 1970"}));
            JButton clearFixedButton = new JButton("Clear Fixed");
            JButton clearNotFixedButton = new JButton("Clear NotFixed");
            JButton lafButton = new JButton("Look and feel");
            JPanel panel = new JPanel();
            panel.add(fixedColumnsField);
            panel.add(notFixedColumnsField);
            panel.add(comboBox);
            panel.add(clearFixedButton);
            panel.add(clearNotFixedButton);
            panel.add(lafButton);
            final JFrame frame = new JFrame();
            frame.getContentPane().add(panel);
            frame.setSize(640, 480);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
            clearFixedButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    fixedColumnsField.setText("");
            clearNotFixedButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    notFixedColumnsField.setText("");
            lafButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    UIManager.LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
                    if (currentLookAndFeelId == infos.length - 1) {
                        currentLookAndFeelId = 0;
                    else {
                        currentLookAndFeelId++;
                    try {
                        UIManager.setLookAndFeel(infos[currentLookAndFeelId].getClassName());
                    catch (Exception e1) {
                    SwingUtilities.updateComponentTreeUI(frame);
    }In this example, the first text field (the fixed column one) has a bad behaviour when switching LAF (the text is clipped in Windows LAF).
    The second field is ok when switching LAF, but if you clear it and resize the frame, its widht is near zero.
    The combo box behaves perfectly in both situations : LAF and clear&resize...
    To sum it up : is it possible to have the same behaviour with a JTextField as with a JComboBox and its prototype method ?

    Hello Phil,
    yes, there are always side effects when changing the L&F. I have no perfect solution, but when you add a
    import java.awt.*;
    notFixedColumnsField.setPreferredSize(new Dimension (140,20));at least the shrinking doesn't happen any more when the field is empty.
    You may also declare the field's dimension in dependence of another field such as
    notFixedColumnsField.setPreferredSize(fixedColumnsField.getPreferredSize());hth
    J�rg

  • Show resize cursor when mouse hovers edge of window?

    When I'm not using the standard window chrome, is there an easy way to show the resize cursor when the mouse hovers a window edge?

    thanks, that's the component I was looking for (assuming I can now change the fonts, colour etc)
    I have done the following and it kind of works: it should highlight the text and show the tooltip. However, it kind of gets stuck every now and then...two things: it takes some time before the tooltip appears (1 sec): is there a way to make it immediate, simultanous to the highligh? also, I have a few Jtextfield, as you may remember..as I hover the mouse over each of them, it all works fine, but when I go back to a jtextfield previously hovered over and highlighted, nothing happens, until I randomly click around and then works again. Any ideas? thanks a lot
    myJTextField.addMouseListener(new MouseAdapter(){
                     public void mouseEntered(MouseEvent e) {
                        ((JTextField) e.getSource ()).requestFocus();
                        ((JTextField) e.getSource ()).selectAll(); // highlight the text
                        ((JTextField) e.getSource ()).setToolTipText("text");
                       

  • How a custom component is called when we install a custom component in UCM.

    How a custom component is called when we install a custom component in UCM.
    On what event the component services will be activated and called.
    Suppose i create a Custom service name MULTIPLECHECKIN then this service will be called on what event and where it will be defined to call.

    Saurabh,
    the code is packed in the component (see component\Security Filter\java\Security Filter\ModifyAttributesFilter.java - the first Security Filter is the component name, the other Security Filter is the Java package name).
    What is important:
    - your class must implement the FilterImplementor interface (you will need UCM standard classes - server.zip in your classpath) and its doFilter method
    How the filter is executed?
    - actually, in this case you don't need any new service - you can use the standard 'hook', which is provided by standard checkin services
    - in Component Wizard create a new component, add your compiled class to it (make sure you follow the rules not to end up in classpath issues)
    - in Component Wizard click the 'Java Code' tab. Here you can add a Custom filter called validateCheckinData, which is executed by standard checkin services. If you parametrize the filter to call your class created above, you are done.
    'Working with Content Components' manual (e.g. here: http://download.oracle.com/docs/cd/E10316_01/cs/cs_doc_10/documentation/developer/using_components_10en.pdf) can give you a basic picture. A better resource is Bex Huff's book - I would recommend you to get it, because it has a step-by-step HelloWorld example which can guide you through Component Wizard. I could also send you my own component (send me an email at [email protected]) which implements a filter for user quotas, so you just need to "replace classes".
    As for the other half of your task, searching for the file in the database server will work only if you use database as your storage (ie. install and configure File Store Provider component accordingly). Of course, you could do a search for file in this case - just consider that you will be comparing two BLOBs rather than two relatively short check-sums (most likely strings or arrays of bytes). Besides, it will not work if you use filesystem as your storage.
    Jiri

  • How can you have the app tabs positioned to the right of the FireFox button when maximized?

    App tabs are '''normally''' positioned to the right of the FireFox button. However, when you shrink the window and then maximize again the app tabs appear below the FireFox button.
    Anytime an app tab is open and you maximize, adjust window, maximize, the entire tab bar is bumped down under the FireFox button. Having just regular tabs open does not have this problem as they correctly position themselves to the right of the FireFox button when maximized.

    Zero is in the middle where it says "none".

  • Strange behaviour when looping MIDI

    Hi,
    I encounter a strange behaviour when looping MIDI:
    1) Created a new MIDI track
    2) Recorded two bars of MIDI drum track (e.g. just a bass drum with Indie Kit Live) via my EDIROL and MIDI piano.
    3) played it back: works
    4) checked the "Loop" box
    5) played it back: after the 4th repeat the drum pattern changes. either it misses two beats or does not play the bass drum but the hihat for two beats.
    I'm using Logic Pro 8.
    Can someone tell me what's going on and how this can be resolved?
    Also on some occasions I have the following behaviour:
    1) Recorded MIDI in loop mode (a few takes).
    2) Played it back: Did not produce any sound.
    3) Tried a different take from the take folder: Did not produce any sound.
    4) Tried to mute/unmute track and different take from the folder: Did not produce any sound.
    5) Tried to MIDI mute/unmute different takes from the folder: Did not produce any sound.
    6) Closed/reopened project and MIDI unmuted the take: Played fine.
    Thanks a lot for some help with those two problems.
    Alex

    Did not happen again in Logic 9 and after starting a fresh project.

  • Different behaviours when exporting pdf

    hi,
    i'm facing a strange behaviour when trying to export a pdf that is generated from db. i want to make pdfs available via dialog box. i set disposition to attachment in the response header. whereas FireFox shows the dialog box (as expected), IE renders the pdf in the same window:
       * downloads the report in the requested export format
      public String exportReport()
        String outcome ="error";
        LayoutXSLT layout = null;
        ByteArrayInputStream xslt_bais=null;
        ByteArrayInputStream xml_bais=null;
        byte[] content=null;
        ByteArrayOutputStream fosByte = new ByteArrayOutputStream ();
        String fileName = "Report";
        String disposition="attachment";  
        String contentType="application/pdf";
        FacesContext faces = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse) faces.getExternalContext().getResponse();
        FileExporter fex = new FileExporter();
        if (report != null && report.getRowCount()>0)
          try
            layout = accountingRemoteInterface.createXSLTLayout(userID, report.getForm().getId(), XSLT_TYPE.PDF);
          catch (UserAccountingException aex)
            messageError = errorWriter.writeUserAccountingException(rb, aex);
          if (layout != null)
            xslt_bais = new ByteArrayInputStream(layout.getXsltContent()); 
            try
              xml_bais = new ByteArrayInputStream(report.createXMLStream());
              XSLTHelper.doFOP(xslt_bais, xml_bais, fosByte, null);               
              fosByte.flush();
              fosByte.close();        
              content = fosByte.toByteArray();
              reportAvailable=1;
              outcome = fex.export(content, contentType, fileName, disposition, response);
              faces.responseComplete();
            catch (XMLWriterException xex)
              messageError = errorWriter.writeXmlException (rb, xex);
            catch (TransformerException tex)
              messageError = errorWriter.writeTransformerException(rb, tex);
            catch (FOPException foex)
              messageError = errorWriter.writeFopException(rb, foex);
            catch (IOException e)
              e.printStackTrace();
        else
          filteredItems=limitedItems=reportItems="";
          messageError=rb.getString("ERROR_NO_PDF_AVAILABLE");
        return outcome;
      public String export(byte[] cnt, String cType, String fName, String dispo,
          HttpServletResponse response) throws IOException
        String outcome = "error";
        byte[] content = cnt;
        String contentType = cType;
        String fileName = fName;
        String disposition = dispo;
        response.reset();
        response.setContentType(contentType);
        response.setContentLength(content.length);
        response.setHeader("Content-disposition", disposition + ";filename=\"" + fileName + "\"");
        response.setHeader("Cache-Control", "cache, must-revalidate");
        ServletOutputStream out = response.getOutputStream();
        out.write(content);
        outcome = "success";
        return outcome;
        }Any help appreciated!

    i checked the server log and couldn't find anything excepting a warning when setting the pdf layout :
    WARN  [BreakingAlgorithm] Line 1 of a paragraph overflows the available area. (fo:block, "****************")you mean i shouldn't stop the render response phase, don't you? what's the alternative? a file servlet?

  • Quicklook does not work with WMV files and quick look no longer maintains resized views when viewing from a folder using the up/down arrows

    Quicklook does not work with WMV files and quick look no longer maintains resized views when viewing from a folder using the up/down arrows. Any fixes?

    Same problem here...

  • Weird behaviour when applying XLST in PL/SQL

    I came across this strange behaviour when applying XSLT to an XML document. Below is a simplified version, based on some code that I found in OTN
    declare
    indoc VARCHAR2(2000);
    xsldoc VARCHAR2(2000);
    myParser dbms_xmlparser.Parser;
    indomdoc dbms_xmldom.domdocument;
    xsltdomdoc dbms_xmldom.domdocument;
    xsl dbms_xslprocessor.stylesheet;
    outdomdocf dbms_xmldom.domdocumentfragment;
    outnode dbms_xmldom.domnode;
    proc dbms_xslprocessor.processor;
    buf varchar2(2000);
    begin
    indoc := '<emp><empno> 1</empno> <fname> robert </fname> <lname>
    smith</lname> <sal>1000</sal> <job> engineer </job> </emp>';
    xsldoc :=
    '<?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output encoding="utf-8"/>
    <xsl:variable name="CR">
    <xsl:text>
    </xsl:text>
    </xsl:variable>
    <xsl:template match="/">
    <xsl:value-of select="$CR" />
    <xsl:value-of select="$CR" />
    </xsl:template>
    </xsl:stylesheet>';
    myParser := dbms_xmlparser.newParser;
    dbms_xmlparser.parseBuffer(myParser, indoc);
    indomdoc := dbms_xmlparser.getDocument(myParser);
    dbms_xmlparser.parseBuffer(myParser, xsldoc);
    xsltdomdoc := dbms_xmlparser.getDocument(myParser);
    xsl := dbms_xslprocessor.newstylesheet(xsltdomdoc, '');
    proc := dbms_xslprocessor.newProcessor;
    --apply stylesheet to DOM document  
    outdomdocf := dbms_xslprocessor.processxsl(proc, xsl, indomdoc);
    outnode := dbms_xmldom.makenode(outdomdocf);
    -- PL/SQL DOM API for XMLType can be used here
    dbms_xmldom.writetobuffer(outnode, buf);
    dbms_output.put_line(buf);
    end;
    I would expect this to output two carriage returns and this is what I get with xsltproc on the Linux server. Instead, it outputs the entire source XML document without the tags, as shown below.
    1 robert
    smith1000 engineer 1 robert
    smith1000 engineer
    Now, if you change the definition of the CR variable to add some text, for example to
    <xsl:variable name="CR">
    <xsl:text>XX
    </xsl:text>
    It outputs:
    XX
    XX
    which is what I would expect.
    Does anyone have any idea what is going on here? Changing the variable definition to <xsl:variable name="CR" select="'&#xD;&#xA;'" /> fixes the problem by the way.

    I came across this strange behaviour when applying XSLT to an XML document. Below is a simplified version, based on some code that I found in OTN
    declare
    indoc VARCHAR2(2000);
    xsldoc VARCHAR2(2000);
    myParser dbms_xmlparser.Parser;
    indomdoc dbms_xmldom.domdocument;
    xsltdomdoc dbms_xmldom.domdocument;
    xsl dbms_xslprocessor.stylesheet;
    outdomdocf dbms_xmldom.domdocumentfragment;
    outnode dbms_xmldom.domnode;
    proc dbms_xslprocessor.processor;
    buf varchar2(2000);
    begin
    indoc := '<emp><empno> 1</empno> <fname> robert </fname> <lname>
    smith</lname> <sal>1000</sal> <job> engineer </job> </emp>';
    xsldoc :=
    '<?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output encoding="utf-8"/>
    <xsl:variable name="CR">
    <xsl:text>
    </xsl:text>
    </xsl:variable>
    <xsl:template match="/">
    <xsl:value-of select="$CR" />
    <xsl:value-of select="$CR" />
    </xsl:template>
    </xsl:stylesheet>';
    myParser := dbms_xmlparser.newParser;
    dbms_xmlparser.parseBuffer(myParser, indoc);
    indomdoc := dbms_xmlparser.getDocument(myParser);
    dbms_xmlparser.parseBuffer(myParser, xsldoc);
    xsltdomdoc := dbms_xmlparser.getDocument(myParser);
    xsl := dbms_xslprocessor.newstylesheet(xsltdomdoc, '');
    proc := dbms_xslprocessor.newProcessor;
    --apply stylesheet to DOM document  
    outdomdocf := dbms_xslprocessor.processxsl(proc, xsl, indomdoc);
    outnode := dbms_xmldom.makenode(outdomdocf);
    -- PL/SQL DOM API for XMLType can be used here
    dbms_xmldom.writetobuffer(outnode, buf);
    dbms_output.put_line(buf);
    end;
    I would expect this to output two carriage returns and this is what I get with xsltproc on the Linux server. Instead, it outputs the entire source XML document without the tags, as shown below.
    1 robert
    smith1000 engineer 1 robert
    smith1000 engineer
    Now, if you change the definition of the CR variable to add some text, for example to
    <xsl:variable name="CR">
    <xsl:text>XX
    </xsl:text>
    It outputs:
    XX
    XX
    which is what I would expect.
    Does anyone have any idea what is going on here? Changing the variable definition to <xsl:variable name="CR" select="'&#xD;&#xA;'" /> fixes the problem by the way.

  • Odd gmail behaviour when using mail.app

    Hello there,
    Ever since upgrading to Mavericks, I've been experiencing odd behaviour when sending messages from my gmail account in mail.app. I send a message and up to ten copies of the message appear in mail.app's trash.
    Does anyone know what might be the cause of this?
    many thanks,
    Chidi

    this is a setting in gmail that interfer with mail.app
    the setting is that mail.app is that when you type a mail it will auto save it while you are typing. and gmail will delete the saved onece and the mail.app will create a new all the time
    duno how to turn this off, try by rebuilding the mailbox in mail.app

  • Flash video - behaviour when buffering stops

    I've started using progressive Flash video on one of my sites. The objective is to provide subtitling for foreign learners of English. It works well, subtitles jump around on full screen, but that's just cosmetic.
    However, one of my testers reports that periodically the playback stops, and you have to press the start button to continue.  The desired behaviour would be à la YouTube, where it pauses, the buffer fills, it continues. I've only seen this problem once on my system.
    There are references to this in the discussions, eg http://forums.adobe.com/message/3794903#3794903  but few answers.
    So, can I ask
    1.  With progressive flash video, what is the expected default behaviour when the playback hits the end of the buffer because too little data is being downloaded - is it supposed to recover and continue automatically ?
    or
    2.  If not, is there a known fix ?
    My goodness, it's a black art Flash Video !  Here's a link where maybe you'll see the problem.
    http://www.regardez-des-videos-en-anglais.org/January2012/index.htm
    ... and if you don't you can enjoy the famous bit of the Rocky Horror Show !

    I've started using progressive Flash video on one of my sites. The objective is to provide subtitling for foreign learners of English. It works well, subtitles jump around on full screen, but that's just cosmetic.
    However, one of my testers reports that periodically the playback stops, and you have to press the start button to continue.  The desired behaviour would be à la YouTube, where it pauses, the buffer fills, it continues. I've only seen this problem once on my system.
    There are references to this in the discussions, eg http://forums.adobe.com/message/3794903#3794903  but few answers.
    So, can I ask
    1.  With progressive flash video, what is the expected default behaviour when the playback hits the end of the buffer because too little data is being downloaded - is it supposed to recover and continue automatically ?
    or
    2.  If not, is there a known fix ?
    My goodness, it's a black art Flash Video !  Here's a link where maybe you'll see the problem.
    http://www.regardez-des-videos-en-anglais.org/January2012/index.htm
    ... and if you don't you can enjoy the famous bit of the Rocky Horror Show !

  • Hide title when maximizing window

    Hi everybody,
    Does anybody know how to hide the window title when maximizing a window ? (as is does in standard forms without Headstart)
    I am new to Headstart so any help will be much appreciated !
    Michiel Arentsen

    Hi everybody,
    Does anybody know how to hide the window title when maximizing a window ? (as is does in standard forms without Headstart)
    I am new to Headstart so any help will be much appreciated !
    Michiel Arentsen

  • How to resize JTextArea when frame has been resized

    Hi!
    At first, I have to complain, that these Layout Managers drive me crazy. Even as an experienced developer, very often, I am frustrated and I am never 100% sure which layout manager I should choose (according to the Sun How Tos) and once I have decided, the never do what I'd expect them to do. I'm not sure if I am just too dumb or if there might be an unreasonable API architecture/design...
    OK, here again is a problem with layouts. And it's basically like this (See code for details):
    Row one: Text Area 1, Button 1; Row two: Text Area 2, Button 2.
    I just want to have the buttons aligned, the text areas should be same sized. Moreover, I want to disable vertical resizing and on horizontal resizing, I want the TextArea to be resized as well.
    But it doesn't. I could partly solve the vertical resizing by setting the minimum size, but the maximum size dosen't seem to work. I can still enlarge the window. The horizontal resizing doesn't work at all. I tried border layout before and set the Text area as center, but it also doesn't work. I read that some layout managers use only preferred size, some also use min and max size and this is very confusing.
    And I saw that component resizing should work for box layout as well (see Sun box layout how to). If this problem is easy to solve, please excuse my question, but I couldn't find it in the forum.
    OK, here is an SSCCE:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package com.ettex.componentresizetest;
    import java.awt.ComponentOrientation;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import javax.swing.BoxLayout;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    * @author Jan Wedel
    public class ComponentResizeTest extends JFrame{
         static ComponentResizeTest frame;
         JPanel mainPanel;
         JPanel firstPanel;
         JPanel secondPanel;
         JPanel statusPanel;
         JButton firstButton;
         JButton secondButton;
         JTextField firstField;
         JTextField secondField;
         JLabel statusText;
         public ComponentResizeTest(String name) {
              super(name);
         public void addComponentsToPane() {
              Container pane = this.getContentPane();
              mainPanel = new JPanel();
              firstPanel = new JPanel();
              secondPanel = new JPanel();
              statusPanel = new JPanel();
              pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
              firstField = new JTextField();
              secondField = new JTextField();
              statusText = new JLabel("Status Bar");
              firstField.setPreferredSize(new Dimension(500, 25));
              secondField.setPreferredSize(new Dimension(500, 25));
              secondButton = new JButton("A Button");
              firstButton = new JButton("Another Button");
              firstPanel.add(firstField);
              firstPanel.add(secondButton);
              firstPanel.setLayout(new BoxLayout(firstPanel, BoxLayout.X_AXIS));
              secondPanel.add(secondField);
              secondPanel.add(firstButton);
              secondPanel.setLayout(new BoxLayout(secondPanel, BoxLayout.X_AXIS));
              mainPanel.add(firstPanel);
              mainPanel.add(secondPanel);
              mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
              statusPanel.add(statusText);
              FlowLayout tabLayout = new FlowLayout();
              tabLayout.setAlignment(FlowLayout.LEFT);
              firstPanel.setLayout(tabLayout);
              firstPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
              secondPanel.setLayout(tabLayout);
              secondPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
              statusPanel.setLayout(tabLayout);
              statusPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
              pane.add(mainPanel);
              pane.add(statusPanel);
          * Create the GUI and show it.  For thread safety,
          * this method should be invoked from the
          * event dispatch thread.
         private static void createAndShowGUI() {
              //Create and set up the window.
              frame = new ComponentResizeTest("Component Resize Test");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              //Set up the content pane.
              frame.addComponentsToPane();
              /* Layout componets */
              frame.pack();
              /* Prevent vertical resize */
              Dimension cur = frame.getSize();
              Dimension max = frame.getMaximumSize();
              frame.setMinimumSize(new Dimension(cur.width, cur.height));
              frame.setMaximumSize(new Dimension(max.width, cur.height));
              frame.invalidate();
              /* show frame */
              frame.setVisible(true);
          * @param args the command line arguments
         public static void main(String[] args) {
              //Schedule a job for the event dispatchi thread:
              //creating and showing this application's GUI.
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        createAndShowGUI();
    }Thanks, Jan
    Edited by: stelzbock on Nov 9, 2009 6:54 AM

    This is what I get using TableLayout:
    The maximum horizontal size of the text area is achieved by specifying the columns in the constructor,
    although I think it's bad since resizing smaller does reduce the text area. I would use FILL constraint for the text area column and remove the 'filler' column at the end.
    import info.clearthought.layout.TableLayout;
    import java.awt.EventQueue;
    import javax.swing.*;
    public class TestLayout {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    TableLayout layout = new TableLayout(new double[][] {
                            // columns
                            { TableLayout.PREFERRED, TableLayout.PREFERRED,
                               TableLayout.FILL },
                            // rows
                            { TableLayout.PREFERRED, TableLayout.FILL,
                              TableLayout.PREFERRED, TableLayout.FILL },
                    JPanel panel = new JPanel(layout);
                    panel.add(new JScrollPane(new JTextArea(3, 30)), "0,0,0,1");
                    panel.add(new JButton("One"), "1,0");
                    panel.add(new JScrollPane(new JTextArea(3, 30)), "0,2,0,3");
                    panel.add(new JButton("Two"), "1,2");
                    JFrame frame = new JFrame("Test");
                    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    frame.getContentPane().add(panel);
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
    }Ah, in your code you have text fields, not area and want to restrict vertical resize. Then I get this:
    TableLayout layout = new TableLayout(new double[][] {
                            // columns
                            { TableLayout.FILL, TableLayout.PREFERRED },
                            // rows
                            { TableLayout.PREFERRED, TableLayout.PREFERRED,
                                TableLayout.FILL, TableLayout.PREFERRED },
                    layout.setVGap(5);
                    layout.setHGap(5);
                    JPanel panel = new JPanel(layout);
                    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
                    panel.add(new JTextField(30), "0,0");
                    panel.add(new JButton("One"), "1,0");
                    panel.add(new JTextField(30), "0,1");
                    panel.add(new JButton("Two"), "1,1");
                    panel.add(new JLabel("Status"), "0,3,1,3");Another more advanced layout to look at is MigLayout.
    Edited by: WalterLaan on Nov 9, 2009 8:23 AM

Maybe you are looking for

  • Why won't iCal display multi-day events in month view?

    This is frustrating. If someone sends me a calendar event that lasts multiple days from Calendar software that ACTUALLY WORKS  (hint hint hint Google Calendar, Outlook), and if I accept this event, it only displays the FIRST DAY of the event in iCal'

  • CK-20W audio cable

    I wonder if I have to use a special audio cable from CK-20W to the car´s sound system? I only get sound in the left channel. There is no problem with my car receiver. I have tried to switch L and R cables and get sound in right speakers if I put L in

  • What happened to JOIN SMOOTH? (It's gone?!?)

    Title says it all. I've searched around for where it went. I used to use it ALL the time. This elimination of this long-standing feature is just SLOWING ME DOWN.  :-( What's the work-around, without having to go select another tool and try to match t

  • Ix4-300d firmware update canceling

    Hi, im trying to update my ix4-300d from version 4.0.4.14600 to version 4.1.104.31360. I downloaded the h4c-4.1.104.31360.tgz and checked its md5: 54b576b17f4628ee5465880418a37e0b to be sure it was not corrupted during download. Then I upload the tgz

  • Problem getting good levels

    Hi folks Im trying to record vocals on garageband 4.1.2. using Duet as an interface (Duet 1 not 2) and I have rented a universal audio preamp 6176 and a SM7 mic.  My problem is that I cannot get the vocals loud enough without distorting.  I have trie