Swap component positions dynamically

Hello,
I want to be able to dynamically swap the postions of any two components within a single container.
For example, if I have a JPanel that has a BorderLayout, I want to be able to to swap the NORTH and WEST components with each other.
I find that it is easy to remove them from their current positions.
However, my problem is how to add them back with the proper layout constraints. I don't see any Container methods that will allow me to get the layout contraints of an existing component so that I can then transfer it when adding another component dynamically.
After the swap, the components should resize properly when the container is resized, as if each had initially been added to the container with the given layout manager with the other's constraints.
I would like this to be a general solution that will work for any Container and any LayoutManager.
Thank you,
Ted Hill

For you problem, it will be nice, if each Layout Manager has a method call swapComponent ...
I do not think there are esay solution for this problem.
Because most of layout manager, keep those information private!
Here are some of my ideas :
(1) Keep the information by youself in your code.
Well, you can use a hashTable, keep those constraint layout infomation by youself.
Before or After add the component, save the constraint info.
And when you need to swap, just use it.
(2) You still need to keep those information ( may-be by using hashTable ),
but this time, implement to more generic way.
==> subclass all layout managers you are interresting.
Overriden the addLayoutComponent and removeLayoutComponent,
make sure you capture the constraint information and save some where.
Also add new method swapComponent();
And by subclass, you may access protected method or field (that may related to constraint info... )
In this way, you just implement once, and you can re-use forever.
Hope this helps you.

