Doing without layout manager

Hi guys.
I have a very complex problem.
I've been writing a code that should be able to display a general tree. The tree has to look like an organigram, if you know what I mean. For example, the parent node is a the top and the child nodes are underneath it.
It's clear that there is no layout manager that can handle this correctly. At least I assume.
I used the Node Positioning of John Walker to compute the x- and y-coordinate of each node.
I can display the nodes so far, but I don't know how to force a scrollpane to react to the size of the JPanel containing the nodes.
In fact, the JPanel containing the nodes of the tree has a null layout manager. If it contains let say 10 nodes, it becomes big enough. However the scrollpane doesn't grow along with the panel.
What should I do to let the scroll pane grow so that all nodes can be seen.
Regards.
Edmond

It's clear that there is no layout manager that can handle this correctly. Correct. So you need to create a custom layout manager.
I used the Node Positioning of John Walker to compute the x- and y-coordinate of each node. This is the code that should be added to your custom layout manager.
but I don't know how to force a scrollpane to react to the size of the JPanel containing the nodes.This is the job of the layout manager. It will determine the preferred size of the panel based on the location/size of all the components added to the panel.
Here is a simple example to get you started. This layout displays the components diagonally:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
public class NodeLayout implements LayoutManager, java.io.Serializable
     private int hgap = 20;
     private int vgap = 20;
     public NodeLayout()
      * Adds the specified component with the specified name to the layout.
      * @param name the name of the component
      * @param comp the component to be added
     @Override
     public void addLayoutComponent(String name, Component comp) {}
      * Removes the specified component from the layout.
      * @param comp the component to be removed
     @Override
     public void removeLayoutComponent(Component component)
      *     Determine the minimum size on the Container
      *  @param      target   the container in which to do the layout
      *  @return      the minimum dimensions needed to lay out the
      *                subcomponents of the specified container
     @Override
     public Dimension minimumLayoutSize(Container parent)
          synchronized (parent.getTreeLock())
               return preferredLayoutSize(parent);
      *     Determine the preferred size on the Container
      *  @param      parent   the container in which to do the layout
      *  @return  the preferred dimensions to lay out the
      *              subcomponents of the specified container
     @Override
     public Dimension preferredLayoutSize(Container parent)
          synchronized (parent.getTreeLock())
               return getLayoutSize(parent);
      *  The calculation for minimum/preferred size it the same. The only
      *  difference is the need to use the minimum or preferred size of the
      *  component in the calculation.
      *  @param      parent  the container in which to do the layout
     private Dimension getLayoutSize(Container parent)
          int components = parent.getComponentCount();
        int width = (components - 1) * hgap;
        int height = (components - 1) * vgap;
          Component last = parent.getComponent(components - 1);
          Dimension preferred = last.getPreferredSize();
          width += preferred.width;
          height += preferred.height;
          Insets parentInsets = parent.getInsets();
          width += parentInsets.top + parentInsets.right;
          height += parentInsets.top + parentInsets.bottom;
          Dimension d = new Dimension(width, height);
          return d;
      * Lays out the specified container using this layout.
      * @param       target   the container in which to do the layout
     @Override
     public void layoutContainer(Container parent)
     synchronized (parent.getTreeLock())
          Insets parentInsets = parent.getInsets();
          int x = parentInsets.left;
          int y = parentInsets.top;
          //  Set bounds of each component
          for (Component component: parent.getComponents())
               if (component.isVisible())
                    Dimension d = component.getPreferredSize();
                    component.setBounds(x, y, d.width, d.height);
                    x += hgap;
                    y += vgap;
      * Returns the string representation of this column layout's values.
      * @return      a string representation of this layout
     public String toString()
          return "["
               + getClass().getName()
               + "]";
     public static void main( String[] args )
          final JPanel panel = new JPanel( new NodeLayout() );
          panel.setBorder( new MatteBorder(10, 10, 10, 10, Color.YELLOW) );
          createLabel(panel);
          createLabel(panel);
          createLabel(panel);
          createLabel(panel);
          createLabel(panel);
          JButton button = new JButton("Add Another Component");
          button.addActionListener( new ActionListener()
               public void actionPerformed(ActionEvent e)
                    NodeLayout.createLabel( panel );
          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.add( new JScrollPane(panel) );
          frame.add(button, BorderLayout.SOUTH);
          frame.pack();
          frame.setLocationRelativeTo( null );
          frame.setVisible( true );
     public static void createLabel(JPanel panel)
          JLabel label = new JLabel( new Date().toString() );
          label.setOpaque(true);
          label.setBackground( Color.ORANGE );
          panel.add( label );
          panel.revalidate();
          panel.repaint();
}You would need to customize the getLayoutSize() and layoutContainer() methods to meet your Node Layout requirements.

