Flex 4 - center popup

How can I center popup window in flex 4 ?
I have tried:
PopUpManager.addPopUp(AlertPopUp,DisplayObject(spark.components.Application), true);
PopUpManager.centerPopUp(AlertPopUp);
but it's problem with conversion Application->DisplayObject.
Please help

try this:
PopUpManager.addPopUp(AlertPopUp,spark.components.Application as DisplayObject, true);
PopUpManager.centerPopUp(AlertPopUp);

Similar Messages

  • PopUp Manager and Flex Forum PopUps

    I wanted make sure I understood what someone on the Forum told me about the PopUpManager and TitleWindow.
    My question was:  "How are the PopUps that appear when you hover over a person's image/profile on the left side of this Adobe Forum's page done?  Did you use Flex for this, or are they some type of Ajax thing?  If Flex was used was it done with the PopUp Manager based on the TitleWindow.  This is exactly the kind of PopUp I need, especially because it has a larger hit area than most PopUps which dissapear when the mouse exits the button or textarea acting as a button.
    Thanks and Sorry for the long version.
    Doug

    Hi,
    Same  thing is simple to acheive in flex.You can try the code below.Let me know if you have any issue with this.
    MainApplication.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
         verticalAlign="middle">
        <mx:Script>
            <![CDATA[
                import mx.managers.PopUpManager;
                private var bool : Boolean;
                private var myPopUp:MyPopup;
                private function onMouseOver():void
                    if(bool == false)
                        if(myPopUp != null)
                            PopUpManager.removePopUp(myPopUp);
                            myPopUp = null;
                        myPopUp = MyPopup(PopUpManager.createPopUp(this, MyPopup, false));
                        myPopUp.move(700,400);
                        var infoObject : Object = new Object();
                        infoObject.imagePath = 'assets/img1.png';
                        infoObject.name = "David";
                        infoObject.country = "United Kingdom";
                        infoObject.profession = "Software Developer"
                        infoObject.domain = "Banking";
                        myPopUp.info = infoObject;
                        bool = true;   
                private function onMouseOut():void
                    bool = false;
                    if(myPopUp != null)
                        PopUpManager.removePopUp(myPopUp);
            ]]>
        </mx:Script>
        <mx:Image source="assets/img1.png" mouseOver="onMouseOver()" mouseOut="onMouseOut()"/>
    </mx:Application>
    MyPopup.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" width="250" height="300"
        title="Author Information">
    <mx:Script>
        <![CDATA[
            private var _info:Object;
            public function get info():Object
                return _info;
            public function set info(value:Object):void
                _info = value;
                if(value != null)
                    imgImage.source = info.imagePath;
                    nameLbl.text = info.name;
                    countryLbl.text = info.country;
                    professionLbl.text = info.profession;
                    domainLbl.text = info.domain;
        ]]>
    </mx:Script>
        <mx:VBox width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
            <mx:Image id="imgImage" buttonMode="true" useHandCursor="true"/>
            <mx:Label id="nameLbl"/>
            <mx:Label id="countryLbl"/>
            <mx:Label id="professionLbl"/>
            <mx:Label id="domainLbl"/>
        </mx:VBox>
    </mx:TitleWindow>
    with Regards,
    Shardul Singh Bartwal

  • Help with Flex based popup windows and data population.

    Hello, I need a bit of help with Flex popups. I have a flex
    application that uses a popup window when you click on a button and
    displays information about the image above the button the user
    clicked. I have about 4 images and I need to be able to display
    information about each of them through the popup window when users
    click on the buttons below the image.
    At this time, I am trying to do this from somewhat of a
    "static" point of view because I do not believe my hosting company
    supports Flex Data services. You will find my code below.
    First File.
    <?xml version="1.0" encoding="utf-8"?>
    <!--Application Initialization -->
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" width="850" height="750"
    cornerRadius="10" borderColor="#000000"
    backgroundGradientColors="[#1b3434, #000000]">
    <!-- Popup-->
    <mx:Script>
    <![CDATA[
    import mx.managers.PopUpManager;
    [Bindable]
    private var win:IMSAI;
    private function init():void{}
    private function createPopup():void{
    win=IMSAI(PopUpManager.createPopUp(this,IMSAI,true));
    win.title = 'IMSAI.Net';
    win.x = -500;
    win.y = 0;
    customMove.end();
    customMove.play();
    ]]>
    </mx:Script>
    <mx:Style>
    TitleWindow {
    borderStyle:solid;
    borderThickness:2;
    </mx:Style>
    <mx:Parallel id="customMove" target="{win}">
    <mx:Move duration="2000" xTo="{(stage.width - win.width)
    / 2}" yTo="{(stage.height - win.height) / 2}" />
    <mx:WipeDown duration="2000" />
    </mx:Parallel>
    This is the code to trigger the popup when a user clicks on
    the button. The code below is the code for the popup.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:TitleWindow xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical" creationComplete="init()"
    close="PopUpManager.removePopUp(this)"
    showCloseButton="true" alpha=".8"
    headerColors="[#000000,#1F3F62]" color="#FFFFFF"
    minHeight="200" minWidth="300"
    backgroundColor="#000000" title="IMSAI.net" width="520"
    height="394" verticalAlign="middle" horizontalAlign="center">
    <mx:Script>
    <![CDATA[
    import mx.managers.PopUpManager;
    private function init():void{}
    ]]>
    </mx:Script>
    <mx:Canvas width="470" height="338">
    <mx:Image x="10" y="10" width="140" height="103">
    <mx:source>file:///C|/ColdFusion8/wwwroot/IMSAI/Web-App/Site_Images/IMSAI
    Final Movie.swf</mx:source>
    </mx:Image>
    <mx:Text x="10" y="121" text="Description:" width="75"
    height="25" fontWeight="bold" color="#ff0000"/>
    <mx:Text x="158" y="10" text="Client:" width="52"
    height="28" fontWeight="bold" color="#ff0000"/>
    <mx:Text x="196" y="10" text="IMSAI Microcomputers
    &amp; Fischer-Freitas Company" width="252" height="39"/>
    <mx:Text x="159" y="46" text="Industry:"
    fontWeight="bold" color="#ff0000"/>
    <mx:Text x="216" y="46" text="Computer &amp;
    Microcontroller Manufacturing." width="232" height="35"/>
    <mx:Text x="83" y="121" text="IMSAI.net is the front-end
    web application for IMSAI Computer " width="355"/>
    <mx:Text x="10" y="136" text="manufacturing, customer
    support, and order processing. Driven by a Microsoft database
    back-end, this application includes rich flash forms, site search
    capabilities, and flash content. Currently under phase II of a
    three phase development plan, the e-commerce logic and processing
    capabilities are under development. Once finished, this application
    will be able to process orders provide customers with instant order
    confirmation numbers, shipment dates, and payment processing."
    width="428"/>
    <mx:Text x="10" y="244" text="Technologies:"
    fontWeight="bold" color="#ff0000"/>
    <mx:Image x="100" y="244" width="50" height="50">
    <mx:source>file:///C|/ColdFusion8/wwwroot/Sapphire
    Development/content/cf8icon.jpg</mx:source>
    </mx:Image>
    <mx:Image x="244" y="244" width="50" height="50">
    <mx:source>file:///C|/ColdFusion8/wwwroot/Sapphire
    Development/content/flashlogo.jpg</mx:source>
    </mx:Image>
    <mx:Text x="53" y="290" text="Coldfusion 8 Enterprise"
    height="30"/>
    <mx:Text x="230" y="290" text="Adobe Flash 8"/>
    </mx:Canvas>
    What I want to do is either be able to create a popup file
    for each button and photo, or find a way to pass a name like a
    button ID that corresponds to a XML data structure and then
    provides the appropriate data for the photo. I have tried altering
    the first page of code with the "public" declaration to allow for a
    second popup file for each button and image, but the IDE won't
    allow me to do such because it creates errors stating I can only
    have one public declaration of the kind and function above per
    application. Help resolving this would be greatly appreciated.
    Thank you.

    I have an idea of what I want to do. I am just having
    difficulty articulating how to go about such. I know I want to find
    a way so that if a user clicks on button 1, button 1 will send some
    kind of variable. For example, a user clicks Btn1 under a picture.
    Btn1 sends some kind of variable or binding to a data structure
    which returns the picture's description, price, etc. and calls the
    popup to display that data in a form like manner. Then the user
    click Btn2 which does the same thing. The only purpose of the popup
    is to display the data.
    Do I create a data structure with a related name to say a
    button name so when the btn is clicked, the a variable title btn1
    will prepend itself to the data structure like
    {btn1.imagename}
    {btn1.price}
    {btn1.description}.
    I want each btn to call a different set of data about each
    picture because right now, the code I have is allowing me multiple
    buttons, but is just displays the popup. Is there a way to create a
    separate popup window for each button? Thats seems as though it
    would be easier. Thank you for your help.

  • Flex 3 Popup resize

    Hello Everyone ,
      I have a flex app that uses a popup.  When I first add the popup to the stage , it is missized , has scrollbars and is offcenter.  Then a split second later it resizes , centering the content and removing the scrollbars.  Is there anyway to avoid this abrupt behavior ?
    Sincerely ,
         Ubuntu

    That would make sense !  I reused a component  from another part of the application.  I
    may have to "hard size" it.

  • [Integration] Web Dynpro ABAP calling Flex in Popup (without Flash Islands)

    Hi,
    We do not intend to install Enhancement Package 1 in a near future.
    Nevertheless, we do have requirements where Flex should be integrated with Web Dynpro ABAP (Flex components embedded or 'attached' to Web Dynpro ABAP applications).
    I would like to open a popup showing a Flex component. Then, the user validates and the Web DYnpro ABAP application is resumed. All this integrated within EP 7.0.
    What, according to you, would be the most effective combination : 
    - Suspend / Resume plug
    - Server-side cookies
    - iFrame (although it is deprecated)
    Given what I have read so far, it seems encapsulating the .swf within a BSP application would be the best shot. Could it be possible to get rid of this 'additional layer' ?
    Thanks in advance.
    Best regards,
    Guillaume

    Web Dynpro ABAP
    Define a suspend and a resume plug.
    BSP
    Retrieve the parameters sent by WDA either by AUTO attributes or the following code
    CONSTANTS: c_resume_name          TYPE string  VALUE `sap-wd-resumeurl`.
    DATA: lt_tihttpnvp                TYPE tihttpnvp.
    FIELD-SYMBOLS: <fs_httpnvp>       LIKE LINE OF lt_tihttpnvp,
                   <fs_dept_magasin>  LIKE LINE OF t_dept_magasins.
    ** Lecture des paramètres envoyés (par le WD ABAP)
    CALL METHOD request->get_form_fields
      CHANGING
        fields = lt_tihttpnvp.
    READ TABLE lt_tihttpnvp ASSIGNING <fs_httpnvp> WITH KEY name = c_resume_name.
    IF sy-subrc = 0.
      e_url = <fs_httpnvp>-value.
    ENDIF.
    Flex
    To return to the Web DYnpro ABAP, call a Javascript function within the BSP using this kind of code :
    jsReturn = ExternalInterface.call("sendBackToSAP", selectedDepartmentsParam, orderParam);
    BSP
    First, to react to the user action in the Flex component, define a Javascript function in the
          function sendBackToSAP(departements, ordre) {
             fireServerEvent(departements, ordre);
             return("Done");
    To fire a server-event (in order for BSP to call the WDA resume plug), I use this declaration :
    <!--  Event used by the Javascript to trigger OnInputProcessing so as to create
                  the server-side cookie -->
           <bsp:htmlbEvent name= "fireServerEvent"
                           id  = "flexAction"
                           p1  = "departements"
                           p2  = "ordre"></bsp:htmlbEvent>
    Last, I simply call the URL that the WDA gives me first :
    navigation->goto_page( e_url ).
    If people are interested in a more detailed presentation, feel free to reply to this post, and I will write a blog about this. Nevertheless, it should become pretty obsolete with the Flash Islands release... 
    Edited by: Guillaume Garcia on Oct 11, 2008 11:13 AM

  • How do I stop constant Game Center popups?

    IPad 3, iOS 6. I am not interested in gaming community. I want to delete Game Center and stop all notifications. How can I remove my ID from GC? I logged out but that doesn't help. I turned off notifications, but that didn't help.

    YAHOO! - so to speak. That was it. The pref pane in Guest looked normal. So I went back (in full boot) and deleted any pref file I could find for AddressBook. Now I look normal . . .
    . . . and **** if that Sync w/ Yahoo! WAS CHECKED. I un-checked it.
    While I was searching for stuff to delete, I also found this weird pref file 'com.apple.yahoo.synctool.plist' . . .
    Can't find anything called a SYNCTOOL. Hopefully this will end the annoyance. Thank you very much for your insights and aid.

  • Group Policy item for Security Center

    What's the easiest way to do this?
    I want to disable the security center popup.Windows XP Pro SP2, zen 3.2sp2
    Roaming profiles (for students, a single volatile profile is in use).
    I've attempted a few things to get this screen from showing up. I run
    fortres, but the security center screen comes up before fortres has
    initialized on the machine. I've tried wiping out the wscntfy.exe, but it's
    self-repairing.
    I tried to build an adm to add to the user extensible policies in the
    package, but it's either being ignored or I've got the wrong key
    (HKCU\Software\Microsoft\Security Center\FirstRun=dword:00000001).
    I noticed that if I turn off the notification on the workstation, it appears
    to be in the LM hive and sticks around for subsequent users. But the next
    user to use the machine has the thing pop up everytime (because the
    notification that they have seen the screen once disappears when their
    profile is wiped out).
    I guessed that this is the time that I would truly have to switch over to
    Windows Group Policies rather than relying on the unsupported user
    extensible policies (which have been working fine for me for quite some
    time).
    But when I tried to get the security center in the group policy editor
    (launched from console 1), it isn't there at all. How do I add the proper
    snapin to this editor so that I can apply security center settings?
    Chris Denby
    IT Coordinator
    Rainy River District School Board
    Fort Frances, Ontario
    Canada

    Chris,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Do a search of our knowledgebase at http://support.novell.com/search/kb_index.jsp
    - Check all of the other support tools and options available at
    http://support.novell.com.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://support.novell.com/forums)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://support.novell.com/forums/faq_general.html
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://support.novell.com/forums/

  • Managing Popup Visibility

    Hi all, my question is this:
    How can I make a popup that behaves like a JPopupMenu or JComboMenu, specifically it's criteria for Hiding.
    To clarify, When the popup is visible if the moused is pressed anywhere on the screen other than over the popup it should hide.
    I've spent 2 weeks on this one thing and I am no closer to an answer, it seems there's not really any resources on this available.

    excuse me,JWindow does't handle DeActiveEvent ;
    There's my code , I'll make it like jdesktop's auto complet component or code assistant but ...
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Window;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import javax.swing.JPopupMenu;
    import javax.swing.JTextField;
    import javax.swing.JWindow;
    import javax.swing.Popup;
    import javax.swing.PopupFactory;
    import tlw.example.Shower;
    Author:ÌÆÁ¦Î°
    E-Mail:[email protected]
    Date:2008-10-23
    Description:
    public class JTextFieldKindsOfPopup extends JPanel{
         private static final long serialVersionUID = 1L;
         public static void main(String[] args) {
              JTextFieldKindsOfPopup wp=new JTextFieldKindsOfPopup();
              Shower.show(wp);
         JTextField jtfWindowPopuup=new JTextField("Edit for Popup JWindow",20);
         JTextField jtfMenuPopup=new JTextField("Edit for Popup JPopupMenu",20);
         JTextField jtfPopup=new JTextField("Edit for PopupFactory Popup",20);
         Window popupWindow=new JWindow();
         JPopupMenu popupMenu=new JPopupMenu();
         Popup popup;
         JPanel popupPane=new JPanel();
         public JTextFieldKindsOfPopup(){
              add(jtfWindowPopuup,"North");
              add(jtfMenuPopup,"South");
              add(jtfPopup,"Center");
              //popup window
              popupWindow.setPreferredSize(new Dimension(300,300));
              popupWindow.setBackground(Color.red);
              popupWindow.setBounds(20, 20, 100, 100);
              popupWindow.setAlwaysOnTop(true);
              popupWindow.addWindowListener(new WindowListener());
              jtfWindowPopuup.addKeyListener(new KeyAdapter(){
                   public void keyPressed(KeyEvent e){
                        popupWindow.setVisible(true);
              //popup menu
              JMenuItem menuItem1=new JMenuItem("Item1");
              JMenuItem menuItem2=new JMenuItem("Item2");
              JMenuItem menuItem3=new JMenuItem("Item3");
              popupMenu.add(menuItem1);
              popupMenu.add(menuItem2);
              popupMenu.add(menuItem3);
              jtfMenuPopup.addKeyListener(new KeyAdapter(){
                   public void keyPressed(KeyEvent e){
                        popupMenu.show(jtfMenuPopup, 0, jtfMenuPopup.getHeight());
                        jtfMenuPopup.requestFocus();
              //popup factory
              popupPane.setBackground(Color.blue);
              popupPane.setPreferredSize(new Dimension(100,100));
              jtfPopup.addKeyListener(new KeyAdapter(){
                   public void keyPressed(KeyEvent e){
                        popup=PopupFactory.getSharedInstance().getPopup(JTextFieldKindsOfPopup.this, popupPane, 100, 100);
                        popup.show();
                        //where can i execute popup.hide()?
         class WindowListener extends WindowAdapter{
              @Override
              public void windowDeactivated(WindowEvent e) {
                   popupWindow.setVisible(false);
    }Edited by: tlw_ray on Oct 23, 2008 1:00 AM
    Edited by: tlw_ray on Oct 23, 2008 10:28 PM

  • About popup hide

    Question F
    1.How dose JPopupMenu or JMenuItem hiden ,when click any where .
    2.How dose JComboBox's dropdown hidden ,when click any where.
    3.Question1,2 is one answer?
    I tried to read JComponent ,Popup ,PopupFactory ,JPopupMenu,JCombox and others source code,but in few day I can't find the way .Please help me and give directions B
    JTextField editing ,dropdown a JPopupMenu contain maybe input words,but focus lost,can't still edit JTextField;
    Edited by: tlw_ray on Oct 22, 2008 11:40 PM

    Thans for you camickr .
    My question is I dosen't know the theory , how swing manage popup item hiden;
    I want a JTextField ,when I input word,it can drop down a popup assistant help me auto complete.
    First I use PopupFactory to implement the function,but finally I notice that I can't hide the popup in an evnent.
    Then I think maybe use somethin like menu can implement the function.So I use JPopupMenu ,but when it popup,the JTextField's focuse lose,I can't input still.then when JPopupMenu shown I set jTextField to requestFocuse().That's all .My problem resolved.But I still dose't know how the JPopupMenu hiden ,when click any where but the menu.And I tried use JWindow ,but it dosen't catch the deActive window event.
    I hope can understand how swing manager popup show or hiden,maybe intro some article or indicate some code block can help me .I like java for he tell me what he do when a program running,
    Utility Class:
    import java.awt.Component;
    import javax.swing.JFrame;
    Author:&#21776;&#21147;&#20255;
    E-Mail:[email protected]
    Date:2008-10-22
    Description:
    public class Shower {
         public static void show(Component comp,int width,int height){
              JFrame f=new JFrame();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.setSize(width, height);
              f.setLocationRelativeTo(null);
              f.add(comp,"Center");
              f.setVisible(true);
         public static void show(Component comp){
              show(comp,400,300);
    }Here is my exmaple code:
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Window;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import javax.swing.JPopupMenu;
    import javax.swing.JTextField;
    import javax.swing.JWindow;
    import javax.swing.Popup;
    import javax.swing.PopupFactory;
    import tlw.example.Shower;
    Author:tlw_ray
    E-Mail:[email protected]
    Date:2008-10-23
    Description:input assistant
    public class JTextFieldKindsOfPopup extends JPanel{
         private static final long serialVersionUID = 1L;
         public static void main(String[] args) {
              JTextFieldKindsOfPopup wp=new JTextFieldKindsOfPopup();
              Shower.show(wp);
         JTextField jtfWindowPopuup=new JTextField("Edit for Popup JWindow",20);
         JTextField jtfMenuPopup=new JTextField("Edit for Popup JPopupMenu",20);
         JTextField jtfPopup=new JTextField("Edit for PopupFactory Popup",20);
         Window popupWindow=new JWindow();
         JPopupMenu popupMenu=new JPopupMenu();
         Popup popup;
         JPanel popupPane=new JPanel();
         public JTextFieldKindsOfPopup(){
              add(jtfWindowPopuup,"North");
              add(jtfMenuPopup,"South");
              add(jtfPopup,"Center");
              //popup window
              popupWindow.setPreferredSize(new Dimension(300,300));
              popupWindow.setBackground(Color.red);
              popupWindow.setBounds(20, 20, 100, 100);
              popupWindow.setAlwaysOnTop(true);
              popupWindow.addWindowListener(new WindowListener());
              jtfWindowPopuup.addKeyListener(new KeyAdapter(){
                   public void keyPressed(KeyEvent e){
                        popupWindow.setVisible(true);
                        //JWindow dosen't catch windowDeactivated event;
              //popup menu
              JMenuItem menuItem1=new JMenuItem("Item1");
              JMenuItem menuItem2=new JMenuItem("Item2");
              JMenuItem menuItem3=new JMenuItem("Item3");
              popupMenu.add(menuItem1);
              popupMenu.add(menuItem2);
              popupMenu.add(menuItem3);
              jtfMenuPopup.addKeyListener(new KeyAdapter(){
                   public void keyPressed(KeyEvent e){
                        popupMenu.show(jtfMenuPopup, 0, jtfMenuPopup.getHeight());
                        jtfMenuPopup.requestFocus();
                        //this way can resolve,input assistant
              //popup factory
              popupPane.setBackground(Color.blue);
              popupPane.setPreferredSize(new Dimension(100,100));
              jtfPopup.addKeyListener(new KeyAdapter(){
                   public void keyPressed(KeyEvent e){
                        popup=PopupFactory.getSharedInstance().getPopup(JTextFieldKindsOfPopup.this, popupPane, 100, 100);
                        popup.show();
                        //what event can i set the popup hide()?
                        //maybe popupFactory dosen't use for this ,it just use to Tooltip.
         class WindowListener extends WindowAdapter{
              @Override
              public void windowDeactivated(WindowEvent e) {
                   popupWindow.setVisible(false);
    }Here is my function code
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.FontMetrics;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ComponentAdapter;
    import java.awt.event.ComponentEvent;
    import java.awt.event.ComponentListener;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseMotionAdapter;
    import java.text.Collator;
    import java.util.Comparator;
    import java.util.List;
    import java.util.Locale;
    import java.util.Vector;
    import javax.swing.JCheckBox;
    import javax.swing.JList;
    import javax.swing.JPanel;
    import javax.swing.JPopupMenu;
    import javax.swing.JScrollPane;
    import javax.swing.JSpinner;
    import javax.swing.JTextField;
    import javax.swing.SpinnerNumberModel;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    import javax.swing.event.DocumentEvent;
    import javax.swing.event.DocumentListener;
    Author:tlw
    E-Mail:[email protected]
    Date:2008-10-23
    Description:
    public class MSearch1 extends JPanel {
         private static final long serialVersionUID = 1L;
         public static void main(String[] args) {
              final MSearch1 ms=new MSearch1();
              ms.setItems(new String[]{"aaa","aab","aac","W3.UNIT1.E0003","W3.UNIT1.E0004","W3.UNIT1.E0005"});
              final JCheckBox jckDropDownMode=new JCheckBox("isDropDownMode");
              jckDropDownMode.setSelected(ms.getIsDropDown());
              jckDropDownMode.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e){
                        ms.setIsDropDownModel(jckDropDownMode.isSelected());
              final JCheckBox jckFilterMode=new JCheckBox("isFilterMode");
              jckFilterMode.setSelected(ms.getIsFilterMode());
              jckFilterMode.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e){
                        ms.setIsFilter(jckFilterMode.isSelected());
              final SpinnerNumberModel jspinModel=new SpinnerNumberModel(8,3,15,1);
              final JSpinner jspinnerRows=new JSpinner(jspinModel);
              jspinnerRows.setToolTipText("drop down item count.");
              jspinnerRows.addChangeListener(new ChangeListener(){
                   public void stateChanged(ChangeEvent e) {
                        int rowCount=jspinModel.getNumber().intValue();
                        ms.setRows(rowCount);
              JPanel paneLeft=new JPanel();
              paneLeft.setLayout(new GridLayout(3,1));
              paneLeft.add(jckDropDownMode);
              paneLeft.add(jckFilterMode);
              paneLeft.add(jspinnerRows);
              JPanel pane=new JPanel();
              pane.setLayout(new BorderLayout());
              pane.add(ms,"Center");
              pane.add(paneLeft,"West");
              Shower.show(pane);
         /*---------user interface element-----------*/
         private JTextField jtfInput=new JTextField();
         private JList jlistReservior=new JList();
         private JScrollPane jscroll4List=new JScrollPane(jlistReservior);
         private JPopupMenu jpopup4List=new JPopupMenu();
         /*---------self property--------------*/
         private boolean isDropDownMode=true;
         private boolean isFilterMode=true;
         private int rows=8;
         private String[] items;
         /*---------constructor--------------*/
         public MSearch1(){
              initUI();
              initEvent();
         private void initUI(){
              jtfInput.setColumns(20);
              //Dimension listSize=new Dimension(20*16,rows*25);
              //jscroll4List.setPreferredSize(listSize);
              setLayout(new BorderLayout());
              add(jtfInput,"North");
              dropModelRefresh();
         private void initEvent(){
              jtfInput.getDocument().addDocumentListener(inputChange);
              jtfInput.addKeyListener(inputKeyListener);
              jtfInput.addComponentListener(resizeListener);
              jlistReservior.addMouseMotionListener(mouseOverShow);
              jlistReservior.addMouseListener(clickSelect);
         //filter items who start with user input;
         private void doFilter(){
              String txt=jtfInput.getText().toLowerCase();
              if(isFilterMode){
                   if(items==null){
                        throw new RuntimeException("please use setItems() to initialize items for select¡£");
                   List fileteredList=new Vector();//<String>
                   for(int i=0;i<items.length;i++){
                        if(items.toLowerCase().startsWith(txt)){
                             fileteredList.add(items[i]);
                   jlistReservior.setListData(fileteredList.toArray());
                   jlistReservior.setSelectedIndex(0);
              }else{
                   jlistReservior.setSelectedIndex(-1);
                   for(int i=0;i<items.length;i++){
                        if(items[i].toLowerCase().startsWith(txt)){
                             jlistReservior.setSelectedValue(items[i], true);
                             return;
         private void refreshPopup(){
              if(isDropDownMode){
                   if(jpopup4List==null){
                        jpopup4List=new JPopupMenu();
                        jpopup4List.add(jscroll4List);
                   jpopup4List.show(jtfInput, jtfInput.getX(), jtfInput.getY()+jtfInput.getHeight());
                   jtfInput.requestFocus();
         //listening user jtfInput change;
         private DocumentListener inputChange=new InputChange();
         class InputChange implements DocumentListener{
              public void changedUpdate(DocumentEvent e) {inputChanged();}
              public void insertUpdate(DocumentEvent e) {inputChanged();}
              public void removeUpdate(DocumentEvent e) {inputChanged();}
              private void inputChanged(){
                   doFilter();
                   refreshPopup();
         //listening user mouse double click jtfInput
         private DoubleClickDropDown clickDropDown=new DoubleClickDropDown();
         class DoubleClickDropDown extends MouseAdapter{
              public void mouseClicked(MouseEvent e){
                   if(e.getButton()==MouseEvent.BUTTON1
                             && e.getClickCount()==2){
                        refreshPopup();
         //listening user click drop down list menu ,select item;
         private ClickSelect clickSelect=new ClickSelect();
         class ClickSelect extends MouseAdapter{
              public void mouseClicked(MouseEvent e){
                   selectInDropDown();
         private void selectInDropDown(){
              jtfInput.setText(jlistReservior.getSelectedValue().toString());
              jpopup4List.setVisible(false);
         //listening user control key;
         private KeyListener inputKeyListener=new InputKeyListener();
         class InputKeyListener extends KeyAdapter{
              public void keyPressed(KeyEvent e){
                   int selected=jlistReservior.getSelectedIndex();
                   if(e.getKeyCode()==KeyEvent.VK_UP){
                        if(selected>0){
                             jlistReservior.setSelectedIndex(selected-1);
                   }else if(e.getKeyCode()==KeyEvent.VK_DOWN){
                        if(selected<(jlistReservior.getModel().getSize()-1)){
                             jlistReservior.setSelectedIndex(selected+1);
                   }else if(e.getKeyCode()==KeyEvent.VK_ENTER){
                        selectInDropDown();
         //listening list mouse over select
         private MouseMotionAdapter mouseOverShow=new MouseOverSelect();
         class MouseOverSelect extends MouseMotionAdapter{
              public void mouseMoved(MouseEvent e){
                   int selected=jlistReservior.getSelectedIndex();
                   int current=jlistReservior.locationToIndex(e.getPoint());
                   if(selected!=current)
                        jlistReservior.setSelectedIndex(current);
         //listening when jtfInput resize
         private ComponentListener resizeListener=new ResizeListener();
         class ResizeListener extends ComponentAdapter{
              public void componentResized(ComponentEvent e){
                   refreshSize();
         /*--------------weather drop down mode---------------------*/
         public boolean getIsDropDown(){
              return isDropDownMode;
         * É趨ÏÂÀģʽ£¬»ò¹Ì¶¨Ä£Ê½¡£É趨ºó×Ô¶¯Ë¢Ð½çÃæ¡£
         * @param dropDown true ±íʾÏÂÀģʽ£¬false ±íʾ¹Ì¶¨Ä£Ê½
         public void setIsDropDownModel(boolean dropDown){
              isDropDownMode=dropDown;
              dropModelRefresh();
              validate();
              repaint();
         private void dropModelRefresh(){
              if(isDropDownMode){
                   remove(jscroll4List);
                   jpopup4List.add(jscroll4List);
                   jtfInput.addMouseListener(clickDropDown);
              }else{
                   jpopup4List.remove(jscroll4List);
                   add(jscroll4List,"Center");
                   jtfInput.removeMouseListener(clickDropDown);
         /*--------------------drop down items-------------------------*/
         public void setItems(String[] strs){
              items=strs;
              refreshItems();
         public String[] getItems(){
              return items;
         private void refreshItems(){
              //if is filter mode ,items may be ordered;
              Comparator cmp = Collator.getInstance(Locale.getDefault());
              java.util.Arrays.sort(items, cmp);
              jlistReservior.setListData(items);
         /*---------------------weather filter mode------------------------*/
         public void setIsFilter(boolean isFilter){
              isFilterMode=isFilter;
              refreshItems();
         public boolean getIsFilterMode(){
              return isFilterMode;
         /*---------------------size property---------------------------------*/
         public int getRows(){
              return rows;
         public void setRows(int rowCount){
              rows=rowCount;
              refreshSize();
              validate();
              repaint();
         public int getColumns(){
              return jtfInput.getColumns();
         public void setColumns(int colCount){
              jtfInput.setColumns(colCount);
              validate();
              repaint();
         private void refreshSize(){
              Font font=jlistReservior.getFont();
              FontMetrics fm=jlistReservior.getFontMetrics(font);
              int height=fm.getHeight()*rows;
              //int height=jlistReservior.getFixedCellHeight()*rows;
              System.out.println(jlistReservior.getFixedCellHeight());
              Dimension size=new Dimension(jtfInput.getWidth(), height);
              jscroll4List.setPreferredSize(size);
         /*--------------------input text property-------------------*/
         public String getText(){
              return jtfInput.getText();
         public void setText(String text){
              jtfInput.setText(text);
    Edited by: tlw_ray on Oct 23, 2008 10:56 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

  • JWindow setLocation issue...

    Hello,
    I got 3 simple lines of code:
    window = new JWindow(parent);
    window.pack();
    window.setLocation(location);
    window.setVisible(true);But they doesn't work when my Matrox driver has center-popup-windows flag enabled. But I need this window to be moved to my location not to the center of the screen. Does anyone know how to prevent this from happening? For instance JFrame isn't moved to the center automatically. :(
    I use it as a popup in calendar editor.
    Help please!

    But they doesn't work when my Matrox driver has
    center-popup-windows flag enabled. Hi,
    does it behave correctly when you turn off that flag? Seems as if the Matrox driver treats a JWindow as a popup.
    I think it is hardly possible to override hardwar-driver-settings by Java.
    Greets,
    Christian

  • How do i get my photos?

    My Iphone 5c screen is smashed, my photos have not saved to icloud i want my photos but itunes wants me to press accept on iphone but screen cannot feel my finger as its smashed. How do i get my photos?
    I had a baby in sept and all her pics are on there from birth until now
    PLEASE Help!

    Ignore Jose's post about uninstalling iTunes.  That's totally unneccesary.
    Move the iTunes window up a bit on your desktop screen.  Grab the top section with your mouse, move the window up so that you can see all of the iTunes screen.  If you have trouble doing that, try this.
    Based on your screenshot, just click the red x in the center popup window that talks about allowing this computer to access iPhone.  Then, click the white square at the top right of the main iTunes window, next to the white x.  That will make iTunes 'full screen'.  Then try reconnecting the iPhone, and you shoudl be able to see the entire screen.

  • Multi-screen GUI

    Hello,
    I have made GUI in LabView using TAB control. GUI will toghther with VI be used for process control. I need to split 'frames' from TAB control into 3 separate screens and still use one PC. Is this feasible?
    To summary: One common PC with VI running, GUI presented on three separate (19" flat) screens.
    Do I need the new graphic card to PC or? What if the PC are an laptop?
    Thanks in advance
    Hariss

    Not to advertise, but check this out by Matrox: 
    http://www.matrox.com/graphics/offhome/th2go/home.cfm
    ...... now I want one of these!!!  .....
    (where's the drool icon??)
    EDIT=====
    I have to get one of these!!!
    Check out the specs:
    TripleHead2Go is compatible with many professional and enthusiast class desktop and laptop PCs equipped with certain NVIDIA® and ATI® enabled graphics chipsets and add-in-boards (including multi-GPU configurations). Maximum resolutions supported may vary depending on the GPU version. An updated matrix of GPU version and maximum resolution supported is available on the compatibility page.
    Inside the box
    TripleHead2Go connector box
    2-foot HD15-to-HD15 (analog) monitor cable
    2-foot DVI-I to VGA cable
    External 5VDC power adapter
    Region-specific power cable(s)
    Quickstart paper and CD, which includes the following software:
    Install package
    PowerDesk SE (includes Image quality adjustment, center popup, window management, etc.)
    Electronic Product Manual
    Matrox Surround Gaming Utility
    Additional resolutions (such as DualHead modes or Triple Widescreen modes) can be enabled through the TripleHead2Go Mode Expander Tool.
    Product information
    Dimensions
    9.2 cm x 10.7 cm x 2.5 cm
    Weight
    168 grams
    Connectors
    HD-15 (analog) x 4 (1 input, 3 output), Power (5VDC, 2A)
    Message Edited by JoeLabView on 06-20-2006 10:55 AM

  • To All Top Java Programmers !

    Hello Experts;
    I'm the main programmer of a free java ide that will soon be release : http://www.freewebs.com/cube-j
    I'm here because I'm encountering a big problem for me.
    To have a glimpse of the problem here is the link : http://www.freewebs.com/cube-j/pic.html
    The ide itself uses a desktop pane as its 1st screen. If the user created a new file the desktop pane
    will be hidden by setVisible(false); after that the text pane, tab pane and split pane will be
    displayed as the working area of the programmer. You can close every tab pane on the user
    interface by right clicking the text pane and selecting close on my pop-up menu.
    If you remove the last tab, it will be remove and the desktop pane should be displayed again
    using setVisible(true); here is the code for removing the tab panes :
    // where i7 is a menu item on my pop-up menu
    i7.addActionListener(new ActionListener() {
    public void actionPerformed( ActionEvent e )
    // x1 is my tab pane . . .
    int rem = x1.getTabCount();
    if (rem == 1) {
    // remove tab pane . . .
    x1.remove(x1.getSelectedIndex());
    // if its the last pane d1 which is desktop pane
    // should be displayed . . .
    x1.setVisible(false);
    s1.setVisible(false);
    s2.setVisible(false);
    d1.setVisible(true);
    else {
    // If its not the final tab then keep removing . . .
    x1.remove(x1.getSelectedIndex());
    As you can see on my link above I'm having a problem on my desktop pane cause after a
    resize or a full screen the desktop pane would remain the same and would not
    follow the resize of the frame. Is there any solution to this ?
    Dont worry about the layout cause its well arange, the desktop pane is set like :
    this.getContentPane().add(d1, BorderLayout.CENTER);
    Hoping to here from you guys . . .
    Friend : Javatm

    I've already reproduce my codes to a much more simplier format.
    1.) Click 1st the reproduce button then you'll see a txt area w/ a tabbedpane.
    2.) Right click the text area and select close.
    3.) Then resize the window, you will see that the desktop pane would not follow.
    Is there any solution to this :
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MyFrame extends JFrame {
    private JDesktopPane d1;
    private JTabbedPane x1;
    private JTextArea t1;
    public MyFrame() {
    super("Sample . . .");
    JPanel p1 = new JPanel();
    d1 = new JDesktopPane();
    JButton b1 = new JButton("Reproduce");
    p1.add(b1);
    this.getContentPane().add(d1, BorderLayout.CENTER);
    this.getContentPane().add(p1, BorderLayout.SOUTH);
    // This is for the screen resolution and dimension
    Dimension sd = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation(sd.width / 2 - 300 / 2,
    sd.height / 2 - 275 / 2);
    setSize(300, 275);
    show();
    b1.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent h)
    create();
    private void create() {
    d1.setVisible(false);
    t1 = new JTextArea();
    x1 = new JTabbedPane();
    String s1 = "Untitled";
    String s2 = "To close this area you need to right"+
    "\nclick this text area and then select close.";
    t1.setText(s2);
    x1.addTab(s1, new JScrollPane(t1));
    x1.setVisible(true);
    this.getContentPane().add(x1, BorderLayout.CENTER);
    popup();
    private void popup() {
    final JPopupMenu p1 = new JPopupMenu();
    JMenuItem i1 = new JMenuItem("Close");
    i1.setAccelerator(KeyStroke.getKeyStroke(
    KeyEvent.VK_X, ActionEvent.CTRL_MASK));
    p1.add(i1);
    i1.addActionListener(new ActionListener() {
    public void actionPerformed( ActionEvent e )
    int rem = x1.getTabCount();
    if (rem == 1) {
    x1.remove(x1.getSelectedIndex());
    x1.setVisible(false);
    t1.setVisible(false);
    d1.setVisible(true);
    else {
    x1.remove(x1.getSelectedIndex());
    t1.addMouseListener( new MouseAdapter() {
    public void mousePressed( MouseEvent e ) {
    checkForTriggerEvent(e);
    public void mouseReleased( MouseEvent e ) {
    checkForTriggerEvent(e);
    private void checkForTriggerEvent( MouseEvent e ) {
    if ( e.isPopupTrigger() )
    p1.show( e.getComponent(), e.getX(), e.getY() );
    public static void main( String args[] )
    MyFrame app = new MyFrame();
    app.addWindowListener(
    new WindowAdapter() {
    public void windowClosing( WindowEvent e )
    System.exit(0);
    Thank you very much . . .

  • Flex mobile - close popUp with back hardware key - bug?

    Hi everyone,
    i am having a problem with a popUp in my firstView aka HomeView. I used a similar logic as provided by the DashBoardMobile reference example: (http://www.adobe.com/products/flex/examples/)
    when i open the PopUP i add a EventListener with the HandlerFunction to close the popUp if the device back-key is pressed:
    systemManager.stage.addEventListener(KeyboardEvent.KEY_UP, deviceKeyUpHandler, false, 1000, true);
    protected function deviceKeyUpHandler(event:KeyboardEvent):void
                    var key:uint = event.keyCode;
                    if (key == Keyboard.BACK)
                        event.stopImmediatePropagation();
                        event.stopPropagation();
                        closePopUp();
    So far this had worked fine (if a popUp is open its get closed, if no popUp is open the previous View is poped)
    Now i made a popUp for the firstView of my app, and there this doesnt works, if i press the back-kay the application is closed wether the popUp is open or not...

    You might want to try listening for the backKeyPressed event on the View instead: http://polygeek.com/4225_air-mobile_go-your-own-way-overriding-the-back-key-press-in-air-m obile-apps
    In that handler if your popup is open you'll want to preventDefault() on the event and call your close logic.

  • HT4314 How do I disable game center's "welcome back" popup messages or disable game center entirely?

    Iphone 5, iOS 7.0.4
    Ok, this seems obvious but how do I get rid of this welcome back popup? Every time I open a game this redundant "welcome back!" message pops up taking up a good quarter of the screen and frequently causing me to die. I can't tell you how many times I've opened a game like Sonic the Hedgehog 2, only to die immediately because I can't see my character while he's covered by a big "welcome back" message. Of course, when that's the last life left and I end up having to restart the whole level, you can see how it might be way more frustrating than it's worth.
    So, I've excluded game center from the notification center stuff, I've set it to "no notifications" (which shouldn't matter since it's excluded) and still it pops up.
    I signed out of game center too because i'd rather enjoy my games than be frustrated and able to share the scores.  Now it just has a pop up at the beginning of every game asking me to sign in, which is just aggrivating in a different way, plus now I I don't have the ability to use the game center. I read here that once signed out there is a button to disable game center, but that doesn't seem to appear in iOS 7. Is there a way to disable it without jailbreaking my phone?
    Thanks!

    May not be Game Center but something in Solitaire...whcih Solitaire is this, there are so many?
    I have Real Solitaire, ver 2.5.1 and it has in the window when you win that you are not signed in to Game Center but never says anything else about Game Center.

Maybe you are looking for

  • Can't see NAS device connected to BEFW11S4 v2

    I have an Iomega StorCenter 250GB NAS drive that works perfectly well when directly connected to a Windows XP SP2 laptop.  When I plug it into my Linksys BEFW11S4 v2 router, I can not connect to it.  All of the right LEDs light up on the router and S

  • Error when installing 9.0.1.4.0 patch set for the Oracle Database Server.

    Hi to all. Currently, i am trying to install patches for portal server. The server OS is Sun Solaris 8. We are using Oracle9iAS. Now, we are installing 9.0.1.4.0 patch set for the Oracle Database Server. We managed to install the patch, but have prob

  • Beginners guide for netweaver administration

    hi , i m a basis administrator . next month they r going to put me in  a project where xi is implemented . gurus what are the url's which guides for the sap xi administration  i m very new to xi...so can you also please say me what would be the job r

  • EJB Deployment error in 9.2 (java.lang.OutOfMemoryError: Java heap space at

    Hello all, I am trying to deploy EAR(has more than 25 ejb's) in weblogic 9.2 but currently one EJB ejb-pwc.jar is failing to compile(gives out of memory error). But if i try building ear only with this EJB and its dependencies class it work. Here is

  • Updating to 2.0

    I sync my music and videos and photos to my account at home and I sync my contacts, calender, and e-mail at work. Well I am at work and want to update to 2.0 but it says that I should do this where I sync my media because I will loose all of my photo