Component resizing in applets

Can any one help with my problem. I am creating an applet and would like to increase the size of buttons and text to help visualy people. In my research it i have found that once you call init(), components can not be redrawn. Is this true? Does anyone know how to or where i can readup on, resizing buttons and textfields.
Many thanks in advance

IF you use awt and don't specify a layout it goes to flow layout by default, so here's one way of doing itimport java.awt.*;
import java.awt.event.*;
public class aButton extends java.applet.Applet implements ActionListener {
   Button b;
   int size = 16;
   Font f1 = new Font("Arial", Font.BOLD, 14);
   public void init() {
      b=new Button("some text");
      b.addActionListener(this);
      b.setFont(f1);
      add(b);
   public void actionPerformed(ActionEvent evt){
      if(evt.getSource()==b){
         size = size+2;
         Font f1 = new Font("Arial", Font.BOLD, size);
         b.setFont(f1);
      validate();
}

Similar Messages

  • How to email text from a text component in my applet on a the host server ?

    How to email text from a text component in my applet on a the host server, back to my email address ?
    Assuming I have Email Form on the host server.
    Help will be appreciated.

    You can do like below
    =REPLACE(Fields!Column.Value," " & Parameters!ParameterName.value & " ","<b>" & Parameters!ParameterName.value & "</b>")
    The select the expression and  right click and choose placeholder properties
    Inside that set Markup type as HTML 
    then it will highlight the passed parameter value in bold within the full xml string
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Resize() of applet is not working properly in java6.0

    Hi iam new to applets i have given one task,that is to display multiple tiff pages in applet, So i have written one applet which displays multiple pages tiff file, i have kept next and previous buttons in the applet to navigate to different pages and here iam using resize() of applet for refreshing applet up to now all fine this all thing i have done in java5.0, but i got a requirement to do in java6.0, in java6.0 applet is not refeshing in the webpage.
    i found the reason that resize() is not working properly.
    Please can someone help me..........
    Thanks&Regards
    Manmohan A

    Dear Aravindth
      (.*?) means -> Select all contents from where you start and end,
    For Ex. <month>(.*?)</month> then Select for start <month> and end last </month> tag.
    (?) Match zero or one occurrences. Equivalent to {0,1}.
    (*) Match zero or more occurrences. Equivalent to {0,}.
    (+) Match one or more occurrences. Equivalent to {1,}.
    (.) (Dot). Match any character except newline or another Unicode line terminator.
    (.*?) means -> Zero or more times Match any character except newline or another Unicode line terminator + Match zero or more occurrences. Equivalent to {0,}.+Match zero or one occurrences. Equivalent to {0,1}.
    Could you please refere the below cite :
    http://www.javascriptkit.com/jsref/regexp.shtml
    Thanks & Regards
    T.R.Harihara SudhaN

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

  • Resizing an Applet window and components.

    How can I resize an applet window and not compromise the layout of components in the applet's panel? Can i get the components to resize as the applet's window resize?

    Try using GridBagLayout as your LayoutManager. Then use GridBagConstraints to specify the components behaviour on resizing.
    Hope that helps.

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

  • Resizing an applet on runtime

    Is it possibe to dynamicaly resize the applet to for example display a image loaded completly when it is larger then the applet currently is? how can this be done?

    Is it possibe to dynamicaly resize the applet The answer is no if you rely on the real estate given to you by the browser. The trick is to define a minimal area for the applet and just spawn a separate window with something like a JFrame for what you wanted it to do. For example:
    <APPLET CODE = "myApplet" CODEBASE = "." ARCHIVE = "myApplet.jar" WIDTH = 10 HEIGHT = 10></APPLET>
    Check out the applet at the link shown below:
    http://www.aokabc.com/index.htm
    ;o)
    V.V.

  • Using my new GUI component in an applet :Help!!!

    I am seeking help for the following
    Define class MyColorChooser as a new component so it can be reused in other applications or applets. We want to use the new GUI component as part of an applet that displays the current Color value.
    The following is the code of MyColorChooser class
    * a) We define a class called MyColorChooser that provides three JSlider
    * objects and three JTextField objects. Each JSlider represents the values
    * from 0 to 255 for the red, green and blue parts of a color.
    * We use wred, green and blue values as the arguments to the Color contructeur
    * to create a new Color object.
    * We display the current value of each JSlider in the corresponding JTextField.
    * When the user changes the value of the JSlider, the JTextField(s) should be changed
    * accordingly as weel as the current color.
    * b)Define class MyColorChooser so it can be reused in other applications or applets.
    * Use your new GUI component as part of an applet that displays the current
    * Color value.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.event.*;
    import java.text.DecimalFormat;
    public class MyChooserColor extends JFrame{
         private int red, green, blue;  // color shade for red, green and blue
         private static Color myColor;  // color resultant from red, green and blue shades
         private JSlider mySlider [];      
         private JTextField textField [];
    // Panels for sliders, textfields and button components
         private JPanel mySliderPanel, textFieldPanel, buttonPanel;
    // sublcass objet of JPanel for drawing purposes
         private CustomPanel myPanel;
         private JButton okButton, exitButton;
         public MyChooserColor ()     
              super( "HOME MADE COLOR COMPONENT; composition of RGB values " );
    //       setting properties of the mySlider array and registering the events
              mySlider = new JSlider [3];
              ChangeHandler handler = new ChangeHandler();
              for (int i = 0; i < mySlider.length; i++)
              {     mySlider[i] = new JSlider( SwingConstants.HORIZONTAL,
                               0, 255, 255 );
                   mySlider.setMajorTickSpacing( 10 );
                   mySlider[i].setPaintTicks( true );
    //      register events for mySlider[i]
                   mySlider[i].addChangeListener( handler);                     
    //      setting properties of the textField array           
              textField = new JTextField [3];          
              for (int i = 0; i < textField.length; i++)
              {     textField[i] = new JTextField("100.00%", 5 );
                   textField[i].setEditable(false);
                   textField[i].setBackground(Color.white);
    // initial Background color of each slider and foreground for each textfield
    // accordingly to its current color shade
              mySlider[0].setBackground(
                        new Color ( mySlider[0].getValue(), 0, 0 ) );
              textField[0].setForeground(
                        new Color ( mySlider[0].getValue(), 0, 0 ) );           
              mySlider[1].setBackground(
                        new Color ( 0, mySlider[1].getValue(), 0 ) );
              textField[1].setForeground(
                        new Color ( 0, mySlider[1].getValue(), 0 ) );
              mySlider[2].setBackground(
                        new Color ( 0, 0, mySlider[2].getValue() ) );
              textField[2].setForeground(
                        new Color ( 0, 0, mySlider[2].getValue() ) );
    // initialize myColor to white
              myColor = Color.WHITE;
    // instanciate myPanel for drawing purposes          
              myPanel = new CustomPanel();
              myPanel.setBackground(myColor);
    // instanciate okButton with its inanymous class
    // to handle its related events
              okButton = new JButton ("OK");
              okButton.setToolTipText("To confirm the current color");
              okButton.setMnemonic('o');
              okButton.addActionListener(
                   new ActionListener(){
                        public void actionPerformed (ActionEvent e)
                        {     // code permetting to transfer
                             // the current color to the parent
                             // component backgroung color
                             //System.exit( 0 );     
    //      instanciate exitButton with its inanymous class
    //      to handle its related events           
              exitButton = new JButton("Exit");
              exitButton.setToolTipText("Exit the application");
              exitButton.setMnemonic('x');
              exitButton.addActionListener(
                        new ActionListener(){
                             public void actionPerformed (ActionEvent e)
                             {     System.exit( 0 );     
    // define the contentPane
              Container c = getContentPane();
              c.setLayout( new BorderLayout() );
    //     panel as container for sliders
              mySliderPanel = new JPanel(new BorderLayout());
    //      panel as container for textFields           
              textFieldPanel = new JPanel(new FlowLayout());
    //      panel as container for Jbuttons components           
              buttonPanel = new JPanel ();
              buttonPanel.setLayout( new BoxLayout( buttonPanel, BoxLayout.Y_AXIS ) );
    //add the Jbutton components to buttonPanel           
              buttonPanel.add(okButton);
              buttonPanel.add(exitButton);
    //     add the mySlider components to mySliderPanel
              mySliderPanel.add(mySlider[0], BorderLayout.NORTH);
              mySliderPanel.add(mySlider[1], BorderLayout.CENTER);
              mySliderPanel.add(mySlider[2], BorderLayout.SOUTH);
    //add the textField components to textFieldPanel     
              for (int i = 0; i < textField.length; i++){
                   textFieldPanel.add(textField[i]);
    // add the panels to the container c          
              c.add( mySliderPanel, BorderLayout.NORTH );
              c.add( buttonPanel, BorderLayout.WEST);
              c.add( textFieldPanel, BorderLayout.SOUTH);
              c.add( myPanel, BorderLayout.CENTER );
              setSize(500, 300);          
              show();               
    //     inner class for mySlider events handling
         private class ChangeHandler implements ChangeListener {          
              public void stateChanged( ChangeEvent e )
    // start by collecting the current color shade
    // for red , forgreen and for blue               
                   setRedColor(mySlider[0].getValue());
                   setGreenColor(mySlider[1].getValue());
                   setBlueColor(mySlider[2].getValue());
    //The textcolor in myPanel (subclass of JPanel for drawing purposes)
                   myPanel.setMyTextColor( ( 255 - getRedColor() ),
                             ( 255 - getGreenColor() ), ( 255 - getBlueColor() ) );
    //call to repaint() occurs here
                   myPanel.setThumbSlider1( getRedColor() );
                   myPanel.setThumbSlider2( getGreenColor() );
                   myPanel.setThumbSlider3( getBlueColor() );
    // display color value in the textFields (%)
                   DecimalFormat twoDigits = new DecimalFormat ("0.00");
                   for (int i = 0; i < textField.length; i++){
                        textField[i].setText("" + twoDigits.format(
                                  100.0* mySlider[i].getValue()/255) + " %") ;
    // seting the textcolor for each textField
    // and the background color for each slider               
                   textField[0].setForeground(
                             new Color ( getRedColor(), 0, 0 ) );
                   mySlider[0].setBackground(
                             new Color ( getRedColor(), 0, 0) );
                   textField[1].setForeground(
                             new Color ( 0, getGreenColor() , 0 ) );
                   mySlider[1].setBackground(
                             new Color ( 0, getGreenColor(), 0) );
                   textField[2].setForeground(
                             new Color ( 0, 0, getBlueColor() ) );
                   mySlider[2].setBackground(
                             new Color ( 0, 0, getBlueColor() ) );
    // color of myPanel background
                   myColor = new Color (getRedColor(),
                             getGreenColor(), getBlueColor());
                   myPanel.setBackground(myColor);               
    // set methods to set the basic color shade
         private void setRedColor (int r){
              red = ( (r >= 0 && r <= 255) ? r : 255 );
         private void setGreenColor (int g){
              green = ( (g >= 0 && g <= 255) ? g : 255 );
         private void setBlueColor (int b){
              blue = ( (b >= 0 && b <= 255) ? b : 255 );
    // get methods (return the basic color shade)
         private int getRedColor (){
              return red ;
         private int getGreenColor (){
              return green;
         private int getBlueColor (){
              return blue;
         public static Color getMyColor (){
              return myColor;
    // main method                
         public static void main (String args []){
              MyChooserColor app = new MyChooserColor();
              app.addWindowListener(
                        new WindowAdapter() {
                             public void windowClosing( WindowEvent e )
                             {     System.exit( 0 );
    // inner class CustomPanel for drawing purposes
         private class CustomPanel extends JPanel {
              private int thumbSlider1 = 255;
              private int thumbSlider2 = 255;
              private int thumbSlider3 = 255;
              private Color myTextColor;
              public void paintComponent( Graphics g )
                   super.paintComponent( g );
                   g.setColor(myTextColor);
                   g.setFont( new Font( "Serif", Font.TRUETYPE_FONT, 12 ) );
                   DecimalFormat twoDigits = new DecimalFormat ("0.00");
                   g.drawString( "The RGB values of the current color are : "
                             + "( "     + thumbSlider1 + " , " + thumbSlider2 + " , "
                             + thumbSlider3 + " )", 10, 40);
                   g.drawString( "The current background color is composed by " +
                             "the folllowing RGB colors " , 10, 60);
                   g.drawString( "Percentage of RED from slider1 : "
                        + twoDigits.format(thumbSlider1*100.0/255), 10, 80 );
                   g.drawString( "Percentage of GREEN from slider2 : "
                        + twoDigits.format(thumbSlider2*100.0/255), 10, 100 );
                   g.drawString( "Percentage of BLUE from slider3 : "
                        + twoDigits.format(thumbSlider3*100.0/255), 10, 120 );
    // call to repaint occurs here     
              public void setThumbSlider1(int th){
                   thumbSlider1 = (th >= 0 ? th: 255 );
                   repaint();
              public void setThumbSlider2(int th){
                   thumbSlider2 = (th >= 0 ? th: 255 );
                   repaint();
              public void setThumbSlider3(int th){
                   thumbSlider3 = (th >= 0 ? th: 255 );
                   repaint();
              public void setMyTextColor(int r, int g, int b){
                   myTextColor = new Color(r, g, b);
                   repaint();
    //The following method is used by layout managers
              public Dimension getPreferredSize()
              {     return new Dimension( 150, 100 );
    The following is the code of application that tests the component
    //Application used to demonstrating
    // the homemade GUI MyChooserColor component
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class ShowMyColor extends JFrame {
         private JButton changeColor;
         private Color color = Color.lightGray;
         private Container c;
         MyChooserColor colorComponent;
         public ShowMyColor()
         {     super( "Using MyChooserColor" );
              c = getContentPane();
              c.setLayout( new FlowLayout() );
              changeColor = new JButton( "Change Color" );
              changeColor.addActionListener(
                        new ActionListener() {
                             public void actionPerformed( ActionEvent e )
                             {     colorComponent = new MyChooserColor ();
                                  colorComponent.show();
                                  color = MyChooserColor.getMyColor();
                                  if ( color == null )
                                       color = Color.lightGray;
                                  c.setBackground( color );
                                  c.repaint();
              c.add( changeColor );
              setSize( 400, 130 );
              show();
         public static void main( String args[] )
         {     ShowMyColor app = new ShowMyColor();
              app.addWindowListener(
                        new WindowAdapter() {
                             public void windowClosing( WindowEvent e )
                             {  System.exit( 0 );

    Yes, I want help for the missing code to add in actionPerformed method below. As a result, when you confirm the selected color (clicking the OK button), it will be transferred to a variable color of class ShowMyColor.
    // instanciate okButton with its inanymous class
    // to handle its related events
              okButton = new JButton ("OK");
              okButton.setToolTipText("To confirm the current color");
              okButton.setMnemonic('o');
              okButton.addActionListener(
                   new ActionListener(){
                        public void actionPerformed (ActionEvent e)
                        {     // code permetting to transfer
                             // the current color to the parent
                             // component backgroung color
                             //System.exit( 0 );     
              );

  • Disposed component in an applet

    an applet sometimes throws a NullPointerException. here is the tree:
    java.lang.NullPointerException: disposed component at
    sun.awt.windows.Win32SurfaceData.initOps(Native Method) at
    sun.awt.windows.Win32SurfaceData.<init>(Unknown Source) at
    sun.awt.windows.Win32SurfaceData.createData(Unknown Source) at
    sun.awt.windows.WComponentPeer.<init>(Unknown Source) at
    sun.awt.windows.WChoicePeer.<init>(Unknown Source) at
    sun.awt.windows.WToolkit.createChoice(Unknown Source) at
    java.awt.Choice.addNotify(Unknown Source) at
    java.awt.Container.addNotify(Unknown Source) at
    java.awt.Panel.addNotify(Unknown Source) at
    java.awt.Container.addNotify(Unknown Source) at
    java.awt.Panel.addNotify(Unknown Source) at
    java.awt.Container.addImpl(Unknown Source) at
    java.awt.Container.add(Unknown Source) at NewTable.init
    (NewTable.java:75) at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    as you see the exception is thrown in line 75.
    line 75 in my code looks like this: i add a panel
    to the appletwhich were relayouted earlier with borderlayout. it
    looks like this:
    74 Panel p=new Panel();
    75 this.add(p,BorderLayout.CENTER);
    now, the exception is probably thrown because i run the add() method
    on a component which containment hierarchy is made undisplayable.
    according the api it can happen when the component's ancestor window
    is disposed.
    the question is why it is getting disposed? i payed attention that
    the exception is thrown only on 2 specific win98 machines and it's
    never thrown when the user opens the applet in the first time.
    usually it happens when a number of users visit the same page which
    includes this applet and the browser is not closed between the user
    sessions...but! the users always press a button on applet which redirects them to another page, which means that the applet calls destroy() on itself ...
    i thought to add an isDisplayable() check , but it will only give me
    a control over the exception, not the no-problem-sollution.
    any ideas what can be fixed?
    thanX

    how do you run your applet - using applet viewr or a browser?
    anyway, when debugging, don't assume anything.
    in line 75 you may try System.err.println( this )
    if you don't get null, try:
    System.err.println this.GetXXX() and print as much as you can about your object.

  • Component resizing problem in Vbox

    Hi.. I am facing a peculiar problem.. I have a vbox which contains 5 components, each of which has a line graph and a legend.. But all of them need not be visible at a time.. It depends on the number of parameters returned from a webservice call... so at a time 1-5 of such components maybe visible... i do this by setting includeInLayout and visible to false..
    Each of the components have height and width set to 100%. So I expect all the components which have includeinlayout and visible set to true to be equal in size... But if initially only one of the component is visible and then i want to show 2 components by setting these properties, the component which was visible initially is not resizing.. It is staying the same size as before making the second component visible... second component is getting correct size (half of the size of the VBox)..... Am i doing something wrong here? Can some component not reduce in size if another child added/included in layout of its parent?
    Thanks in advance for your help!

    Hi Philip,
    This is my vbox declaration. Trendline has a linechart and a legend
    <mx:VBox id="chartsContainer" width="100%" height="100%" verticalScrollPolicy="auto">
       <chart:TrendLine id="defaultTrendLineChart" width="100%" height="100%" includeInLayout="true" visible="true"/>
       <chart:TrendLine id="trendChart1" width="100%" height="100%" includeInLayout="false" visible="false"/>
       <chart:TrendLine id="trendChart2" width="100%" height="100%" includeInLayout="false" visible="false"/>
    </mx:VBox>
    And here is the code where i selectively include various charts in the display
    var count:int = 0;
    for (var parameterType:String in parameterTable)
       var trendLineChart:TrendLine = trendChartArray[count++];                                                       
       trendLineChart.includeInLayout = true;
       trendLineChart.visible = true;
       trendLineChart.Initialize();
       trendLineChart.SetView(bIsChartView);                       
       trendLineChart.LoadChart(dataProvider, parameterType, parameterTable[parameterType]);
    I have stored all the children of the vbox in an array for easy fetching
    var trendChartArray:Array = [defaultTrendLineChart, trendChart1, trendChart2];
    parameterTable is a Dictionary in which number of parametertypes can vary from 1 to 3 depending on the result of a webservice call. The problem is that if initially i am showing only one chart and then i have to show 2 charts, the first chart's size is not getting reduced. But the second chart added is getting correct size.
    Thanks a lot for your response.

  • Component resize, paint and AffineTransform

    Hello,
    I am resizing a JInternalFrame that contains a JPanel.
    When I call:
    MyJPanel.repaint();The paint function gets the dimensions of the JPanel
    using getWidth() and getHeight(), once, at the start of the
    paint function. The function then proceeds to plot some lines and
    points on a graph. Everything appears to work fine for lines and points (ie: drawOval).
    The function then goes on to draw some text for the axes of the graph. The Y axis
    text plots fine. The X axis text is rotated using AffineTransform and plots intermittently
    with the correct and incorrect position.
    Calling repaint() for the JPanel, without resizing,
    everything renders in the proper place
    via the overridden paint() procedure for that panel.
    When I resize the JInternalFrame, thus causing the
    JPanel to also automatically resize and repaint, the JPanel
    paints all lines and points in the correct locations
    with respect to the bounds of the JPanel. The
    Y axis text, drawn using drawText() plots in the correct place.
    The X axis text then plots in the wrong place after AffineTransform
    positioning in a location that would indicate it is transforming based on the
    coordinate system of the JInternalFrame rather than the JPanel (??).
    To create the text transform I am calling the following function:
    public void drawRotatedText(Graphics g, String text, int xoff, int yoff, double angle_degrees){
                        Graphics2D g2d=(Graphics2D)g;
                        AffineTransform old_at=((Graphics2D)g).getTransform();
                        AffineTransform at = new AffineTransform(old_at);
                        at.setToTranslation(xoff, yoff);
                        at.rotate((angle_degrees/360.0)*Math.PI*2.0);
                        g2d.setTransform(at);
                        g2d.drawString(text, 0, 0);
                        g2d.setTransform(old_at);
                    }The parameter Graphics g is the Graphics passed from public void MyJPanel.paint(Graphics g) .
    Why would AffineTransform get confused regarding which component the Graphics is coming from?
    More importantly, how can I avoid the problem?
    Thanks,
    P

    >
    To create the text transform I am calling the following function:
    public void drawRotatedText(Graphics g, String text, int xoff, int yoff, double angle_degrees){
    Graphics2D g2d=(Graphics2D)g;
    AffineTransform old_at=((Graphics2D)g).getTransform();
    AffineTransform at = new AffineTransform(old_at);
    at.setToTranslation(xoff, yoff);
    at.rotate((angle_degrees/360.0)*Math.PI*2.0);
    g2d.setTransform(at);
    g2d.drawString(text, 0, 0);
    g2d.setTransform(old_at);
    The problem is with the use of at.setToTranslation(xoff, yoff); instead of at.translate(xoff, yoff).
    After changing that the problem cleared up.
    P

  • Catching the start/end of component resizing?

    Hi Folks,
    I have a JPanel descendant and I want to store its initial size before being resized (by mouse), then at the end of resining, use this value to calculate the resizing factor.
    componentAdapter.componentResized() works fine for Windows LAFs, as it is called just once (when the mouse is released). But, using other Look and feels, it is called several times during the resize process (it can be seen also that the panel is repainted continuously).
    I tried to turn off repainting with setDynamicLayout(), but besides it did not worked at all, it looked ugly.
    My question: is there a way to get an event for determining the beginning and the end of the resizing process using any LAFs?
    Thanks,
    -meri

    Hello,
    well, who's controlling the resize? You have a mouse
    drag to do it? Then you can know on mouse press what
    the size is...Yes, a mouse drag is used to resize a JDialog which contains my component. The problem with mouse press is if it's a resizing (grabbing the border of the dialog), then no other mouse events are fired on the component (either MousePressed).
    or maintain the "current size" in a variable and
    compare that to the componentResized call and after
    done, reset the "current size" to the new size.Fine, I could do it (already done), but for special reasons, it would be much more better to calculate further sizes of the very first (initial) one.
    Thanks anyway! I will keep on searching for some solution...
    -meri

  • Component Resize

    I'm making a website entirely in Flash and I've just bought
    an XML MP3 Player which is supplied with the source code and the
    component file etc:
    Picture
    here
    After installing the component it appears in the Components
    Panel as complied. I am able to drag it onto the stage, however if
    I try to resize it like other components by using the Free
    Transfrom Tool, its almost like a masking effect, if I try to drag
    the component to a smaller size, its simply shows a smaller area of
    the component.
    The mp3 player once dragged from the Component Panel onto the
    stage:
    Here
    After I try to resize it:
    Here
    How can I resize it? Or what options do I have? Please help

    OneTen wrote:
    > Urgent! Please help.
    This is not something we can fix for you.
    You need to contact the producer and ask them for that.
    Unlike us, they are the one who knows how it was design
    and how to control it.
    Best Regards
    Urami
    !!!!!!! Merry Christmas !!!!!!!
    Happy New Year
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Resizing an applet

    I have a Applet which has a Panel ,(main) with border layout. This Panel(main) again contains another Panel (sub) which is postioned at the North. The Panel (sub)has default layout manager (Flow Layout) with components in it.
    My problem is when I change the width of the Applet say to 400 pixcels some of the components disappear.
    Please help to me to figure out a way, that no matter what the size of the applet is , components within in Panel(sub) should resize accordingly and appear on the screen
    Please help...........

    THanks for your reply. The Panel(main) which has the border layout is the same size as the Applet and it resizes accordingly. what other layout do you suggest for the Panel(sub). Currently I have flow layout. With this flow Layout I won't be able achieve my objective. What other choices do I have??
    PLease help -----------------

  • Unwanted component resize

    Using JAvaFX 2.2 I have implemented a custom control. To figuring out the internal proportions this control needs to be resizable. However after these internals are sorted out, the control should no longer change it's size. What's the best way to do that, besides overriding the isResizable method to return the value false, after the internals are sorted out?
    Below is a stacktrace, showing the call hierarchy of the first unwanted size change.
    this.boundsInParentProperty().addListener(new ChangeListener<Bounds>(){
            @Override
            public void changed(ObservableValue<? extends Bounds> arg0,
                    Bounds arg1, Bounds arg2) {
                System.out.println("New bounds of Pagination: "+arg2);
                new Exception("Cause for Bounds change").printStackTrace();
    java.lang.Exception: Cause for Bounds change
        at ch.sahits.game.javafx.control.Pagination$5.changed(Pagination.java:118)
        at ch.sahits.game.javafx.control.Pagination$5.changed(Pagination.java:1)
        at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:196)
        at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100)
        at javafx.scene.Node$LazyBoundsProperty.invalidate(Node.java:7555)
        at javafx.scene.Node$MiscProperties.invalidateBoundsInParent(Node.java:4980)
        at javafx.scene.Node.invalidateBoundsInParent(Node.java:2730)
        at javafx.scene.Node.transformedBoundsChanged(Node.java:3349)
        at javafx.scene.Node.localBoundsChanged(Node.java:3333)
        at javafx.scene.Node.impl_geomChanged(Node.java:3321)
        at javafx.scene.Parent.impl_geomChanged(Parent.java:1705)
        at javafx.scene.Parent.childBoundsChanged(Parent.java:1729)
        at javafx.scene.Node.notifyParentOfBoundsChange(Node.java:3382)
        at javafx.scene.Node.transformedBoundsChanged(Node.java:3351)
        at javafx.scene.Node.localBoundsChanged(Node.java:3333)
        at javafx.scene.Node.impl_geomChanged(Node.java:3321)
        at javafx.scene.Parent.impl_geomChanged(Parent.java:1705)
        at javafx.scene.layout.Region.access$900(Region.java:104)
        at javafx.scene.layout.Region$3.invalidated(Region.java:423)
        at javafx.beans.property.DoublePropertyBase.markInvalid(DoublePropertyBase.java:129)
        at javafx.beans.property.DoublePropertyBase.set(DoublePropertyBase.java:163)
        at javafx.scene.layout.Region.setWidth(Region.java:442)
        at javafx.scene.layout.Region.resize(Region.java:1312)
        at javafx.scene.Node.resizeRelocate(Node.java:2667)
        at javafx.scene.control.Control.layoutChildren(Control.java:892)
        at javafx.scene.Parent.layout(Parent.java:1018)
        at javafx.scene.Parent.layout(Parent.java:1028)
        at javafx.scene.Scene.layoutDirtyRoots(Scene.java:516)
        at javafx.scene.Scene.doLayoutPass(Scene.java:487)
        at javafx.scene.Scene.preferredSize(Scene.java:1489)
        at javafx.scene.Scene.impl_preferredSize(Scene.java:1516)
        at javafx.stage.Window$9.invalidated(Window.java:716)
        at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:127)
        at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:161)
        at javafx.stage.Window.setShowing(Window.java:779)
        at javafx.stage.Window.show(Window.java:794)
        at javafx.stage.Stage.show(Stage.java:229)
        at ch.sahits.game.graphic.display.dialog.OpenPaticianTestApplicationWindow.start(OpenPaticianTestApplicationWindow.java:59)
        at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
        at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
        at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
        at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
        at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
        at com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java:82)
        at java.lang.Thread.run(Thread.java:724)

    Let me reformulate the question:
    If I implement the control as non resizable:
    public boolean isResizable() {
        return false;
    What else to I have to implement? How can I ensure that the component has the correct dimensions? The width and height properties are read only.

Maybe you are looking for

  • How to View the Actual Remaining Budget for Earmarked Fund?

    Hi All, First of all, pardon if my questions below are very basic, I'm an ABAPer trying to gasp the big FI process. Background: I created a project definition then allocate a budget via CJ30.  I created WBS Element then allocate a budget again. I cre

  • Computers running Vista won't open PDF files with Adobe Reader

    I have tried downloading the latest version and nothing helps.  The error message says it was incorrectly encrypted or something along those lines.  I have forwarded the file to my home computer and ith opens fine, but not on the boss's computer or h

  • Unable to run JSP file in TOmcat

    My Tomcat is running when i type http://localhost:8080/index.jsp , i'm able to see home page CLASSPATH=C:\j2sdk1.4.2_08\bin;E:\Grinder;E:\Grinder\lib\grinder.jar;C:\Program Files\Java\j2re1.4.2_08\lib\grinder.jar; JAVA_HOME=C:\j2sdk1.4.2_08 I tried b

  • Preferences, screensaver not working

    when i go to preferences, screensaver it says loading images and freezes on that, i get the spinning wheel, i have to force quit to stop it. how do i fix that?

  • A Sample Report

    Hi All     Can anyone send me a sample report which covers almost all the main concepts of ABAP which is very useful...like all events involved,many function module used,calculations used,many tables used,ALV...etc etc Regards Asha