Similar Messages

  • How to swap the position of two objects?

    I have four self made componensts that I imported them into my main mxml file
    and placed each on four corners.
    What I want to achieve is to drag each component onto others then swap their position.
    For example, comp A is dragged over comp B, when this is detected, swap the position of A and B.
    But at the moment it doesn't seem to work properly. I could not figure out what's wrong with my code. Could any one help me achieve that?
    Many thanks to any who could give me a hand!
    *********This is one of my component***********
    *********All other three components are made the same way, except each source of image file is different******************
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Box xmlns:mx="http://www.adobe.com/2006/mxml" width="42" height="42">
        <mx:Image source="Images/air.png"/>
    </mx:Box>
    *********This is my mxml that calls my components***********
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:comp="Comp.*" creationComplete = "onInit()">
        <mx:Script>
            <![CDATA[
                import mx.containers.Box;
                import Comp.Icon_illustrator;
                import Comp.Icon_air;
                import Comp.Icon_flash;
                import Comp.Icon_flex;
                private var i_1:Icon_air; //1
                private var i_2:Icon_flash; //2
                private var i_3:Icon_flex; //3
                private var i_4:Icon_illustrator; //4
                private var origX:Number;
                private var origY:Number;
                private var startObj:String;
                private var icons:Array;
                private var h_1:Box;
                private var h_2:Box;
                private var h_3:Box;
                private var h_4:Box;
                private function onInit():void{
                    //initialise all icons
                    i_1 = new Icon_air();
                    i_2 = new Icon_flash();
                    i_3 = new Icon_flex();
                    i_4 = new Icon_illustrator();
                    i_1.name = "i_1";
                    i_2.name = "i_2";
                    i_3.name = "i_3";
                    i_4.name = "i_4";
                    //populate icon
                    showArea.addChild(i_1);
                    showArea.addChild(i_2);
                    showArea.addChild(i_3);
                    showArea.addChild(i_4);
                    //set x position
                    i_1.x = 100;
                    i_2.x = 200;
                    i_3.x = 100;
                    i_4.x = 0;
                    //set y position
                    i_1.y = 0;
                    i_2.y = 100;
                    i_3.y = 200;
                    i_4.y = 100;
                    icons = [i_1, i_2, i_3, i_4];
                    //addEventListeners
                    for(var i:int=0; i<icons.length; i++){
                        icons[i].addEventListener(MouseEvent.MOUSE_DOWN, moveMe);
                        icons[i].addEventListener(MouseEvent.MOUSE_UP, stopDragMe);
                }//end of onInit
                private function moveMe(e:MouseEvent):void{
                    e.currentTarget.startDrag();   
                    showArea.setChildIndex(DisplayObject(e.currentTarget), 0);
                    origX = e.currentTarget.x;
                    origY = e.currentTarget.y;
                    startObj = e.currentTarget.name;   
                private function stopDragMe(e:MouseEvent):void{
                    if(this[startObj].hitTestObject(icons[1])){
                        trace("hit 2");
                        this[startObj].x = i_2.x;
                        this[startObj].y = i_2.y;
                        i_2.x = origX;
                        i_2.y = origY;
                    }else if(this[startObj].hitTestObject(icons[0])){
                        trace("hit 1");
                        this[startObj].x = i_1.x;
                        this[startObj].y = i_1.y;
                        i_1.x = origX;
                        i_1.y = origY;
                    }else{
                        trace("hit others");
                        this[startObj].x = origX;
                        this[startObj].y = origY;
                    e.currentTarget.stopDrag();
                }//end of stopDragMe
            ]]>
        </mx:Script>
        <mx:Panel id="showArea" width="400" height="300" layout="absolute" backgroundColor="0x999999"/>
    </mx:WindowedApplication>

    Here is a sample of swaping two objects in Flex (not Air)   I believe it is the same.  Take a look at the way the x and y coords are swapped using the dragInitator and the currentTarget object in the dragDropHandler.
    Hope this helps
    <?xml version="1.0" encoding="utf-8"?><mx:Application  xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
     <mx:Script>
    <![CDATA[
     import mx.containers.Box; 
    import mx.core.UIComponent; 
    import mx.managers.DragManager; 
    import mx.core.DragSource; 
    import mx.events.DragEvent; 
    private var dragProxy:Box= new Box(); 
    public function dragDropHandler(e:DragEvent): void { 
    //These variables are the x and y coords of the objects 
    //the e.dragInitator is the object being dragged 
    //the e.currentTarget is the object being dropped on 
    //First save the x and y coords of each of the objects 
    var xdi:int = e.dragInitiator.x; 
    var ydi:int = e.dragInitiator.y; 
    var xct:int = e.currentTarget.x; 
    var yct:int = e.currentTarget.y; 
    //now switch them around.e.dragInitiator.x = xct;
    e.dragInitiator.y = yct;
    e.currentTarget.x = xdi;
    e.currentTarget.y = ydi;
    public function dragEnterHandler(event:DragEvent):void { 
    DragManager.acceptDragDrop(UIComponent(event.target));
    public function mouseMoveHandler(event:MouseEvent):void { 
    if(event.buttonDown == false) return; 
    var dragInitiator:UIComponent = event.target as UIComponent; 
    var dragSource:DragSource = new DragSource(); 
    dragProxy =
    new Box();dragProxy.width = dragInitiator.width;
    dragProxy.height = dragInitiator.height;
    dragProxy.setStyle(
    "borderStyle","solid")dragProxy.setStyle(
    "borderColor","0x000000")dragProxy.setStyle(
    "backgroundColor","0xc6c6c6"); 
    DragManager.doDrag(dragInitiator, dragSource, event, dragProxy,
    event.localX * -1, event.localY * -1, 1.00);
    ]]>
    </mx:Script>
     <mx:Canvas width="84" height="93" x="23" y="14" borderStyle="
    solid" borderColor="
    #030303" backgroundColor="
    #F83C3C"dragEnter="dragEnterHandler(event)"
    dragDrop="dragDropHandler(event)"
    mouseMove="mouseMoveHandler(event)"
    >
     </mx:Canvas>
     <mx:Canvas width="84" height="93" x="223" y="14" borderStyle="
    solid" borderColor="
    #030303" backgroundColor="
    #C5F83C"dragEnter="dragEnterHandler(event)"
    dragDrop="dragDropHandler(event)"
    mouseMove="mouseMoveHandler(event)"
    >
     </mx:Canvas>
     </mx:Application>

  • Why do I get Illegal Component position when I say FlowLayout.CENTER

    The code runs fine if you replace the line
    Jp7.add(submitButton, FlowLayout.CENTER);
    with
    Jp7.add(submitButton);
    I know FlowLayout's default location is CENTER. But when I explicitly say to center the button, it crashes during runtime but compiles fine.
    Whats the reason for this? Is this a bug?
    I am using 1.4.0_03.
    I getthe following error.
    Exception in thread "main" java.lang.IllegalArgumentException: illegal component
    position
    at java.awt.Container.addImpl(Container.java:568)
    at java.awt.Container.add(Container.java:327)
    at Mon2.main(Mon2.java:114)
    ALSO CAN I DO THE SAME WITHOUT USING SO MANY JPANELS?????????????????? I AM NOT NEW TO PROGRAMMING BUT I AM NEW TO GUI PROGRAMMING.
    Thanks in advance.
    import java.sql.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Mon2 extends JFrame{
    static long i =0;
    static int jobid = 0;
    static String StartTime = "";
    static String LastReport = "";
    static String FinishTime = "";
    static String Description = "";
    static String job_position = "";
    static String desc ="";
    public static String database = "";
    public static String user = "";
    public static String password = "";
    static int counter = 1;
    static boolean valuesEntered = false;
      JButton jButton1 = new JButton();
      JButton jButton2 = new JButton();
      JButton jButton3 = new JButton();
      BorderLayout borderLayout1 = new BorderLayout();
      JLabel jLabel1 = new JLabel();
    JTextPane jTextArea1 = new JTextPane();
    static JTextField userArea = new JTextField();
    static JPasswordField passArea = new JPasswordField();
    static JTextField databaseArea = new JTextField();     
    static JFrame f = new JFrame();
    static JLabel us = new JLabel ("UserName: ");
    static JLabel pa = new JLabel ("Password: ");
    static JLabel da = new JLabel ("Database: ");
      BorderLayout borderLayout2 = new BorderLayout();
      JPanel jPanel1 = new JPanel();
      JLabel jLabel2 = new JLabel();
         public Mon2() {
        try  {
          jbInit();
        catch (Exception e) {
          e.printStackTrace();
         public static void main(String args[]) {
              System.out.println("Starting Mon2...");
        f.setSize(300,200);
        f.setTitle("Login");
        f.setLocation(250,250);
        f.setResizable(false);
        Panel Jp1 = new Panel (new BorderLayout());
        Panel Jp3 = new Panel (new BorderLayout());
        Jp3.add(us, BorderLayout.NORTH);
        Jp3.add(pa, BorderLayout.CENTER);
        Jp3.add(da, BorderLayout.SOUTH);
        userArea.setEditable(true);
        userArea.setSize(20,20);
        passArea.setEditable(true);
        databaseArea.setEditable(true);
        JButton submitButton = new JButton("Submit");
        JPanel Jp2 = new JPanel (new BorderLayout());
        JPanel Jp4 = new JPanel (new FlowLayout());
        userArea.setPreferredSize(new Dimension(200,21));
        Jp4.add(userArea, FlowLayout.LEFT);
        Jp4.add(us, FlowLayout.LEFT);
        JPanel Jp5 = new JPanel (new FlowLayout());
        passArea.setPreferredSize(new Dimension(200,21));
        Jp5.add(passArea,FlowLayout.LEFT);
        Jp5.add(pa, FlowLayout.LEFT);
        JPanel Jp6 = new JPanel (new FlowLayout());
        databaseArea.setPreferredSize(new Dimension(200,21));
        databaseArea.setText("DWPROD");
        Jp6.add(databaseArea,FlowLayout.LEFT);
        Jp6.add(da, FlowLayout.LEFT);
        Jp1.add(Jp4, BorderLayout.NORTH);
        Jp1.add(Jp5, BorderLayout.CENTER);
        Jp2.add(Jp6, BorderLayout.NORTH);
       JPanel Jp7 = new JPanel(new FlowLayout());
    ///////////////////////////This is  the line//////////////////
    //If you remove the ,FlowLayout.CENTER it works fine.
    //If you leave it like as it is, it will compile but then give runtime error
        Jp7.add(submitButton, FlowLayout.CENTER);
        Jp2.add(Jp7, BorderLayout.SOUTH);
        Jp1.add(Jp2, BorderLayout.SOUTH);
        f.getContentPane().add(Jp1);
        Image img = Toolkit.getDefaultToolkit().getImage("c:\\appletHeader.gif");
        f.setIconImage(img);
        f.setDefaultCloseOperation(3);
        f.setVisible(true);
        f.pack();
         submitButton.resize(75, 30);
        submitButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
        user = userArea.getText();
        password = passArea.getText();
        database = databaseArea.getText();
        if((user.equals(null) || password.equals(null) || database.equals(null) || user.equals("") || password.equals("") || database.equals(""))){
        valuesEntered = false;
        else{
             valuesEntered = true;
        if(valuesEntered == true){
        f.setVisible(false);
              Mon2 mainFrame = new Mon2();
              mainFrame.setSize(600, 400);
              mainFrame.setTitle("Monitor");
        mainFrame.setLocation(100,200);
        mainFrame.setResizable(false);
        desc = "ERROR! or there are no locked jobs.";
              mainFrame.setVisible(true);
        else{
        JOptionPane.showMessageDialog(null,"Must enter values for UserName, Password and Database", "Value Required",JOptionPane.INFORMATION_MESSAGE);
    //    System.exit(0);
      private void jbInit() throws Exception {
        this.setDefaultCloseOperation(3);
        jButton1.setText("Refresh");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
          jButton1_actionPerformed(e);
        jButton2.setText(" Exit ");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
        this.getContentPane().setLayout(borderLayout1);
        jButton3.setText("Clear");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jTextArea1.setText("Click on Refresh to update screen.");
        Panel p = new Panel(new FlowLayout());
        Panel p2 = new Panel (new BorderLayout());
        jLabel1.setText("Monitor for current Job");
        jTextArea1.setPreferredSize(new Dimension(8, 50));
        jTextArea1.setContentType("text/html");
        jTextArea1.setText("");
        jTextArea1.setEditable(false);
        f.setResizable(false);
        f.setTitle("Login");
        jLabel2.setHorizontalTextPosition(SwingConstants.LEFT);
        jLabel2.setText("jLabel2");
        jLabel2.setHorizontalAlignment(SwingConstants.LEFT);
        f.getContentPane().setLayout(borderLayout2);
        jTextArea1.setSize(100,10);
        p.add(jButton1);
        p.add(jButton3);
        p.add(jButton2);
        this.getContentPane().add(jLabel1, BorderLayout.NORTH);
        this.getContentPane().add(jTextArea1, BorderLayout.CENTER);
        p2.add(p, BorderLayout.CENTER);
        this.getContentPane().add(p2, BorderLayout.SOUTH);
        pack();
        f.getContentPane().add(jPanel1, BorderLayout.CENTER);
        jPanel1.add(jLabel2, null);
      void jButton1_actionPerformed(ActionEvent e){
            jTextArea1.setText("Refreshing...");
            long i = 0;
         try{
              jTextArea1.setText("In side try block");
                    Thread.sleep(1000);
                   DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                   jTextArea1.setText("DriverManager");
                  Connection conn=
                   DriverManager.getConnection("jdbc:oracle:thin:@machine:1234:"+ database, user, password);
                                                                          jTextArea1.setText("Got COnnection");
                   Statement stmt = conn.createStatement();
                   jTextArea1.setText("Statement Created");
                   ResultSet rs =
                   stmt.executeQuery("select 1, sysdate, sysdate, sysdate, sysdate, sysdate from dual ");
                   jTextArea1.setText("Query Executed");
                   while(rs.next()){
          jobid = rs.getInt(1);
          StartTime = rs.getString(2);
          LastReport = rs.getString(3);
          FinishTime = rs.getString(4);
          Description = rs.getString(5);
          job_position = rs.getString(6);
          desc = "<b>Count: </b>" + counter + "" +
                     "<p><table border = '1'><tr><td><b>JOB ID:      </b></td><td>" + jobid + "</td></tr>" +
                 "<tr><td><b>Start Time:  </b></td><td>" + StartTime + "</td></tr>" +
                 "<tr><td><b>Last Report: </b></td><td>" + LastReport + "</td></tr>" +
                 "<tr><td><b>FinishTime:  </b></td><td>" + FinishTime + "</td></tr>" +
                 "<tr><td><b>Description: </b></td><td>" + Description + "</td></tr>" +
                 "<tr><td><b>Position:    </b></td><td>" + job_position + "</td></tr></table>";
                  counter = counter + 1;
                     rs.close();
                   conn.close();
                    jTextArea1.setText("Sleeping");
                    jTextArea1.setText(desc);
                    desc = "";
              catch (SQLException se){
              jTextArea1.setText(desc + se);
           catch(Exception ee){
                jTextArea1.setText("Exception occured\n\n" + ee);
    }

    Get your basics checked.
    Go to:
    http://developer.java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/shortcourse.html#whatAreLMs
    And find the heading: FlowLayout Variations
    FlowLayout can be customized at construction time by passing the
    constructor an alignment setting:
    FlowLayout.CENTER (the default)
    FlowLayout.RIGHT
    FlowLayout.LEFT

  • Illegal component position error

    Hi I'm new to GUI's and I'm trying to add a menu bar onto my jframe for a creation of a word processor. I'm using the Jtextarea for the text field. I keep getting this message but dont understand what it means:
    java.lang.IllegalArgumentException: illegal component position
    at java.awt.Container.addImpl(Container.java:325)
    at java.awt.Container.add(Container.java:252)
    at javax.swing.JMenu.add(JMenu.java:511)
    at wordprocessor.WordProcessorDemo.<init>(WordProcessorDemo.java:68)
    at wordprocessor.WordProcessorDemo.main(WordProcessorDemo.java:18)Any help would be greatly appreciated. Thanks.

    Is that the only thing wrong or is there more to it?

  • Positioning dynamic text in SAP Script windows

    HI all,
    Is there any control command to position DYNAMIC text that comes from a variable into a window...
    Regards,
    Chandra Sekhar

    Hi chandra,
    You can move the text into one variable in the print
    program and in the layout form call this as
    &VAR&.
    Thanks&Regards,
    Siri.

  • Illegal component position when add JLabel to JtextPane

    Hi all,
    I want to add a JLabel to a JTextPane, the label shoud be put in the lines of text just like the normal text. I have some questions:
    1. How can I put the label in the position we want, when I use the method add(label, textPane.getStyledDocument().getLength()), it generates exception :"illegal component position"
    2. How can I set the width and the height of the label so that user cannot know that I used the label. I mean the text on label and the normal text on JTextPane must look the same. Of course I know the length of the caption of the label
    Thank you very much

    How can I put the label in the position we want, I'm not sure you can add a component using that method. I think there is an insertComponent(...) method to use. Also you may need to make the text pane uneditable first if I remember correctly. Something like:
    textPane.setEditable(false);
    textPane.insertComponent(...);
    textPane.setEditable(true);
    How can I put the label in the position we want, label.setFont(textPane.getFont());

  • Dynamically component position

    hello all,
    In a screen is a component(dropdown list) which must be positioned always at the center of the screen. How to set its position accorded to the screen size?
    thank you a lot
    Bogdan

    i am not sure but you can drag and drop any column in screen. also you have column number feature in attribute

  • Implement commit,rollback,cancel popup when swapping task in dynamic region

    Hello,
    I have been trying to implement this functionality when I swap task flows in a dynamic region....
    A popup/dialog to be displayed with the following options (assuming there are changes to be saved on the task flow being swapped out)
    Commit - save the changes on the the outgoing task flow and continue to bring in the new task flow
    Rollback - cancel the changes on the the outgoing task flow and continue to bring in the new task flow
    Cancel - remain on the outgoing task flow and do not bring in the new task flow
    If i click on a button within the outgoing task flow, it is possible to determine the condition of the view object, determine if there are pending changes and display such a dialog, the problem is if that the navigation within the dynamic region is being performed from outside the region, we are advised against using task flow return activities when using bounded task flows within regions ( section 17.1.8 of fusion dev guide for 11.1.1.1.0 ) so the only thing i can think of is building a finalizer routine for the task flow. While this does get executed when the task flow is swapped out... how can i display the dialog from there, and stop execution of the finalizer and return to the original task flow if ultimately i want to cancel.
    Any ideas? other solutions?
    Thanks.

    Thanks for the reply Richard,
    I think this will probably be an important feature for anyone using the single page model, unless that model is not being encouraged/being discouraged. Unfortunately I'm not aware of the "How-to" you mentioned, but I would dearly LOVE to be. The project I am working on is in a relatively early stage, and this would be the time to put things in extension libraries, templates and the like. Especially if there is no official line on when a formal fix might be available, the plans not being firm and all...
    But thanks for the reply none the less... I'd still appreciate any further information if anyone has some form of solution.
    Cheers

  • JSF Tab component and Dynamic Faces AjaxZone

    Has anyone tried to use a JSF Tab Component in a Dynamic Faces Ajax Zone. I would like to try to have a page that has a list of the alphabet, each tab being one letter and then adding terms an definitions to each tab. Do you have any comments or suggestions regarding doing this. I am at a loss as to how to make the tab component respond when clicking on it in the ajaxZone. any help would be appreciated. thnx

    The Scales and Tomahawk libraries provides a tabbed panel.
    But basically tabs are nothing less or more than a bunch of block elements layered over each other with the same amount of buttons or links at the top. If a tab click doesn't require a trip to the server, then you can just load all tab blocks at once and use Javascript+DOM to switch between tab blocks, e.g. one block should be displayed using element.style.display='block' and all other blocks should be hidden using element.style.display='none'. If a tab click require a trip to the server (to preinitialize stuff or so), then you can use the 'rendered' property of the tab block element (which can be <h:panelGroup style="display:block;" rendered="#{myBean.showTab == 1}" /> or so).
    For styling of the tab blocks and tab buttons/links just use CSS.

  • Menu Bar Component Positioning

    Hello,
    I'm looking for a way to position a Menu Bar swf (made from
    the menubar component) at the top of the web page, so it does not
    push the rest of the content down the page and end up with a bunch
    of white space. I believe it would be done with a style sheet.
    Anynone have any suggestions for such a style sheet?
    Thanks

    Hi Noel,
    Here is a link to what I am speaking of. It is just a test
    example.
    http://www.mallisoft.com/testbed/menu/menutest.html
    I would like to like the content to fit right under the menu.
    Thanks

  • Finding Component on Dynamically Created UI

    I am having a hard time regarding finding a particular component in my managed bean if your UI is dynamically created (say using an iterator..) especially
    if you need that component during PPR.
    As of the moment, I am doing this but its really ugly and is bound to be broken if I add another layout.
    public void handleChange(ValueChangeEvent valueChangeEvent) {
         UIComponent component = valueChangeEvent.getSource().getParent().getChildren().get(0).getChildren().getFacet("end").get(0).getChildren().get(1);
         AdfFacesContext context = AdfFacesContext.getCurrentInstance();
         context.addPartialTarget(component);
    }This code wont work also, since at runtime, I wouldnt know the id of the component.
    FacesContext facesCtx = FacesContext.getCurrentInstance(); 
    facesCtx.getViewRoot().findComponent(name) ; Been thinking about this for sometime now. Help needed.

    you can use this instead
    FacesContext.getCurrentInstance().getViewRoot().findComponent("<id>);
    or
    // used to locate region. Could also find any component
    // located in the base ViewRoot()
    public static UIComponent findComponentInRoot(String id) {
    UIComponent component = null;
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (facesContext != null) {
    UIComponent root = facesContext.getViewRoot();
    component = findComponent(root, id);
    return component;
    // Recursive method which finds your component within JSFF
    // regardless of facet or other UIComponents which may have children
    public static UIComponent findComponent(UIComponent base, String id) {
    if (id.equals(base.getId()))
    return base;
    UIComponent kid = null;
    UIComponent result = null;
    Iterator kids = base.getFacetsAndChildren();
    while (kids.hasNext() && (result == null)) {
    kid = (UIComponent) kids.next();
    if (id.equals(kid.getId())) {
    result = kid;
    break;
    result = findComponent(kid, id);
    if (result != null) {
    break;
    return result;
    }

  • Changing Screen field position dynamically

    Hi,
    Is there a way to change the position of screen fields dynamically in a module pool program?
    My requirement is that based on the value of a variable, I need to arrange a few input and text fields on a subscreen in different order.
    Points will be rewarded for helpful answers..
    Regards
    Abhishek

    Hi,
    For this what I can think of is that u need to create the fields multiple times on the same screen and then using SCREEN variables, u need to make them visible/invisible.
    e.g. Say, u want Matnr at first position at one time and 6th position at another. In that case, what u can do is create the field MATNR twice and them hide/unhide it depending upon the condition.
    Hope this helps.
    Regards,
    Himanshu

  • Swap Component in JPanel

    Hi there,
    I have a JPanel that holds several Components (ThumbnailPanel ... own Class for Displaying Thumbs and Infos of a Pic). I want to have a function to sort this Panel. That means I have Arrow Buttons and can shift a ThumbPanel one to the left or to the right. I try to show you here (its better to understand if you see this):
    http://www.rebelman.de/images/tpscreenshot.jpg
    the arrows to sort are the small buttons in the upper right corner.
    Logically the Components (ThumbnailPanels) are stored in a Vector and they are displayed in a JPanel with GridBagLayout. To shift a Component to the right, I have to swap it with its right neighbour. In the Vector its no problem
         public void sortToRight() {
              if(selIndex<currList.getImageCount()-2) {
                   //Vector swap
                   ImageData startImage     = currList.getImage(selIndex);
                   ImageData swappedImage     = currList.getImage(selIndex+1);
                   currList.setImage(selIndex, swappedImage);
                   currList.setImage(selIndex+1, startImage);
         }But I cant swap the Components in the JPanel where they are displayed. I can get the reference to the component (panelName.getComponent(index)) ... but I cant set the reference e.g. panelName.setComponent(index, Component).
    Any working idea? (I just think of swapping the constraint value of gridX ... but how? and does this work? The value for selIndex could point to the wrong component then and selection could run into trouble).
    - Frankie
    Edit: As mentioned in the last lines, I tried to swap the gridx Value:
    Component startComponent = thumbScrollPanel.getComponent(selIndex);
    Component swappedComponent = thumbScrollPanel.getComponent(selIndex+1);
    GridBagConstraints startConstraints = panelLayout.getConstraints(startComponent);
    GridBagConstraints swappedConstraints = panelLayout.getConstraints(swappedComponent);
    int startX = startConstraints.gridx;
    int swappedX = swappedConstraints.gridx;
    startConstraints.gridx = swappedX;
    swappedConstraints.gridx = startX;
    thumbScrollPanel.validate();This does not work. The order, both Components are displayed is not changing.
    Edited by: rebelman on Dec 13, 2007 1:14 AM

    Maybe use a GridLayout so you don't have to worry about constraints.
    Either way as mentioned above the key is to revalidate() the parent container after you add or remove a component from it. (Sometimes the repaint() is also necessary).

  • Load Component w/ Dynamic Parameters

    I am trying to use a pre-made third party component (that I
    have no source for) to read in and manipulate an XML file. I can
    get it into the component window and drag it onto the stage and it
    works fine. However, in order to dynamically change the location of
    the xml file (which is absolutely crucial), I need to take in this
    location as an argument to the overall swf and then push it to the
    component when its created.
    I tried to simply drag the component onto the stage and
    change the component's xml_file parameter in actionscript in the
    first frame, but that has no effect because the object has already
    been created and by then the xml from the default xml parameter is
    already read in. Since I have no control over the source code of
    the component, I can't delay this read in. Thus, I must set this
    parameter dynamically upon creation.
    So I was trying things like attachMovie and loadClassObject
    to push a parameter assignment in the fourth
    argument(xml_file:"blah"), but I cannot get this to work either.
    Anyone have a similar problem or know how to alleviate
    it?

    The default number of values is 1000. This default can be changed with a registry edit.
    I'm on CR XI R2
    HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 11.5\Crystal Reports\DatabaseOptions\LOV\MaxRowsetRecords
    I'm thinking v2008 should be:
    HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Crystal Reports\DatabaseOptions\LOV
    HTH,
    Jason

  • The right-mouse-click dropdown on links in FF4.00 has swapped the positions of 'open link in new tab' & 'open link in new window'. This is infuriating as I keep opening windows when I want tabs. I want to swap back - how?

    Please swap them back!

    2 Solutions found in [http://support.mozilla.com/en-US/questions/791244]
    the user cor-el has a method that does not require any add-ons. He States
    This code in userChrome.css will move "Open Link in New Window" to the top of the context menu.
    <pre>@namespace url("<a href="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul</a>"); /* only needed once */
    #contentAreaContextMenu &gt; * { -moz-box-ordinal-group: 2; }
    #context-openlink { -moz-box-ordinal-group: 1 !important; }</pre>
    the user jay_ff shows how to do it using the Menu Editor Add-on
    1. Install the Menu Editor add-on from https://addons.mozilla.org/en-US/firefox/addon/menu-editor/ .
    2. After the installation, go to Firefox> add-ons (or simply use Ctrl+Shift+A)
    3. Go to the Menu Editor "Options"
    4. In the "Main context menu," simply grab the "Open link in New Tab" and place it below the "Open Link in New Window"
    5. and Voila! You may also change other menu options if you want to!
    I tried jay_ff method first and found that indeed changing the Main Context Menu did cause the hotlink context menu to change as well.

Maybe you are looking for