Similar Messages

  • Placing components without layout manager not working

    Hey there, I am working on a java game version of pong which I have begun to try and do using Java Swing. The problem I am currently having is reposition the components in the main window part of the game which is were the user can start a new game or close the program. I having tried using the absolute positioning by setting the layout manager to null but then everything goes blank. I can't figure out why this is not working. Here is the code so far...
    import javax.swing.*;
    import java.awt.*;
    public class SwingPractice extends JFrame
        private Container contents;
        private JLabel titleLabel;
        private JButton startGameButton;
        public SwingPractice()
            super("SwingPractice");       
            contents = getContentPane();
            contents.setLayout(null);
            this.getContentPane().setBackground(Color.BLUE);
            startGameButton = new JButton("Start Game");
            startGameButton.setFont(new Font("Visitor TT1 BRK", Font.PLAIN, 24));
            startGameButton.setForeground(Color.cyan);
            startGameButton.setBackground(Color.blue);       
            startGameButton.setBounds(350,350, 75, 75);
            titleLabel = new JLabel("The Amazing Ping Pong Game!!");
            titleLabel.setForeground(Color.cyan);
            titleLabel.setBackground(Color.blue);
            titleLabel.setOpaque(true);
            titleLabel.setFont(new Font("Visitor TT1 BRK", Font.PLAIN, 24));
            titleLabel.setBounds(0,350, 75, 75);
            contents.add(startGameButton);
            contents.add(titleLabel);
            setSize(700,350);
            setResizable(false);
            setVisible(true);
        /*private class SwingPracticeEvents implements ActionListener
        public static void main(String [] args)
            SwingPractice window = new SwingPractice();
            window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       Any other critiquing would be greatly appreciated. Thank you.
    Edited by: 804210 on Oct 21, 2010 1:30 PM

    804210 wrote:
    Hey there, I am working on a java game version of pong which I have begun to try and do using Java Swing. The problem I am currently having is reposition the components in the main window part of the game which is were the user can start a new game or close the program. I having tried using the absolute positioning by setting the layout manager to nullDon't. Ever. Never. Well, mostly.
    Read the tutorial chapter about [url http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html]Laying out components. It even features a section on absolute positioning - which you should skip reading, of course! :o)
    And read this old Sun topic: http://forums.sun.com/thread.jspa?threadID=5411066
    Edited by: jduprez on Oct 21, 2010 10:48 PM

  • Does anyone know how to win a fight with layout manager?

    I am using the form designer in netBeans to design my page, which has a jPanel on the left and a number of controls on the right.
    My problem is that when I eventually get it to look half right at design time, it looks different at run time. The fonts are different, the combo boxes are a different height and some of my text boxes are 4 times as wide. http://RPSeaman.googlepages.com/layout.GIF shows both the design-time view and the run-time view. How can I win my fight with layout manager?

    I'd like to do an experiment where you take say 20 pairs of students of java, with each pair matched in terms of prior programming and java experience, general knowledge, etc... and set one of each pair to learn Swing using netbeans and its layout generator with the other pair learning to code Swing by hand. Then 6 months later compare their abilities. I'll bet that the code by hand group will blow the other group out of the water in terms of understanding and ability.
    Just my 2 Sheckel's worth.

  • HU without inventory management and message L3778 in storage type 999

    Hi experts,
    Need suggestion on the process to add inventory of an HU with status 'HU without inventory Management'. This issue has occurred out of the below scenario:
    1. our warehouse is HU & WM managed.
    2. We have a transfer order for a delivery document requesting to pick up 100 cases of MAT1 which is assigned to HU1.
    3. While confirming the transfer order user has confirmed difference for the full quantity of 100 because the SU/HU was not found in the bin.
    4. The system has set the status of HU as 'HU without inventory Management'. The HU is empty.
    5. system has moved the stock from the bin to difference storage type 999.
    Now user has found the stock for this HU and he wants to post the stock back into the bin. system does not allow to move the stock back to bin using LT01 as we get error message 'L3 778'.
    What will be the best practice to get the stock back into the bin and post the stock into the same old HU.
    Is there a process wherein we can post this stock to another bin and repack into the old HU?
    Thanks,
    Harish

    Thanks Manish on the hint. I was able to transfer stock to partner location and then bring back to original Storage type/Bin. Below steps was used to fixed the issue:
    1. Initiate a transfer of stock from WM/HU Sloc where the IM stock resides into Sloc 9099. An outbound delivery is created during this process.
    2. Create a transfer order with reference to delivery and pick the stock from 999 storage type.
    3. Create a Pick HU using LH01 and assign the HU on the pallet to the transfer order.
    4. Confirm the transfer order using LT12.
    5. Perform PGI for the delivery.
    6. Use HUMO to display the HU and then you can transfer the stock back to WM/HU location using the storage location transfer option available on the HUMO screen(EDIT à change HU posting à Storage location)
    7. Perform Bin to bin transfer to move the SU from 921 storage type to putaway the HU/SU back to the destined Storage type/Bin.
    Best Regards,
    Harish

  • Handling unit without inventory management

    Hi Experts,
    In our scenario, we have Goods reciept from production into Storage location 1000 which is IM managed, Later the stocks are transfer posted into storgae location 1100 which is HU/WM managed. Now in 1100 i have found HU's which have been created with status 'Handling unit without Inventory management'.
    Can someone explain to me what does it mean when a HU gets created with this status? under which scenario does the system create the HU with this status?
    Also when this HU is scanned for putaway the system gives error message Handling unit does not exist in SAP. Can someone let me know the resolution or the root cause for this issue.
    Thanks in advance.
    Harish

    Hi,
    The above mentioned status is when a Handling Unit created, but the Inventory management is not yet posted for the content materials of the HU
    I can give an example:  Created a Inbound Delivery for material XXX. Then a HU is created in Packing screen, but the PGR is not yet done. At this stage, HU has the same status
    Hope this helps
    If the GR/GI is reported for HU contents, then the HU status will change. With you case, a Handling Unit is just created, but no further tansaction like, packing, GI or GR is done.
    Regards,

  • Handling unit mangement without Warehouse management

    Hello,
    We are working on a scenario,wherein we are planning to use handling unit management without warehouse management.Does HU management and WM go hand in hand?
    Do you foresee any inconsistencies if HU management is implemented without WM?
    What does SAP recommend?
    Thanks,
    Pankaj

    Hello,
    WM and HU functionality are independent solutions. WM and HU could be implemented based on your business scenarios. It is pretty common to have WM and HU solutions for the business.
    It will be sort of difficult to answer about inconsistency in HU solution without WM. Based on what process you define and what are the intricacies involved you may or may not have true inconsistencies.
    You could refer to the SAP best practices help library and see if for your business scenario SAP has a solution and that way you could best define an integrated solution.
    Hope this helps.
    Thanks,

  • The most precise layout manager

    It's time to decide on a layout. My java game screen is a fairly complex jumble of info in little boxes here and there. Everywhere.
    I'm not a java pro yet, but am I correct in thinking that there is -no- pixel grid layout manager? Meaning, I could define the coords for each element? I don't think there is one like that.
    All that being said, what java layout manager gives you the most precise control over element placement? It looks like the Box or GridBag, but I'm not certain.
    Thank you in advance for your expert oppinion :-)
    Mark Deibert

    From my experience I've found that using a combination
    of layout managers works best for fine tuning things.
    For example you can create a panel for your buttons
    implementing a flow layout then a panel for your
    checkboxes using a gridbag layout etc.
    The code might not be as neat as using a single
    manager but it does give you more control on where
    things go by breaking the GUI up into more manageable
    pieces.I agree with that - I really never use absolute postioning. Think in an object oriented way when you choose LayoutManagers - arrange all components, that are displayable by the same LayoutManager in a separate JPanel with this LayoutManager - add only those components, which are in the same context to that, what this JPanel should do.
    For example - when you want some buttons to show up in the center of JPanel, use two JPanels, one with FlowLayout, where you add the buttons, and add this JPanel to a second one with BorderLayout to its center. If you now want to place these buttons to the bottom of another panel, you easily add it to a JPanel with BorderLayout to its bottom - the hole JPanel, not the buttons. That is also quite fine if you want to repostion those functional units later on - components, that are in a relation to each other will stay together this way and must not be repositioned component by component.
    greetings Marsian

  • JAVAFX have FANTASTIC LAYOUT MANAGER!

    NEW version 2.2!!! is new from 2.1
    I find a fantastic layout for javafx, it is static and dynamc with Scene. You can create special indipendent rows and set all cols and rows size. Is better than java layout. You can create span cols. You can set grow in vertical and horizontal. You can set alignment and other. It is user friendly and simple to use for all. Is easy create form and panel with this layout.
    He's name is DigLayout. For tutorial and samples:
    See articles in jfxstudio web site: http://jfxstudio.wordpress.com/2009/03/05/new-advanced-javafx-layout-manager-diglayout-from-jdlayout-library/
    See official project webpage: http://code.google.com/p/diglayout/
    simple to use:
    import Window.JDLayout.;
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.text.Text;
    import javafx.scene.text.Font;
    import javafx.scene.effect.;
    /   @author Diego Benna [email protected]
    var panel = DigLayout?{
            // All setting
           // Rows and Items
            digrows:[
                    Row{
                            items:[
                                    Item{
                                            valign:"middle"
                                            halign:"center"
                                            item:
                                                    javafx.ext.swing.SwingLabel? {
                                                            text: "Item 1"
                                    Item{
                                            valign:"middle"
                                            halign:"center"
                                            item:
                                                    javafx.ext.swing.SwingLabel? {
                                                            text: "Item 2"
                    Row{
                            items:[
                                    Item{
                                            valign:"middle"
                                            halign:"center"
                                            item:
                                                    javafx.ext.swing.SwingLabel? {
                                                            text: "Item 3"
                                    Item{
                                            valign:"middle"
                                            halign:"center"
                                            item:
                                                    javafx.ext.swing.SwingLabel? {
                                                            text: "Item 4"
    Stage{
            title : "UnitTest? Simple Panel"                                       
            scene : Scene{
                width: 540
                 height: 370
                content: [
                    panel
    What do you think??

    DiegoBenna wrote:
    NEW version 2.2!!! is new from 2.1
    I find a fantastic layout for javafx
    What do you think??I think you are doing a bit too much advertisements for your product, and pretending to "find" it when you made it is on the limit of honesty.
    I think I dislike CRYING OUT loud with capitals in forums and mailing lists.
    I think you are right to present your product, and you probably made a good product, but such marketing ploys don't make me feeling like trying it.
    Just my opinion, perhaps too arrogant, and certainly more looking upset than I am actually, but I felt I had to let you know, in case you wonder why you have so little reactions to your messages... :-) I don't mean to be offensive, somehow I try to help (otherwise I would just shut up and go my way).
    Have a good day and I sincerely wish your product will become as popular as it deserves.

  • Image (jpeg, gif) display in AWT layout manager

    Goodmorning All,
    I am looking for some help, a hint on my AWT Layout challenge i have.
    Example GUI_1:
    =========================
    Window border..................[_][x]..
    =========================
    [label]....|display_area|....[button].
    [label]....|display_area|....[button].
    ...............|display_area|....[button].
    ...............|display_area|....[button].
    ...............|display_area|..................
    =========================
    ...........................................[QUIT].....
    =========================
    I want to
    - display a picture in the "display area" of the this GUI
    - put labels left of it with some text
    - put a couple of buttons right of it, through which i am able to manipulate the image
    Questions:
    *1. Is it (even) possible to display an (jpeg,gif) image in the "display area" while using a layout manager?*
    Surfing over the internet...so far i only have found applet-examples that use the full gui surface of the applet to display an image via the g.drawImage (imagename, x,y); without any gui elements (labels, buttons) beside it.
    *2. What kind of AWT gui element do i need at the location of the "display area"?*
    Is is possible to use a CANVAS or do i need somethen else? (e.g. glue an image on a button)
    *3. Is is possible to display an ANIMATION (series of sequences jpeg, gifs) in the display area?*
    I already found out how to locate and load the images (via mediatracker).
    Now i need to find a way to "paint" the loaded images in the GUI.
    *4. Is this even possible with AWT layout or do i need to switch to SWING layout?*
    I have not used Swing yet, cause i'm working my way up through the oldest gui technologie first.
    *5. Do know any usefull websites, online tutorials (on awt and displaying images) that can help me tackle my challenge?*
    Thank you very much for your hints, tips and tricks

    A link as Gary pointed out is the best way to see what the problem may be.
    Did you save the image to your working folder and have you defined a site pointing to this folder.
    Defining a site helps Dreamweaver track and organize the files used in this site.
    http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14028
    If you can't see the image, this means that the path to the image is incorrect.
    Nadia
    Adobe Community Expert : Dreamweaver
    Unique CSS Templates | Tutorials | SEO Articles
    http://www.DreamweaverResources.com
    Web Design & Development
    http://www.perrelink.com.au
    http://twitter.com/nadiap

  • Rename or delete manually created menus from Report and Layout Manager

    Hi All,
    Does anyone know if it's possible to rename or delete a folder manually created during a report import in the Report and Layout manager?
    Kind regards,
    Matt

    Posted the question on the SAP core forum.

  • A better FlowLayout layout manager... with linebreaks

    I go frustrated enough with the lack of a useful layout manager that I ended up writing my own. It's basically a FlowLayout layout manager, but allowing "new line" and "new block" commands so that it can actually do what most people asking about FlowLayout want.
    The post for it is on http://pomax.nihongoresources.com/index.php?entry=1242306034 with a link to the jarchive for it (javadoc linked in same entry).
    Hopefully this is of use to people other than myself.
    - Mike "Pomax" Kamermans
    nihongoresources.com

    Hi,
    A JInternal frames insisde a JDesktopPane without any LayoutManager
    Bye

  • Cant find suitable Layout  Manager

    Hello!
    I am doing a project where i allow user to drag an area on frame and then I should put a new JtextArea on that area. I have used the setBounds method of JTextArea to specify the location points but becoz of the layout manager (Flow Layout) it automatically shifts to other place in the frame.
    I have tried using other layouts but none helps to keep the textarea at specified place. Plz help!!

    Hi,
    You need to set the layout manager to null. This will allow you to specify size/location using setBounds.
    Regards,
    Ahmed Saad

  • MDM integration without Solution Manager

    Hi All,
    I hope we can have MDM implementation without solution manager. (Please correct me if I am wrong.)
    Can anybody explain me the concerns if I don't have solution manager in my MDM implementation framework.
    Customising Steps to integrate all the components with MDM Server.
    Thanks in advance,
    Regards..
    Sambhaji

    Hi Sambhaji,
    Which release are you referring to?
    The current release SAP NetWeaver MDM 5.5 does not require Solution Manager for implementation. (Customizing tasks are done in the MDM Console).
    As far as MDM 3.00 is concerned, the Solution Manager is used for Customizing synchronization and distribution. Please refer to the relevant Master Guide in the Service Marketplace for further information.
    Regards, Markus

  • Problems with integrating YUI Layout Manager with APEX

    Hello,
    I have a problem about the YUI Layout Manager and APEX.
    This is the link to the Layout Manager, which I want to integrate:
    http://developer.yahoo.com/yui/layout/
    I tried to integrate it and in Firefox everything is fine!
    But with Internet Explorer the page is damaged.
    Look at the sample on apex.oracle.com:
    http://apex.oracle.com/pls/otn/f?p=53179:1
    Can anybody help me with this issue?
    I think this couldn`t be a big problem, becaus in FF it works correctly, but I don`t get the point to run that in IE7.
    Thank you,
    Tim

    Hello,
    now I put some color in it, but it does not help me pointing out the problem.
    The Login for my Account is:
    My Workspace is: EHRIC02
    Username: [email protected]
    Password: ehric02
    Is there anybody who have implementet the YUI Layout Manager with APEX? Perhaps that isn`t possible with APEX?
    I know that John Scott played with YUI a few times, has he tried out the Layout Manager?
    Thank you,
    Tim

  • Employees Salary without Time Management sub-module?

    Dear Consultants,
    Where to record employees attendance/absences (time related information) inorder to pay the salary through SAP-HR Payroll? We are implementing PA and Payroll (International). Time Management is not in the scope of the project.
    Could you please let me know, how can we handle this without Time Management. What would be the limitations without Time Management sub-module.
    Thank you all for your efforts.
    Edited by: Business Analyst - HCM on May 20, 2009 2:20 PM

    You have to create atleast the work schedule which will consist of DWS and PSW and then work scheedule rule. Also I think you will require to configure feature SCHKZ to default work schedule rule in IT0007.
    After doing this configuration you can create wagetypes related to ur time and you can pay these wage types through IT2010 ee remuneration info
    if the wt will have rate then that rate you can maintain in T510 and may be to meet the complete requirement you need to write little bit code in CATS exit.
    otherwise you will be able to pay through 2010 and you can enter the data thru CAT2 tcode. Just you need to create a profile and set the view for entering the data like single entry or mass entry.
    SPRO->IMG->Cross-Application Components->Time Sheet->Specific Settings for CATS Regular->CATS Regular->Record Working Time
    hope this will help
    guds

Maybe you are looking for

  • Custom Column using Function - How to Continue on Error

    I'm using Wolfram Alpha from Azure Data Marketplace API. I'm using a list of Zipcodes in Excel. I've created a concatenated column that merges Zipcode (column a) with "Population for Zipcode & ColumnA" & passing that column to the Wolfram Alpha funct

  • How can I get reimbursed for an unauthorized account charge by Fruit Ninja HD Free through In App Purchase?

    Hi There, I was not able to report my problem through the link given on the receipt. Therefore, I am reporting my problem here hoping that someone will care about it: On the 2nd of June 2012, I have downloaded some free game apps in the Apple Store u

  • Purcahse order not coming in FBL1N Report

    Hi ,    When i go to FBL1N Report ( Vendor Line Items Display ) , and execute it inside the Purchasing document field i am not getting the Purchase Order number  , its blank , why is it so , is there any extra settings to be done for that regards raj

  • Message control buttons in Japaneese

    My galaxy s5 messaging buttons are in Japaneese.  I can sent messages in english but all the control buttons - such as the send button - are all in japaneese.  it is driving me crazy.....anyone have any ideas.  I have looked at my setting and all of

  • Google searches redirect to unwanted sites such as K Directory

    Using the Google search engine when I click a link in a result I increasingly end up at an unrelated and sometimes totally random website! For example a lot of the time I end up at www.kdirectory.co.uk. Other times I end up on youtube? Bizarre and in