How to Capture the event when minimized button is clicked of a JFrame?

Hi All,
In my SWING application, I want to do something when the minimized button is clicked. But not able to understand how to do that.
My basic requirement is like that, if I minimize the JFrame, it should be minimized to system tray with an icon. Again when the icon is clicked, the frame should be maximized in the Windows.
Also, how to make my JFrame visible/invisible. If I close it, then the process will got killed... that I don't want to happen. Should I us setVisible(true/false) for the frame... Please suggest...
Thanks,
Ujjal

There could be some mistake in my basic understanding... Anyway this is what I wrote...
import java.io.*;
import java.awt.*;
import javax.swing.*;
public class WindowIconify extends JApplet
     JFrame jf;
     JPanel jp;
     public void run()
          jf = new JFrame("test");
          jf.setSize(200,200);
          jp = new JPanel();
          jp.setBackground(Color.BLACK);
          jf.add(jp);
          jf.setVisible(true);
     public boolean handleEvent(Event event)
          if ( event.id == Event.WINDOW_ICONIFY)
               System.out.print("iconifying");
          return true;
     public static void main(String args[])
          WindowIconify wi = new WindowIconify();
          wi.run();
}

Similar Messages

  • How to capture the event in ALV grid display?

    Hi experts,
      How to capture the event in an ALV grid display which is editable. I have to capture the TAB key or ENTER key.
    regards,
    Arul Jothi.

    Hi Arul,
    Take a look at sample program BCALV_EDIT_03. (Find string "register ENTER" in the program to see how to register)
    Basically you have to Register edit events using method call REGISTER_EDIT_EVENT and then write a handler method for event DATA_CHANGED..
    If you are using a REUSE..GRID fm then first get the grid reference using function module GET_GLOBALS_FROM_SLVC_FULLSCR and then repeat the above procedure..
    Hope this helps..
    Sri
    Message was edited by: Srikanth Pinnamaneni

  • How to capture the event in driver JSplitPane

    Hi all, i have some problem with the JSplitPane.
    What i want to do is that:
    i need to capture the event throw when the user press the button in the driver of the JSplitPane, this is because i want to know wich side of the splitpane is complet visible.
    Thanks for your time!
    Luca

    I thought I would do up an example just for fun. As you drag the splitter bar the size of the two components and the splitter component is reported to the console along with the divider location. Interestinly, on my system (Windows XP, Java 1.41_02) when you move the bar downwards the divider location is consistantly two pixels past the height of the top component but when you drag the bar upwards the divider location and the height of the top component are the same.
    Does anyone have any ideas why that would be?
    Here is the test app:package splitPaneMonitor;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import javax.swing.JFrame;
    import javax.swing.JSplitPane;
    import javax.swing.JTextArea;
    public class SplitPaneFrame extends JFrame implements PropertyChangeListener  {
         public SplitPaneFrame()  {
              super ("Split pane test");
              //  Create the components to show in the split pane
              myTopComponent = new JTextArea ("This is the top component", 10, 40);
              myBottomComponent = new JTextArea ("This is the bottom component", 15, 40);
              //  Create the split pane
              mySplitter = new JSplitPane (JSplitPane.VERTICAL_SPLIT , true, myTopComponent, myBottomComponent);
              mySplitter.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, this);
              getContentPane ().setLayout(new BorderLayout ());
              getContentPane ().add (mySplitter, BorderLayout.CENTER);
         public void propertyChange (PropertyChangeEvent evt) {
              if (evt.getPropertyName () == JSplitPane.DIVIDER_LOCATION_PROPERTY)  {
                   System.out.println ("Split pane divider moved");
                   Dimension size = myTopComponent.getSize ();
                   System.out.println ("    The top component's size is: " + size.height +" h, "+ size.width + " w");
                   myBottomComponent.getSize (size);
                   System.out.println ("    The bottom component's size is: " + size.height +" h, "+ size.width + " w");
                   mySplitter.getSize (size);
                   System.out.println ("    The splitter's size is: " + size.height +" h, "+ size.width + " w");
                   System.out.println ("    The splitter divider location is: " + mySplitter.getDividerLocation ());
         private JTextArea myTopComponent;
         private JTextArea myBottomComponent;
         private JSplitPane mySplitter;
         public static void main(String[] args) {
              SplitPaneFrame appFrame = new SplitPaneFrame ();
              appFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              appFrame.pack();
              appFrame.setVisible (true);          
    }

  • Is it possible to fire an event when radio buttons are clicked in a report?

    Hi All,
    I have got a requirement. In the selection screen i have certain input fields and three radio buttons. When radio buttons are clicked i have to grey out certain input fields. Is it possible to fire an event when i write program through se38??
    Thanks
    Rakesh

    Hi Rakesh,
    Check this code.
    SELECTION-SCREEN BEGIN OF BLOCK FINPUT WITH FRAME TITLE TEXT-001.
    PARAMETERS  : FILENAME(132) TYPE C LOWER CASE  NO-DISPLAY,
                  FDLOAD RADIOBUTTON GROUP RAD1
                  USER-COMMAND R1 ,
                  FUPLOAD RADIOBUTTON GROUP RAD1 .
    SELECTION-SCREEN END OF BLOCK FINPUT.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
    PARAMETERS : FUNAME(132) TYPE C LOWER CASE MODIF ID AA.
    SELECTION-SCREEN PUSHBUTTON /33(30) ACTION USER-COMMAND
                     BTNACT MODIF ID AA VISIBLE LENGTH 8 .
    SELECTION-SCREEN PUSHBUTTON 43(30) CANCEL USER-COMMAND
                     BTNCAN MODIF ID AA VISIBLE LENGTH 8  .
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    PARAMETERS : FDNAME(132) TYPE C LOWER CASE MODIF ID BB.
    SELECTION-SCREEN PUSHBUTTON /33(30) ACTIONS USER-COMMAND
                     BTNACT1 MODIF ID BB VISIBLE LENGTH 8.
    SELECTION-SCREEN PUSHBUTTON 43(30) CANCELS USER-COMMAND
                     BTNCAN1 MODIF ID BB VISIBLE LENGTH 8.
    SELECTION-SCREEN END OF BLOCK B2.
    DATA : ACTNAME(8) TYPE C,SCRGRUP(2) TYPE C.
    INITIALIZATION.
    ACTIONS = 'Download'.
    CANCEL = 'Cancel'.
    ACTION = 'Upload'.
    CANCELS = 'Cancel'.
    ACTNAME = 'Download'.
    SCRGRUP = 'AA'.
    AT SELECTION-SCREEN ON RADIOBUTTON GROUP RAD1.
    IF FUPLOAD = 'X'.
         MOVE 'Upload' TO ACTION.
         MOVE 'Upload' TO ACTNAME.
    ELSEIF FDLOAD = 'X'.
         MOVE 'Download' TO ACTION.
         MOVE 'Download' TO ACTNAME.
    ENDIF.
    AT SELECTION-SCREEN.
    IF SY-UCOMM = 'R1'.
        IF ACTION = 'Download'.
          SCRGRUP = 'AA'.
         MESSAGE S007(ZMESSAGE).
        ELSEIF ACTION = 'Upload'.
          SCRGRUP = 'BB'.
         MESSAGE S008(ZMESSAGE).
       ENDIF.
    ELSEIF SY-UCOMM = 'BTNCAN' OR SY-UCOMM = 'BTNCAN1'.
      LEAVE PROGRAM.
    ENDIF.
    *AT USER-COMMAND.
    CASE SY-UCOMM.
       WHEN 'ACTIONS'.
         LOOP AT SCREEN.
           IF SCREEN-NAME = 'FUNAME'.
           ENDIF.
         ENDLOOP.
    ENDCASE.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR FUNAME.
      PERFORM call_filedialog CHANGING FUNAME.
    PERFORM call_filedialog CHANGING FUNAME.
    AT SELECTION-SCREEN OUTPUT.
    LOOP AT SCREEN.
    IF SCREEN-GROUP1 = SCRGRUP AND ACTNAME = 'Download' .
      SCREEN-ACTIVE = 0.
      MODIFY SCREEN.
    ENDIF.
    IF SCREEN-GROUP1 = SCRGRUP AND ACTNAME = 'Upload'.
      SCREEN-ACTIVE = 0.
      MODIFY SCREEN.
    ENDIF.
    ENDLOOP.
    FORM call_filedialog CHANGING fname.
      DATA: li_filetable TYPE STANDARD TABLE OF file_table,
        lv_return TYPE i,
        lw_filetable TYPE file_table.
      CALL FUNCTION 'TMP_GUI_FILE_OPEN_DIALOG'
        TABLES
          file_table = li_filetable
        EXCEPTIONS
          cntl_error = 1
          OTHERS     = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      READ TABLE li_filetable INDEX 1 INTO lw_filetable.
      fname = lw_filetable-filename.
    ENDFORM.                    "call_filedialog
    Reward Points, if useful.
    Regards,
    Manoj Kumar

  • How to Catch the Event when a Row is Selected in Extended value Selector

    Hi All.
    I Want to Call the Action when a perticular row is selected in Extended value Selector.
    How can I do it
    Thanks & Regards
         Kiran

    Hi Kiran,
                  Create a seperate view with the table of records same u are showing EVS because with EVS it is not possible to raise any event.
    So add ths view to a seperate window and open that window instead of EVS .So here you can raise an event becuse it a view.
    Regards
    Padma N

  • How te get the event of SAVE button in WDDOPOSTPROCESSING method

    Hello,
    am using an application that was configured with FPM, and my question is  how can I get the event wehen the user click on the save button in the method WDDOPOSTPROCESSING?
    will explain again!
    if the user click on the save button, how can I know or get the event in the WDDOPOSTPROCESSING?
    am talking here about the general save button in the header..
    please let me know if somebody knows
    thank you all

    just to make it easy for me,  the save button has an ID , i dont know how to get that ID  or where that action will be generated , i dont know where to implement my method, and this is the problem i dont know where or which method or class or IF will be genareted
    the SAP Developper are taking this case into consideration , because normaly all the data will be stored first in a buffer table, and after the suer clicks on the SAVE button, all the data will bestored in the corresponding INFOTYPE using the CP of the person, but in case of some INFTYPEs that are specified with 'P' instead of 'CP' we can't use the SAP Standard methode insert_infty , and this is the reason why i believe that there must be an alternative way to save all DATA of all Subtable by clicking only once on the save button.
    I foundout that the methode WDDOPOSTPROCESSING will be generated after clicking on the SAVE button, but as I said, i can't get the corresponding event ????
    please is somebody has an Idea, am still interessted to get the solution.
    thank you all

  • How to capture the event on changing focus from a JTextField?

    Hi All,
    I have got a problem...
    I want to do something (say some sort of validations/calculations) when I change the focus by pressing tab from a JTextField. But I am not able to do that.
    I tried with DocumentListener (jtf01.getDocument().addDocumentListener(this);). But in that case, it's calling the event everytime I ke-in something in the text field. But that's not what I want. I want to call that event only once, after the value is changed (user can paste a value, or even can key-in).
    Is there any way for this? Is there any method (like onChange() in javascript) that can do this.
    Please Help me...
    Regards,
    Ujjal

    Hi Michael,
    I am attaching my code. Actual code is very large containing 'n' number of components and ActionListeners. I am attaching only the relevant part.
    //more codes
    public class PaintSplitDisplay extends JApplet implements ActionListener
         JFrame jf01;
         JPanel jp01;
         JTextField jtf01, jtf02;
         //more codes
         public void start()
              //more codes
             jtf01 = new JTextField();
              jtf01.setPreferredSize(longField);
              jtf01.setFont(new Font("Courier new",0,12));
              jtf01.setInputVerifier(new InputVerifier(){public boolean verify(JComponent input)
                   //more codes
                   System.out.print("updating");
                   jtf02.setText("updated value");
                   System.out.print("updated");
                   return true;
              //more codes
              jtf02 = new JTextField();
              jtf02.setPreferredSize(mediumField);
              jtf02.setEditable(false);
              jp01.add(jtf02, gbc);
              //more codes
              jf01.add(jp01);
              jf01.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              jf01.setVisible(true);
              //more codes
         public static void main(String args[])
              PaintSplitDisplay psp = new PaintSplitDisplay();
              psp.start();
         public void actionPerformed(ActionEvent ae)
              //more codes
    }As you can see I want to update the second JTextField based on some calculations. That should happen when I change the focus from my frist JTextField. I have called jtf02.setText() method inside InputVerifier. But it's giving error...
    Please suggest...
    Ujjal

  • How to resubmit the form when back button pressed

    Hi,
    In my application, iam implementing searching,
    when i submitting the form, i got some records and i navigated all the results through next and previous buttons.
    Problem occurs when i clicked on back button, it is showing "page expires and asking for resubmit the data".
    How can i show the previous page, when user clicked on back button.
    Iam using struts 1.0 and ibatis
    Please help me out.
    Thanks in advance,
    Mohan

    Hi mohan,
    try to store your search indices in a vector and put that vector in the session scope. at page first loading you get the first index from your vector and pass it in the request scope in your action class, due to the page you have to find a way to understand the passed index in request scope and translate it to the searched word location.really I have not a code sample, but it is just an idea.
    feel free to ask me.
    Thanks.
    Ahmad Elsafty

  • How to trigger the event when leave current iView

    Hi Expert,
    We have this common senario: when leave current iView(eg, change the menu, close the window etc) we need to notify user whether they want to save current content or not, but I found wdDoExit(in views or coponent controller) can not be triggered
    Is there any event we can use to reside these logic?
    Thanks in advance.
    Best Regards,
    William

    How about trying to use the wdDoBeforeAction event?  You can use a flag to keep track of whether or not there is unsaved data, and check it in the above-mentioned event.
    Walter

  • How to catch the event when a MovieClip is visible/invisible?

    Is there event for that e.g. activate/deactivate? Thanks,

    there's are events for when a movieclip is added and removed from the display, but not for the visible property.

  • How to get the tab when is it pressed?

    I have the following situation:
    I have an array of JTextField inside a scroollpane. The size of my array is nine or ten depends on some rules. But my window show just four JTextField. So I would like to know how to get the event when I press "tab", just to show the others JTextField while I'm pressing "tab". Because I need this event to scrooll down or scrooll up.
    I tried the keylistener, but when I press "tab" any method(keypressed, keyreleased, keytyped) is called.
    I also tried the focuslistener. If this event I could scrooll down or scrooll up, but I couldn't do both!!
    Can somebody help me??
    Thanks anyway!!
    Gin

    JTextField implements Scrollable interface, which provides information to the enclosing container such as JScrollPane.
    Hence when the tab event is fired, you can compute the Rectangle area that should be visible and then call the 'scrollRectToVisible()' method in JTextField. This will inform the JScrollPane to scroll to the rectangle that you mention.
    HTH

  • How to get the event before the session end?

    Currently i using a connection pool (dbpool). I need to release my pool when user logout or closing the browser. I have a session that keeping the user information and the connection pool manager.
    How i detect the event when session end? I need to know is that can catch an event and perform release() command before the session that store login information ended.
    Or have other solution to release the pool (it acually is only 1 pool, it will close the pool when no user(s) using it)

    you do not need to do this.
    In your db code, when you use
    conn.close(); your connection will be released to the pool.
    If you do not do this you will get connection pool leaks.
    There is no benefit in using a pool if you try and keep a connection for a single user, the idea is to SHARE connections between many users.
    If you want to detect session expiry yoyu need to use a 'session listener', if you search the forums you can easily find out how to do this.
    The main thng is NOT to tie your connections up in this way, you MUST use conn.close(); to release your connections back to the pool as soon as you have finished using them.

  • Access Bidder Tab Details when PUBLISH button is clicked

    Hi All,
    I've few requirements to enhance the functionality of PUBLISH button in Rfx Creation.
    One fo them is to trigger notification mails to all bidders when RFx is re-PUBLISHed by clicking PUBLISH button.
    I need to fetch all the bidder list from Bidder Tab whenever PUBLISH is clicked.
    Need to know where / which method has all these details so that I can enhance it.
    I know that PUBLISH is in the toolbar for FPM_OIF_COMPONENT.
    View - CNR_VIEW
    RFx Bidder tab details will get from the component /SAPSRM/WDC_UI_DO_BIDDER.
    I want to access the bidders when PUBLISH button is clicked.
    I want to which method is executed when PUBLISH button is clicked.
    Tried with CL_ABAP_DEBUGGER and CL_WDR_ACTION but not getting the ecaxt component which is calling.
    Is there any other way to debug?
    Thanks in Advance
    Rgrds,
    Sravan

    A bit late, but method /SAPSRM/IF_FPM_OVRIDE_EVT_OIF~OVERRIDE_EVENT_OIF from /SAPSRM/CL_FPM_OVRIDE_OIF is extremely useful trying to debug where the info comes from.
    Basically, there are several mappers classes that access to pdo layer somehow. It is always the same process more or less, but you have to know which classes are involved.
    You can usually get a class that is accesible from your wd component. If no BAdIs or no other way of doing some z modification, it is always posible to directly enhance such class...
    Hope this helps
    Regards

  • How to capture the PrintScreen button event in keyboard

    Hi
    The JPanel consists of all components , and finally the panel is added to the JFrame.The problem is to avoid the user by capturing the page through "PrintScreen" button in the keyboard.
    Thank u .

    Hi,
    I believe that you must use JNI to access .dll to do that... you can not use any keyListeners for that!!!
    JRG

  • How to Create a Dynamic http address that opens the Explorer Window for a List Item When a Button Is Clicked--Currently Trying to Make this Work with Javascript

    I have created a button (via Content Editor) that uses JavaScript to open the Attachments folder of a list item in the Explorer Window in SharePoint 2010. The purpose is to have drag and drop functionality for each list item, having multiple attachments.
    The button works but opens the "Attachments" folder containing all of the other folders for each list item (one folder per item). It seems that when you add an attachment to a list item, SharePoint numbers the folder based on the item's ID. What
    I'm trying to do is take the JavaScript I have and have it run when a button is clicked in a custom form. When it runs, I'm trying to get it to open the "specific" folder for the list item. I have had success creating a hyperlink in the list that
    does this; however, the link WILL NOT work until I use the Content Editor created button that runs JavaScript, that prompts me to click OK to my profile certificate, and then opens the Attachment folder. After that occurs, I can use my hyperlinks without issue
    because I'm no longer prompted to click OK for my cert.
    So I'm trying to take the JavaScript I have and place it in a list item form (custom form) and have it run when a form button is clicked. The problem is I have very little knowledge of JavaScript (did I mention little?) and
    "don't know how to take the "http:" address I have in the script and append to it the list item ID, according to the record I have open."
    So that for any record I open, the script will grab the corresponding record ID (or list item ID) and append it.
    Here's the script I'm working with (which I didn't create but am grateful for):
    <style>
    .httpFolder {behavior:url(#default#httpFolder);}
    </style>
    <script text = "javascript">
       function fnOpenFolderView(){
       oDAV.navigateFrame("https://server/collection/site/subsite/Lists/Sublist/Attachments","_self");
    </script>
    <div id = "oDAV" class = "httpFolder"/>
    <input type = "button" value = "Open Attachment Folder" onclick = "fnOpenFolderView()"/>
    The above script, in the Content Editor, creates a button that opens the Attachments folder for the corresponding SharePoint list.
    JackSki123

    Hello Thriggle,
    Thank you for pointing that out. I appended your "GetUrlKeyValue" to the end and it worked. That said, I noticed it doesn't run as smoothly as when I simply click on the Content Editor button I created that resides on the SharePoint List
    ASPX page (not the form). The Content Editor button has the same code, minus the "GetUrlKeyValue". I click it; I get prompted to choose my cert; it opens right up.
    Now go to the ASPX Display form where I dump the code in a table cell. Button appears in cell; I click it; wait; wait; I get prompted for cert; it opens. Do I need some sort of "throttle" for the JavaScript? For instance, I thought before running
    JavaScript, you reference the library first. This code doesn't do that. I'm wondering if there's something more I need to make this run smoothly. Thank you both for getting me this far. 
    JackSki123

Maybe you are looking for