Resizing components

hi pals,
i've got some problem with creating gui again. I have scrollpane and a canvas in it. The thing is that the stuff drawn by paint(Graphics g) method in canvas has no effect on size of the canvas itself, so the scrollpane wouldn't show the scrollbars and some images aren't visible without scaling the window. Is there any way to solve this without counting every image's size added to the canvas and setting its preferredSize?

ok,
I'm working on a map editor. The problem I have concerns the pallete where the user is supposed to pick particular tiles and paste them on the map. This pallete is realized with JPanel object which draws all the loaded images into rows of sprites of the same size using the paint() method (already made it paintComponent but whatever). It works actually as a view of images I have loaded somewhere else.
Selecting of the sprites works through MouseAdapter added on the pallete. The id of the selected sprite is aquired after evaluating the mouse position on the pallete since there is fixed width of the pallete and size of the tile is also known so no biggie.
This part works.
In order not to constrain the tileset by top number of sprites (dependent from the size of your screen), I thought it would be good if the pallete would be scrollable so if there is too much sprites on the screen you could just scroll down to be able to pick all of them.
And that's the problem I can't solve. Drawing the sprites doesn't change the size of the panel which realizes the pallete, so the scrollpane doesn't show any scrollbars because the size of the pallete is not smaller than initial preferred size. I thought one solution would be just setting the size of the pallete every time adding a new sprite, but it doesn't seem to be too sexy to me, so if anyone had some hint or idea I would be really pleased ..

