Remove component from JPanel

Hi,
i've to remove a component from the center (BorderLayout.CENTER) of a JPanel without knowing the name of the component at runtime. I know only that the component is in the center position of the panel. How can i do?
Thanks
Luca

normally what i will do i removeall first and then i add the north or south component so you dont have to worry what is in your center of the panel

Similar Messages

  • Remove images from JPanel

    Hi,
    I have a JPanel called imagePanel and a JTree and every time a node is selected in the tree, a set of images are gonna be displayed on the imagePanel
    with the loop below. But the next time a node is selected the images that were added via the loop the first time, has to be removed. What code can I use to
    empty the imagePanel everytime, before the for-loop runs?
    //Some code here to empty the imagePanel so it begins from  scratch
      for(int index=0; index < imageNames.size(); index++)
    ImageIcon newImage = createImageIcon("images/" +
       (String)imageNames.elementAt(index));
    imagePanel.add(new JLabel(newImage));
    pictureLabel.setText(null);
    }

    Hi ,
    try this
    jlabel.setIcon( null ) ;

  • Remove component from JFrame with absolute layout

    I have a JFrame and JPanel inside the JFrame with absolute layout. I wanted to have a button when clicked the JPanel will be removed. I called jFrame.remove(jPanel);
    jFrame.repaint();
    jFrame.validate();
    I can't call jFrame.revalidate(), since JFrame doesn't provide revalidate() method. I try everything, but I can't get that JPanel removed. Could somebody help me please. Oh I tried jPanel.setBounds( 0,0,0,0); and the jPanel is disappeared, but I don't think this is the right solution. Is my problem with the absolute layout?
    Thanks

    public class MainGame
         public void game()
              GridBagLayout gridBagLayout = new GridBagLayout();
              GridBagConstraints constraints = new GridBagConstraints();
              final MainFrame mainFrame = new MainFrame();
              mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              mainFrame.setLayout( gridBagLayout );
              JPanel mainGamePanel = new JPanel();
              mainGamePanel.setLayout( new BorderLayout() );
              mainGamePanel.setBackground( Color.black );
              final Room mainEntrance = new Room( "at the main entrance of the deep forest" );
              mainEntrance.setBackground( Color.white );
              mainEntrance.setLayout( null );
              mainEntrance.setExit( Direction.UP, null );
              mainGamePanel.add( mainEntrance, BorderLayout.CENTER );
    //          c.fill = GridBagConstraints.CENTER;
              constraints.ipady = 800;      //make this component tall
              constraints.ipadx = 600;
              constraints.anchor = GridBagConstraints.WEST;
              constraints.gridx = 0;
              constraints.gridy = 0;
              gridBagLayout.setConstraints( mainGamePanel, constraints );
              mainFrame.getContentPane().add( mainGamePanel );
              thePlayer = new Human( "Cloud" , "The player" );
              thePlayer.setMaximumWeight( MAXIMUM_WEIGHT );
              thePlayer.setImage( Constants.CHARACTER_FRONT );
              thePlayer.setBounds(0 , 0, 40, 30 );
              thePlayer.setBorder( BorderFactory.createLineBorder( Color.black ) );
              mainEntrance.add( thePlayer );
              apple = new EdibleItem( "apple" , "Give more 10 HP" );
              apple.setHp( 100 );
              apple.setImage( Constants.APPLE );
              apple.setBounds( 40, 0, 40, 30 );
              apple.setBorder( BorderFactory.createLineBorder( Color.black ) );
              mainEntrance.add( apple );
              thePlayer.addItem( apple );
              apple1 = new JPanelWithBackground();
              apple1.setImage( Constants.APPLE );
              apple1.setBounds( 80, 60, 40, 30 );
              apple1.setBorder( BorderFactory.createLineBorder( Color.black ) );
              mainEntrance.add( apple1 );
    //          final Room forest = new Room( "at the main entrance of the deep forest" );
    //          forest.setBounds( 0, 0, 800, 600 );
    //          forest.setBackground( Color.white );
    //          forest.setLayout( null );
    //          forest.setExit( Direction.UP, null );
    //          // Add to list
              listOfItems.add( apple );
              listOfItems.add( apple1 );
               * Main Control Panel to control character and actions
              JPanel controlPanel = new JPanel();
              controlPanel.setBackground( Color.black );
              controlPanel.setBounds( 1000, 0, 600, 600 );
              controlPanel.setLayout( new GridLayout( 0, 1 ) );
              JButton eatButton = new JButton( "EAT" );
              // Set this button to setFocusable(false) to prevent this button being focused
              // So the focus will stay at JFrame
              eatButton.setFocusable( false );
              eatButton.addActionListener( new ActionListener()
                   @Override
                   public void actionPerformed(ActionEvent e)
                        JPanelWithBackground currentObject = mainGame.getFacingObject();
                        if( currentObject instanceof EdibleItem )
                             //EdibleItem apple = ( EdibleItem )currentObject;
              controlPanel.add( eatButton );
              JButton attackButton = new JButton( "ATTACK" );
              attackButton.setFocusable( false );
              attackButton.addActionListener( new ActionListener()
                   @Override
                   public void actionPerformed(ActionEvent e)
                        System.out.println( "Remove" );
                        mainFrame.getContentPane().remove( mainEntrance );
                        mainEntrance.setBounds( 0,0,0,0);
    //                    mainFrame.add( forest );
                        mainFrame.validate();
                        mainFrame.repaint();
              controlPanel.add( attackButton );
              mainFrame.setVisible( true );
              mainFrame.requestFocusInWindow();
    }I know that my code is a mess, because it is connected with many classes and the quality of the format is not very good. But I will refactor it later when I solved the problem.
    The problem is I have a JPanel with a character and an apple in it. I could not use any other layout, I have to use absolute layout, because I the user can control the character but arrow keys. And the character moves in pixels.
    Here what I wanted to do.
    final Room mainEntrance = new Room( "at the main entrance of the deep forest" );
              mainEntrance.setBackground( Color.white );
              mainEntrance.setLayout( null );
              mainEntrance.setExit( Direction.UP, null );Room extends JPanel, I wanted to delete this panel when I clicked this button
              JButton attackButton = new JButton( "ATTACK" );
              attackButton.setFocusable( false );
              attackButton.addActionListener( new ActionListener()
                   @Override
                   public void actionPerformed(ActionEvent e)
                        System.out.println( "Remove" );
                        mainFrame.getContentPane().remove( mainEntrance );
                        mainEntrance.setBounds( 0,0,0,0);
    //                    mainFrame.add( forest );
                        mainFrame.validate();
                        mainFrame.repaint();
              controlPanel.add( attackButton );Like I said before, I tried validate, repaint and setBounds to all 0s. Nothing happened with the Room class. How do I delete that Room.
    Thank you so much.

  • Get back component from JPanel

    by java
    I know JPanel can get back components by JPanel.getComponents() like
    private JPanel panelCenter = new JPanel ();
    panelCenter.getComponents();
    I want to know is JPanel able to get component just by the specified component's name?
    e.g. panelCenter.getComponent("buttom");
    or like vb.net Me.Controls("buttom").Visible = True
    Thanks
    Francis SZE

    None of JPanel, JComponent, Container or Component have a method to get a component by name.
    You can either:
    1. Keep references to the objects you place in your JPanel (highly recommended :)
    or
    2. Iterate over the result of getComponents() and test for getName().equals(requestedName)

  • Mass Removal of component from Maintenance Order Component list

    Hi Gurus,
    I had a long list of material which have been set with deletion flag. With this list, I had remove them from BOM using CS20. Does anyone knows how to remove a component from the maintenance order component list based on that material had set deletion flag in material master & that GI had not been done? Appreciate your help.
    Best regards,
    David Tan

    I guess we dont have std function to do this..
    I will suggest to take help of an abaper & create a code to find material & delete from orders.
    Regards

  • How to delete/remove the software component from integration repository

    Dear All
    How to delete/remove the software component from integration repository which we have created some Data and message types.
    Regards
    Blue

    Hi,
      Follow the steps below to delete the Software component:
    1. Delete the created Data Types, Message Types, Message Interfaces, Message Mappings, Interface Mappings and other imported objects like RFC's or IDoc's. Activate all changes.
    2. Then delete the namespace and the default datatypes present with the namespace after checking "objects are modifiable".
    3. Then delete the SW component, after placing the radio button in "Not permitted".
    Regds,
    Pinangshuk.

  • Hi I need Event for removal of component from UIEditor

    Hi, JDev team
    I need a event to identify removal of component from UIEditor.
    I have one method of doing this.Apply viewSelectionListener to the UIEditor but i can'nt use this approach for some reasons.Is there any other way out??

    I'm sorry, but Apple does not provide a downgrade path for iOS. Because downgrading is unsupported by Apple we cannot discuss it on these forums.
    You may leave comments at Apple Feedback.

  • Jpanel add/remove component redraw problem

    I have a JPanel using a GridLayout for a layout manager. The Jpanel has 2 components. When i remove one component ( using remove(Component comp) method) , and call updateUI on the JPanel, it removes the component but retains the original size. i.e It does not shrink to the size of the one component it has.
    How can the required effect be achieved?
    Thanks
    -sduhra

    I have a JPanel using a GridLayout for a layout manager.Well you have a structure like:
    parentPanel
        GridLayoutPanel
            component1
            component2Well it depends on the layout manager of the parent panel. If, for example the parentPane is using a BorderLayout, then the GridLayoutPanel will always be resized to the maximum space available and therefore the remaining component will also be resized.
    So you could use a FlowLayout in the parentPanel and it will respect the size of the GridLayoutPanel. So you resulting code would be something like:
    gridLayoutPanel.remove(...);
    parentPanel.revalidatge();

  • Removing Items from a TextArea/Pane Component

    Hi All,
    I have a question about text containers. Basically I'm reading Strings from a file and I'm displaying them inside a JTextArea. I'm adding new Strings to the JTextArea using it's append() method. Is there a way to limit how much stuff should the JTextArea hold ? After a while my application crashes with the following message:
    java.lang.OutOfMemoryError
         <<no stack trace available>>
    Exception in thread "main"
    This is because so much stuff got accumulated in the JTextArea that it eats up all available memory and the app crashes. My question is; is there a way I can remove items from the JTextArea ? Or is there a way to limit the size/number of Stings it can hold ? Or should I be using something else instead of the JTextArea ? Thanks in advance...
    -Pete

    int size = textArea.getDocument().getLength();
    gives the total number of bytes in the text area. You can then use:
    textArea.replaceRange("", 0, 80);
    to remove 80 characters from the start of the text area. Or to remove the first line from the text area use:
    int start = textArea.getLineStartOffset(0);
    int end = textArea.getLineEndOffset(0);
    textArea.replaceRange("", start, end);
    Design your own routine to keep the text area at a reasonable size.

  • JList run time errors when removing items from list

    Hi there
    I am having trouble removing items from a JList. For a While it was working fine and now it outputs runtime errors everytime samething gets removed from the lsit
    Here is the code
    //declare
    public class Consumertab1gui extends JPanel implements ActionListener
         public static JList conList = null;
         private static DefaultListModel model = null;
    // Create a list with some items
    model = new DefaultListModel();
    conList = new JList(model);
    //set the size of cells in the list with the length of the string
    conList.setPrototypeCellValue("Lenght 1234567890");
    conList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    conList.addListSelectionListener(new ValueReporter());
    //set a scroll onto the list
    JScrollPane conScroll = new JScrollPane(conList);
    add(conScroll,c);
    //when the button gets pressed to drop the selected item the following code is called
    private void dropConsumer()
    int selItem=0;
    componentsV.comVRemove(conList.getSelectedValue().toString());
    selItem=conList.getSelectedIndex();
    System.out.println("No:"+(model.getSize()-1));
    System.out.println("S:"+selItem);
    remConList(selItem);
    dropCon.setEnabled(false);
    //which in turns calls this
    public void remConList(int pos)
         model.remove(pos);
    when the model.remove(pos) code is executed the following runtime errors are given:
    java.lang.NullPointerException
    at Consumertab1gui$ValueReporter.valueChanged(Consumertab1gui.java:197)
    at javax.swing.JList.fireSelectionValueChanged(JList.java:1321)
    at javax.swing.JList$ListSelectionHandler.valueChanged(JList.java:1335)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:187)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:214)
    at javax.swing.DefaultListSelectionModel.removeIndexInterval(DefaultListSelectionModel.java:546)
    at javax.swing.plaf.basic.BasicListUI$ListDataHandler.intervalRemoved(BasicListUI.java:1561)
    at javax.swing.AbstractListModel.fireIntervalRemoved(AbstractListModel.java:160)
    at javax.swing.DefaultListModel.remove(DefaultListModel.java:478)
    at Consumertab1gui.remConList(Consumertab1gui.java:38)
    at Consumertab1gui.dropConsumer(Consumertab1gui.java:58)
    at Consumertab1gui.actionPerformed(Consumertab1gui.java:46)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
    at java.awt.Component.processMouseEvent(Component.java:5100)
    at java.awt.Component.processEvent(Component.java:4897)
    at java.awt.Container.processEvent(Container.java:1569)
    at java.awt.Component.dispatchEventImpl(Component.java:3615)
    at java.awt.Container.dispatchEventImpl(Container.java:1627)
    at java.awt.Component.dispatchEvent(Component.java:3477)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
    at java.awt.Container.dispatchEventImpl(Container.java:1613)
    at java.awt.Window.dispatchEventImpl(Window.java:1606)
    at java.awt.Component.dispatchEvent(Component.java:3477)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
    can anyone spot any mistakes in the code or suggest possible resons as to why these run time errors occur?
    Thanks
    alexis

    java.lang.NullPointerException
    at Consumertab1gui$ValueReporter.valueChanged(Consumertab1gui.java:197)The NullPointerException occurs at line 197, in the valueChanged method of your ValueReporter inner class. I have looked through your post several times but I don't see where you posted that method. Anyway, that is where you should look.
    PC&#178;

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

  • FM for deleting Component from Ibase Hierarchy

    Hi,
    Is there any FM for deleting Component from Ibase Hierarchy.
    I have tried using the FM "CRM_IBASE_COMP_DELETE", it is anyway deleting the component from the hierarchy but not those component
    whose is already assigned to a Contract.
    I have read these similar thread of only deleting a component but it was not very helpful in my scenario.
    In CRM, standard way of removing the component from Ibase Hierarchy is to "CUT" the component  and save. The mentioned component will not
    be seen in Ibase hierarchy.
    So is there any FM which can actually remove or cut the component from the hierarchy even though it is assigned to any contract etc.
    Awaiting for your expeditious help on this issue,
    Thanks and Regards,
    Jojy

    Hi Naresh,
    Thanks for your response,
    Is there any way of doing the same from Std. FM apart from doing it manually.
    Mine is Interface scenario in which the call will be instantaneous.
    I have tried to dismantle the component also, but it will be remain present in Ibase hierarchy even though it is associated to any contract or not with dismantle sign in it's hierarchy .
    I want to cut it so that it will not remain in Ibase hierarchy, it can be present in CRM system.

  • Add and remove columns from JTable

    Help me please!
    A try to remove column from JTable. It's removed, but when I try to add column in table, then I get all old (removed early) columns + new column....
    I completely confused with it.....
    Here is my code for remove column:
    class DelC implements ActionListener
              public void actionPerformed (ActionEvent e )
                   int [] HowManyColDelete = table.getSelectedColumns();
                   if (HowManyColDelete.length !=0)
                        TableColumnModel tableCModel = table.getColumnModel();
                        for (int i = HowManyColDelete.length-1; i>-1; i--)
                             table.getColumnModel().removeColumn (tableCModel.getColumn (HowManyColDelete [ i ]));
                   else
                          JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Column is not selected!");
         }

    It's little ex for me, I just try understand clearly how it's work (table models i mean). Here is code. All action with tables take place through menu items.
    My brain is boiled, I've try a lot of variants of code, but did't get right result :((
    It's code represent problem, which I've describe above. If you'll try remove column and then add it again, it will be ma-a-a-any colunms...
    I understand, that my code just hide columns, not delete from table model....
    But now I have not any decision of my problem...
    Thanks a lot for any help. :)
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.table.*;
    import java.awt.event.*;
    import javax.swing.table.DefaultTableModel;
    class JTableF extends JFrame
         Object [] [] data = new Object [0] [2];
         JTable table;
         DefaultTableModel model;
         String [] columnNames = {"1", "2"};
         TableColumnModel cm;
         JTableF()
              super("Table features");
              setDefaultLookAndFeelDecorated( true );
              setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
              JMenuBar MBar = new JMenuBar();
              JMenu [] menus =  {new JMenu("A"), new JMenu("B")};
              JMenuItem [] menu1 =  {new JMenuItem("Add row"), new JMenuItem("Delete row", 'D'),  new JMenuItem("Add column"), new JMenuItem("Delete column")};
              menu1 [ 0 ].addActionListener(new AddL());
              menu1 [ 1 ].addActionListener(new DelL());
              menu1 [ 2 ].addActionListener(new AddC());
              menu1 [ 3 ].addActionListener(new DelC());
              for (int i=0; i<menu1.length; i++)
                   menus [ 0 ].add( menu1 [ i ]);
              for (int i=0; i<menus.length; i++)
                   MBar.add(menus );
              JPanel panel = new JPanel ();
              model = new DefaultTableModel( data, columnNames );
              table = new JTable (model);
              cm = table.getColumnModel();
              panel.add (new JScrollPane(table));
              JButton b = new JButton ("Add row button");
              b.addActionListener(new AddL());
              panel.add (b);
              setJMenuBar (MBar);
              getContentPane().add(panel);
              pack();
              setLocationRelativeTo (null);
              setVisible (true);
         class DelC implements ActionListener
              public void actionPerformed (ActionEvent e )
                   int [] HowManyColDelete = table.getSelectedColumns();
                   if (HowManyColDelete.length !=0)
                        TableColumnModel tableCModel = table.getColumnModel();
                        for (int i = HowManyColDelete.length-1; i>-1; i--)
                             int vizibleCol = table.convertColumnIndexToView(HowManyColDelete [ i ]);
                             tableCModel.removeColumn (tableCModel.getColumn (vizibleCol));
                        //cm = tableCModel;
                   else
                        JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Column is not selected!");
         class AddC implements ActionListener
              public void actionPerformed (ActionEvent e)
                   //table.setColumnModel(cm);
                   Object NewColumnName = new String();
                   NewColumnName = JOptionPane.showInputDialog ("Input new column name", "Here");
                   int i = model.getRowCount();
                   int j = model.getColumnCount();
                   Object [] newData = new Object [ i ];
                   model.addColumn ( NewColumnName, newData);
         class AddL implements ActionListener
              public void actionPerformed (ActionEvent e)
                   int i = model.getColumnCount();
                   Object [] Row = new Object [ i ];
                   model.addRow ( Row );
         class DelL implements ActionListener
              public void actionPerformed (ActionEvent e)
                   int [] HowManyRowsDelete = table.getSelectedRows();
                   if (HowManyRowsDelete.length !=0)
                        for (int k = HowManyRowsDelete.length-1; k>-1; k--)
                             model.removeRow (HowManyRowsDelete[k]);
                   else
                        JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Row is not selected!");
         public static void main (String [] args)
              javax.swing.SwingUtilities.invokeLater(new Runnable()
                   public void run()
                        JTableF inst = new JTableF();

  • Problem removing components from JLayeredPane

    Hi all,
    I have a problem showing and hiding components on a JLayeredPane. It goes Something like this:
    In my application I have a button. When this button is pressed I use getLayeredPane to get the frames layered pane. I then add a JPanel containing a number of labels and buttons onto that layered pane on the Popup layer. The panel displays and funcitons correctly.
    The problem comes when I try to remove the panel from the layered pane. The panel does not dissappear and I am no longer able to click on anything else in the frame!
    If anyone has any ideas how to get around this or what the problem might be I'd be very greatful to hear it. Sample code follows:
          * Called when the button on the frame is pressed:
          * @param e
         public void actionPerformed(ActionEvent e)
                    JLayeredPane mLayredPane = getLayeredPane();
              int x = 0, y = 0;
              Container c = this;
              while (true)
                   c = c.getParent();
                   if (c != null)
                        x += c.getLocation().x;
                        y += c.getLocation().y;
                        if (c instanceof JRootPane)
                             break;
                   else
                        break;
              mPanel.setBounds(x, y, 235, 200);
              mLayredPane.add(mPanel, JLayeredPane.POPUP_LAYER);
    //And when a listener fires from the panel I use
    mLayredPane.remove(mPanel);
    //To remove it from the layered pane and in theory return the
    //app to the state it was before the panel was displayedThanks again...

    The problem is you only removed it within the program, without actually removing it from the display. If that makes any sense, or whether thats your problem at all.
    If you are only using this line.
    mLayredPane.remove(mPanel);
    I think if you tell it to repaint and revalidate it should work, though i have never used LayeredPane.
    mLayredPane.repaint();
    mLayredPane.revalidate();

  • [Flex 4.5.1] How to remove focus from TextInput on mouse click outside of it?

    For me clicking outside of a TextInput should always remove focus from it, only only if you click on another TextInput or Button.
    I don't see any simple event like MouseEvent.MOUSE_CLICK_OUTSIDE - which would definitely simplify things.. I wonder why there isn't such event. Well anyway I can't find any other similar event and I can't figure out an easy way to do this. I also wonder why I couldn't find a solution to this on the web easily... Well anyway...
    Does someone know how to do that in a convenient way?
    Thanks!

    ok I understand why is that. For example I have a TextInput now where the user enters number through buttons which have mouseFocusEnabled = false, so the TextInput doesn't lose focus. But on a TabBar I had to set mouseFocusEnabled = true or when I switched between tabs -> switches between states, I could still type in the TextInput in the previous tab cause it didn't lose focus. Maybe TabBar's default value of that property is wrongly set to false.
    Anyway, not losing focus when clicking outside is still weird. Take for example this forum, if I click outside of the box I am currently writing this, I lose focus. It's how things usually work. And flex focus is designed to work backwards to what people are used to, no matter as I already pointed out I understand there are cases it comes in handly. I hope I don't sound bad but take it just as a suggestion please that maybe if it is redesigned like this: clicking on component gets focus, clicking outside loses focus. But if you click on a button for example and you want to keep the focus on a TextInput cause you add some text, you should be able to set a property on the Button like maintainCurrentFocus = true (false by default), which would make clicking on the Button not shift the focus to it or set it to null if the component is a group that has some rect background for example, but maintain the focus on the TextInput.
    I could be missing something about the current design of how the focus works in flex, but from my point of view at the moment, the design I describe to use is just like how I am usually used to be working with focus as a user, not as developer.
    Maybe you could agree or maybe you know some reason by which things are how they are at the moment that I don't see. But if you think I make sense please let me know, maybe I could fill a minor enhancement request for that ?

Maybe you are looking for

  • Keyboard viewer causing lock ups

    Keyboard viewer is causing me some headaches. I have a handicapped user who can better use a mouse than a keyboard, and needs to use keyboard viewer. However, after enabling keyboard viewer, if they user logs out of the computer, and logs in again la

  • G5 CRASHES ON START UP

    My G5 1.8 dual has started crashing on start-up. I switch it on and it eventually powers up and I get my personalised desktop but as soon as I try to do anything I ge the spinning beach ball and cannot do anything but force it to close. I have tried

  • Rokr: "Some files and applications are not accessible"

    Help please? When using USB to connect to my ibook the phone gives me this message: "Coneced as Storage Device: Some file and applications are not accessible". I then go to my desktop and search through my phone to find no files not to mention not sh

  • RFX Not reached Approver Inbox for Approval

    Hi Friends, We are experiencing a very strange cases. In RFX approval process RFX has not reached Approver. When I check in Workflow through tcode SWI1 I dont see any agent assigned to it. Functional consultant says that he has already set the ROLE r

  • Topsite edit button gone.

    Hi, On my topste page the background has gone, so as the edit button in the bottom left corner. If I remember correctly my topste page had a background and they was an edit button so I could press the tab, edit then press the tab again. now I only ha