Similar Messages

  • Resizing Components in a JLayeredPane

    Hello,
    I'm brand new to Java (formerly a VB man). I'm creating an application where icons are displayed on a background image and can be dragged around the window. The background image and the icons need to resize with the window.
    I've managed to get the back ground image to resize but can't work out how to get the icon images to resize as well. I also need to keep their relative positions as well.
    I have three classes which extend JFrame, JLayeredPane and JPanel to construct the display. I have attached them below.
    If anyone can help or at least point me in the right direction I would be very grateful indeed.
    Best regards
    Simon
    package imagelayers;
    import java.awt.*;
    import java.awt.color.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SecondFrame extends JFrame
    private JLayeredPane m_layeredPane;
    private MovingImage m_movImage1, m_movImage2, m_movImage3;
    private BackgroundImage m_background;
    public SecondFrame() {
    super("Moving Images");
    setLocation(10,10);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // Load the background image in a JPanel
    ImageIcon kcIcon = new ImageIcon("images/kclogo.gif");
    m_background = new BackgroundImage(kcIcon);
    setSize(kcIcon.getIconWidth(), kcIcon.getIconHeight());
    m_movImage1 = new MovingImage("images/dukewavered.gif", 0);
    m_movImage2 = new MovingImage("images/dukewavegreen.gif", 1);
    m_movImage3 = new MovingImage("images/dukewaveblue.gif", 2);
    m_background.add(m_movImage1 , JLayeredPane.DRAG_LAYER);
    m_background.add(m_movImage2 , JLayeredPane.DRAG_LAYER);
    m_background.add(m_movImage3 , JLayeredPane.DRAG_LAYER);
    m_movImage2.topLayer = 2;
    Container contentPane = getContentPane();
    contentPane.add(m_background);
    setVisible(true);
    public static void main(String[] arguments)
    JFrame frameTwo = new SecondFrame();
    package imagelayers;
    import java.awt.*;
    import javax.swing.*;
    public class BackgroundImage extends JLayeredPane
    private Image m_backgroundImage;
    public BackgroundImage(ImageIcon bg)
    m_backgroundImage = bg.getImage();
    setBorder(BorderFactory.createTitledBorder(""));
    public void paintComponent(Graphics g)
    g.drawImage(m_backgroundImage,0,0,getWidth(),getHeight(),this);
    package imagelayers;
    import javax.swing.ImageIcon;
    import javax.swing.JLabel;
    import javax.swing.JLayeredPane;
    import java.awt.*;
    import java.awt.event.*;
    public class MovingImage extends JLabel implements MouseListener, MouseMotionListener
    private Image m_theImage;
    private ImageIcon m_theImageIcon;
    private int nStartX, nStartY;
    static int topLayer;
    public MovingImage(String imgLocation, int layerNum)
    addMouseListener(this);
    addMouseMotionListener(this);
    m_theImageIcon = new ImageIcon(imgLocation);
    m_theImage = m_theImageIcon.getImage();
    setBounds(0, 0, m_theImageIcon.getIconWidth(), m_theImageIcon.getIconHeight());
    public void paintComponent(Graphics g)
    g.drawImage(m_theImage,0,0,getWidth(),getHeight(),this);
    public void mousePressed(MouseEvent e)
    JLayeredPane imagesPane = (JLayeredPane)getParent();
    imagesPane.setLayer(this,topLayer,0);
    nStartX = e.getX();
    nStartY = e.getY();
    public void mouseMoved(MouseEvent e){}
    public void mouseClicked(MouseEvent e){}
    public void mouseExited(MouseEvent e){}
    public void mouseEntered(MouseEvent e){}
    public void mouseReleased(MouseEvent e){}
    public void mouseDragged(MouseEvent e)
    setLocation(getX() + e.getX() - nStartX, getY() + e.getY() - nStartY);
    }

    Try useing the JFrames show() method or setVisible(true) method after you have added all the other components.
    If that doesnt work use the JFrames validate() method, inherited from Container, after one of the previous methods.
    Hope this helps

  • Printing resolutions, trees, resizing components & co

    Hi.
    I've a little problem which grows bigger and bigger every day: I've to print a tree. Sound's easy, hm? That's not all, I have to use a template and there's a place marked where I've to put that tree (can be a component) but I'm not allowed to change template and I'm not the one adding the other components, just reponsible for trees.
    Ok, now I managed that tree is displayed over more pages without cutting any objects at end of page but now I face other troubles: The tree is too big at all. So I've to resize this.
    I was first wandering, why tree was that big and it is because a page is always rendered with 72dpi by default. First think I thought was to change printing resolution by setting page attributes:
        PageAttributes pageAttributes = new PageAttributes();
        int[] attributes = pageAttributes.getPrinterResolution();
        // using 150 dpi instead of 72 to make tree half sized
        attributes[0] = 150;
        attributes[1] = 150;
        pageAttributes.setPrinterResolution(attributes);
        PrintJob theJob = getToolkit().getPrintJob(this, Catalog.getString("Previewer"), null, pageAttributes);Works fine, but resizes everything, also header and footer and all other components which are already displayed in current size.
    So I need something else.
    I think the real resize happens in the WPrintGraphicsWrapper (yes, I'm using windows) where the AffineTransform for the WPrintGraphics is calculated and set.
    I can't avoid this but I tried to set another scale for the graphics during painting by calling following method in the paint-method of the base components I want to resize:
      protected Graphics checkScaleGraphics(Graphics g, boolean rescale) {
        if (g instanceof Graphics2D) {
          // at preview g2d is received
          if (rescale) {
            ((Graphics2D)g).scale(((double)1/scaleFactor), ((double)1/scaleFactor));
          } else {
            ((Graphics2D)g).scale(scaleFactor, scaleFactor);
        } else {
          // trying to get 2D graphics object for scaling using reflect
          try {
            // get real graphics from wrapper
            Graphics2D d2Graphics = (Graphics2D)g.getClass().getMethod("getTarget", null).invoke(g, null);       
            if (rescale) {
              d2Graphics.scale(((double)1/scaleFactor), ((double)1/scaleFactor));
            } else {
              d2Graphics.scale(scaleFactor, scaleFactor);
          } catch(Exception e) {
            System.out.println("Exception: "+e); // for testing, no exception handling
        return g;
      }Using reflect is rather slow but code must be compileable on sun too.
    However it doesn't work at all. The components get resized but the nodes where irrecognizable, especially text looks cruel.
    Also using reflect is very slow and code must be compileable on sun also.
    Has anybody experience with this or knows a good way how to print a tree at all?
    Thanks in advance
    Karl

  • GridBagLayout & Resizing Components

    Hello all,
    I've created a GUI where one of the panels uses GridBagLayout, defined with GridBagConstraints like so:
    cs.anchor = GridBagConstraints.CENTER;
    cs.fill = GridBagConstraints.BOTH;
    cs.insets = new Insets(5, 5, 5, 5);
    cs.ipadx = 1;
    cs.ipady = 1;gridx, gridy, weightx and weighty are provided later, when adding components to the panel.
    The problem occurs when I update the state of the GUI - two JSpinners in the panel described above are updated, which means its JTextFields display some values. When this happens, JSpinners resize. This is something I'd like to avoid.
    I've tried setting the minimumSize, maximumSize, preferredSize, ... The only thing that comes remotely close to the solution is setting the columns of JTextFields of JSpinners but even that produces a tiny resizing.
    Could you think of any other way to fix this?

    If you do not want the JSpinners to resize why do you set the fill property to BOTH instead of NONE?
    In other words, set the fill property to NONE and properties weightx and weighty to 0.

  • Hint on resizing components with the window

    Hi,
    I'm making a web browser and am having a bit of trouble getting the componenets inside ( a JSpliPane with various bits in it) and the top buttons to resize with the main frame when it is resized. At the moment it all stays in the top left at the same size.
    I would like it for the menu to just expand width ways and the JSplitPane to rezise fully to take ip the rest.
    Any ideas on where to start, I have an idea that it may be layout managers, but i cant seem to see how to get one to do this.
    Any pointers would be appreciated cheers (I will happilly look up the API if someone could tell me where to start).
    Cheers :)

    Use a LayoutManager, more specifically BorderLayout.
    JFrame f = new JFrame();
    f.getContentPane().setLayout(new BorderLayout()); //BorderLayout is the default layoutmanager
    f.getContentPane().add(myContentPane, BorderLayout.CENTER);And that's it...

  • Resizing Components Art? Not working...

    Hello,
    Thanks for your time.
    I know nothing about components... but I'd like to utilize Flash components and learn how to use them so I'm not constantly finding code on FlashKit for things that are already available to me in Flash.
    2 things I'm trying to work with are the "Slider" and the "Progress Bar". I'm unable to size the graphics. So if I went into the art of the slider and switch the slider tick with a graphic and then made that graphic 5-10X bigger, it's not showing when I publish it. It's showing the new art, but the scaling that I've applied is not showing... it's the same size as the original tick was. I then tried selecting all of the art and scaled it, still no luck.
    I looked in the Component Inspector and there wasn't any settings for sizing... and I tried to find some AS3 in the file (using AS3 here only, per client request) and I couldn't find anything.
    Thanks for any help

    This sounds as though you have only added the album art to one song, not the complete album. Find the song with the artwork and copy-and-paste it into the other songs on that album.

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

  • The drop down box does not resize with window

    I have enabled the vi option to resize components of the window with resolution. All other elements in the window resizes appropriatly.
    I have already spoke with an NI rep and she has said this is a problem. I am wondering if this problem is also in the 8.2 version of
    labview, since I have just recieved the update. Otherwise I would like to find an eqivelant work around to complete this particular
    application. Kinda frustrating.

    Hi,
    I was able to resize the combo box control in LabVIEW 8.20 by checking the "Scale all object on the front panel as the window resizes"  option in the "VI Properties" settings.
    Tunde

  • Resizing GUI

    I am having trouble writing code to resize components on a GUI after the hit of a button. I have a matrix of jButtons and I want the user to be able to resize the matrix to more or less columns and rows but the only thing I have managed to do is to copy the resized components below the original. Any suggestions would be appreciated?

    Are you adding new buttons to the matrix? If so, you may have to remove the original panel from the parent container, add the newly sized one, revalidate the container, and pack it. See if that works.
    Container cp = getContentPane();
    cp.removeAll();
    cp.add(createButtonMatrix());
    cp.revalidate();
    pack();

  • Scale nine for scalable components?

    Is there any way to make a scalable component use scale nine coordinates?  It seems that the only options for scaling are to tile or scale (stretch) the image/layer.  I'd love to specify the edges so they aren't distorted.
    Thanks!

    You will need to take your project into Flash Builder to create components that scale. Scale nine, resizable components, and constraint based sizing are not supported Flash Catalyst 1.0
    These were pretty big features to bite off for 1.0, so expect them in the next version.
    Ty

  • How to set the size of a control with the mouse ?

    hi all,
    i am writing a sort of ide (editor which creates applets very easy....) - for this purpose i need some hints from you guys:
    of course i need to create some controls like buttons...
    no prob - i am able to create buttons and place them at any place.
    BUT WHAT ABOUT THE SIZE ?
    ok, i have some ideas to realize this but what i want is a thick border arround the control with spots at each corner - when i place the cursor at one of these spots, my mouse cursor should change and it must be able to change the size of the control (while pressing and moving the mouse - you all know that from any ide).
    so how to do that?
    go on brains!!!
    THANX,
    andi

    I thought about creating dynamically resizable components, but gave it up as the effort seems too much for the benefit. I did a search for info on it and found a lot of people who wanted to do it, but not any who had actually done it completely. Here's some of my thoughts on the subject. You are right on about creating 'sizing handles', it seems to me the way to do this is to create your own container for any component (extend JPanel?) which can switch between no border and your new sizing border at some event. You will need to respond to mouse clicks on this border and follow the 'drag' event to find out where it was dropped. The java drag/drop events probably won't be of any use to you because each component will need an event handler. You need to catch them all.
    Finally, you need to figure out how to interact with some LayoutManager or write your own. Most LayoutManagers want to do their own resizing and you will have to deal with this. For example, GridBagLayout will not only resize all of the other components on the affected row and column, but unless you resize the other components, you won't be able to drag the top higher or the left lefter?

  • AMM Shrink and grow question

    Hi,
    i've 11.2 Database.
    I know that using AMM, Oracle manages sga and pga together.
    But why shink and grow (sga pools) operation impact only shared and buffer and not also the pga?
    An example, I've 5Gb of AMM, looking AWR, Oracle set shared pool to about 1,9Gb, buffer to 1,1Gb (sga target around 3,3Gb) and the results to PGA.
    Looking Memory Dynamic Components in AWR, i see that shrink/grow operation uses only shared and buffer pool and not the PGA that is not used.
    Why this?
    Thanks.

    Mr.D. wrote:
    Hi,
    i've 11.2 Database.
    I know that using AMM, Oracle manages sga and pga together.
    But why shink and grow (sga pools) operation impact only shared and buffer and not also the pga?
    An example, I've 5Gb of AMM, looking AWR, Oracle set shared pool to about 1,9Gb, buffer to 1,1Gb (sga target around 3,3Gb) and the results to PGA.
    Looking Memory Dynamic Components in AWR, i see that shrink/grow operation uses only shared and buffer pool and not the PGA that is not used.
    Why this?
    Thanks.What I understood from your question is that you dont see reallocation of PGA as you see in SGA resizable components.
    [url http://docs.oracle.com/cd/B28359_01/server.111/b28310/memory003.htm] this  describes how the PGA is allocated.
    Unless there is pressure on oracle to release the memory from PGA to allocate to SGA or vice versa you will not see the change in memory allocation for PGA

  • Rendering issue with Netbeans and Firefox

    Very new at using JSF, in fact I am using it from Nebeans 6.1. Once I create the pages using the visual designer, in IE, for the most part they look as they were designed, however when I view them in Firefox, listbox seems to be the original size and spacing between components is larger than IE. Not sure how to fix this, any help appreciated.
    Edited by: robucf3 on Jun 4, 2008 8:35 AM

    I have read up on the two subjects and I have looked at the generated code, in fact I had to tweak some of it to get the CSS to work. In any case, is there anything specific for me to look at, some attribute that maybe needs setting, etc?
    Found this:
    # Issue #95022: Resizing of textfield and other components does not work.
    Description: Due to a change in Woodstock components, resize handles have been removed from the following Woodstock components: TextField, TextArea,PasswordField, DropDown and ListBox. This issue impacts especially projects imported from Java Studio Creator and NetBeans Visual Web Pack 5.5/5.5.1. Resized components may look different from how they looked in previous releases.
    Workaround: For TextField and TextArea components, use the columns and rows attributes, respectively. DropDown and ListBox components are automatically resized to the size of the longest item by the browser.
    Edited by: robucf3 on Jun 4, 2008 9:11 AM

  • JSF - Disable component messages

    Is it possible to disable component's messages when using custom validators? I only want to display a list of messages on the top of the page, not the default behavior that displays the detail error message next to the component.
    Can anyone help me? Thanks

    Hi,
    you could use the GlassPane for this:
      JPanel glassPane = new JPanel();
      glassPane.addMouseListener(new MouseAdapter() {
        // select components on mouse events
      glassPane.addMouseMotionListener(new MouseMotionAdapter() {
        // drag or resize components on mouse events
      frame.setGlassPane(glassPane);
      glassPane.setVisible(true); // must be called after setGlassPane() !!Sven

  • Graphical editor

    Hi,
    I'm trying to make a graphical DTD editor. Right now I have a little problem with moveable objects and arrows. Perhaps someone can help me with this?
    I'll try to describe my problem as good as I can. First, there should be some objects like squares or circles (moveable one). Second, every object have a different meaning (like square is some kind a node or value). So we have couple of squares and circles, we're connecting them with our arrows and we suppose to have a nice DTD document. Yes, I know ... Right now I need some information how to put one object on it place (when we click on the square it stops to move and we can play with another one). Please forgive me my English but I'm not an native speaker.
    Cheers.
    ----some of my code---
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.BevelBorder;
    import javax.swing.event.MouseInputAdapter;
    import javax.swing.text.Highlighter;
    import java.io.*;
    public class DTDEdit extends JFrame
         OptionsTB     _op;
         FunctionsTB     _fu;     
         JTabbedPane _ta;
         * This is main constructor.
         * In here we're cooking all fancy stuff.
         * @param _ch is a JFileChooser. Thank to this he can open
         * a file.
         public DTDEdit() {
              _ta = new JTabbedPane();
              _op = new OptionsTB();
              _fu = new FunctionsTB();
              ImageIcon ic = new ImageIcon("images/icons/Earth-16x16.png");
              JPanel panel = new JPanel();
              //JPanel panel2 = new JPanel();          
              //TODO To nadal jest puste.
              SecondPanel panel2 = new SecondPanel();
              panel2.setVisible(true);
              panel.setBorder(new BevelBorder(BevelBorder.LOWERED));
    OverlayLayout overlay = new OverlayLayout(panel);
    panel.setLayout(overlay);
    panel.add(new TopPanel("123"));
    panel.add(new Overlay());
    _ta.addTab("graphical",ic, panel);
    _ta.addTab("source",ic, panel2);   
    add(_ta, "Center");
              setJMenuBar(new Menu());
              getContentPane().add(_op, BorderLayout.NORTH);
              getContentPane().add(_fu, BorderLayout.WEST);
              pack();
         public int scWidth() //get width of screen number 1
              GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
         GraphicsDevice[] gs = ge.getScreenDevices();
         DisplayMode dm = gs[0].getDisplayMode();
         return dm.getWidth();
         public int scHeight() //get height of screen number 1
              GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
         GraphicsDevice[] gs = ge.getScreenDevices();
         DisplayMode dm = gs[0].getDisplayMode();
         return dm.getHeight();
         public static void main(String[] args) {
    DTDEdit f = new DTDEdit();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(800,600);
    f.setLocation(200, 200);
    f.setVisible(true);
    * This determines an movable editor
    * @author Marcin
    class Overlay extends JPanel
    public Overlay()
    setBackground(Color.LIGHT_GRAY);
    * This is top panel.
    * We're painting on it.
    * @author Marcin
    class TopPanel extends JPanel
    Point loc;
    int width, height, arcRadius;
    Rectangle r;
    String s;
    public TopPanel(String s)
         this.s = s;
    setOpaque(false);
    width = 80;
    height = 40;
    arcRadius = 0;
    r = new Rectangle(width, height);
    TopRanger ranger = new TopRanger(this);
    addMouseListener(ranger);
    addMouseMotionListener(ranger);
    protected void paintComponent(Graphics g)
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
    RenderingHints.VALUE_ANTIALIAS_ON);
    if(loc == null)
    init();
    g2.setPaint(Color.DARK_GRAY);
    g2.fillRoundRect(loc.x, loc.y, width, height, arcRadius, arcRadius);
    g2.setPaint(Color.yellow);
    g2.drawString(s, loc.x + 25, loc.y + 25);
    //g2.drawRoundRect(loc.x, loc.y, width, height, arcRadius, arcRadius);
    private void init()
    int w = getWidth();
    int h = getHeight();
    loc = new Point();
    loc.x = (w - width)/2;
    loc.y = (h - height)/2;
    r.x = loc.x;
    r.y = loc.y;
    public int getRectWidth()
         return width;
    * In here we're enabling an mouse adapters.
    * Thank's to this we can move what we had made :)
    * @author Marcin
    class TopRanger extends MouseInputAdapter
    TopPanel top;
    Point offset;
    boolean dragging;
    public TopRanger(TopPanel top)
    this.top = top;
    offset = new Point();
    dragging = false;
    public void mousePressed(MouseEvent e)
    Point p = e.getPoint();
    if(top.r.contains(p))
    offset.x = p.x - top.r.x;
    offset.y = p.y - top.r.y;
    dragging = true;
    public void mouseReleased(MouseEvent e)
    dragging = false;
    // update top.r
    top.r.x = top.loc.x;
    top.r.y = top.loc.y;
    public void mouseDragged(MouseEvent e)
    if(dragging)
    top.loc.x = e.getX() - offset.x;
    top.loc.y = e.getY() - offset.y;
    top.r.setSize(65, 25);
    top.repaint();
    * Menus and other things.
    * I've made this for two reasons
    * 1) Every application has things like this.
    * 2) It's a pretty cool when you don't have to
    *      search for something in embedded option of
    *      application.
    * @author Marcin
    //     Our little menu
    class Menu extends JMenuBar                         //Still not finished
         JMenu File = new JMenu("File");
         JMenu Edit = new JMenu("Edit");
         JMenuItem firstItem = new JMenuItem("first");
         JMenuItem secondItem = new JMenuItem("second");
         Menu(){
              File.add(firstItem);
              add(File);
              Edit.add(secondItem);
              add(Edit);
    class OptionsTB extends JToolBar implements ActionListener                    //Still not finished
         ImageIcon sa = new ImageIcon("images/icons/Save24.gif");
         ImageIcon op = new ImageIcon("images/icons/Open24.gif");
         JButton _open;
         JButton _save;
         Separator sep1;
         JFileChooser _ch;
         OptionsTB()
              _open  = new JButton("Open", op);
              sep1 = new Separator();
              _save  = new JButton("save", sa);
              _open.addActionListener(this);
              _save.addActionListener(this);
              _ch = new JFileChooser();
              add(_open);
              add(_save);
              add(sep1);
              setFloatable(false);
              setSize(100, 50);
    // TODO Open and save handler
         public void actionPerformed(ActionEvent e)
              if( e.getSource() == _open){
                   int returnVal = _ch.showOpenDialog(OptionsTB.this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = _ch.getSelectedFile();
         //TODO We should have a file handler in here.
    } else
    if (e.getSource() == _save) {
         int returnVal = _ch.showSaveDialog(OptionsTB.this);
    if (returnVal == JFileChooser.APPROVE_OPTION);
         File file = _ch.getSelectedFile();
              //TODO We should have a save handler in here.
    class FunctionsTB extends JToolBar                    //Still not finished
         JButton _check;      
         ImageIcon star = new ImageIcon("images/icon/Star.png");
         FunctionsTB()
              _check = new JButton("Check", star);
              add(_check);
              setFloatable(false);
              setOrientation(VERTICAL);
              setSize(100, 50);
    class SecondPanel extends JPanel
         JEditorPane pane;
         JScrollPane scroll;
         public SecondPanel() {
              pane = new JTextPane();
              //pane.setBackground(Color.BLACK);
              pane.setText("Pierwsza linia");
              pane.setBackground(Color.BLACK);
              pane.setForeground(Color.WHITE);
              pane.setEditable(false);
              scroll = new JScrollPane(pane);
              scroll.setVerticalScrollBarPolicy(
    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
              scroll.setPreferredSize(new Dimension(600, 600));
              scroll.setMinimumSize(new Dimension(800, 600));
              add(scroll);
              JScrollPane scroll = new JScrollPane();
    --- THE END OF MY STUFF ---

    Hi nordvik_
    I developed a component that does exactly what you are talking about. Would you be interested in buying a copy?
    This is not a simple project, but if you're determined to build it yourself, here's a few hints
    1. How are you going to represent your nodes? Will they be components? The advantage of this is that with Components its easy to set size, implement painting. The disadvantage is that it's difficult to draw lines between components, and they will likely absorb mouse events that are outside of the shape's area (unless all your shapes are rectangles)
    2. How are you going to move + resize the components? If you search google for draggable.java/resizeable.java tjacobs01 you'll find some classes that I've previously posted that drag / resize components. This may or may not be helpful
    3. How are you going to internally represent the connection lines? how are you going to draw them? How are you going to figure out start and end points?
    If you're potentially interested in buying a copy of my source code, plz post your email address and I will contact you
    Edited by: tjacobs01 on Aug 10, 2008 2:17 PM

Maybe you are looking for

  • My ipad is charging but is not being recognised by iTunes

    please help

  • Validity for Condition type

    Hi Friends, We are using a delivery cost manual condition in MM Pricing. Presently there are many Open POs in which some of GRs were done and in some GR also not done. I want to change the condition validity  so that in future no one can select that

  • How to get beyond the error installing Shared Technologies in Photoshop Elements 12

    I am trying to install Adobe Photoshop Elements 12 on my Dell Precision Workstation T3400.  During the installation, I get the message 'The installation process has encountered an error while installing Shared Technologies.  In accordance with the on

  • ArticleStartDateOWSDATE missing in Managed Property list

    Hi, I'm using an out-of-the-box managed property "ArticleStartDateOWSDATE" in my Content Search webpart. My problem is I didn't know how this property been added in my Managed Property list under Search Service Application. When I look on the machine

  • N79 power saver, can't animate

    I just bought my N79 ..... quite cool ..... The problem is with the power saver. I like my phone to animate the clock after power svaer, It just go to black screen without the animation of the clock. Anyone know how? The other thing is in other model