Want to close  JInternalFrame when user press OR release "Esc" key.

i want to close JInternalFrame when user press OR release "Esc" key.
i am trying that
but nothing print on console
public class IFTest extends javax.swing.JInternalFrame {
    public IFTest() {
        initComponents();
    private void initComponents() {
        setClosable(true);
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            public void keyReleased(java.awt.event.KeyEvent evt) {
                formKeyReleased(evt);
            public void keyTyped(java.awt.event.KeyEvent evt) {
                formKeyTyped(evt);
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 394, Short.MAX_VALUE)
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 278, Short.MAX_VALUE)
        pack();
    private void formKeyPressed(java.awt.event.KeyEvent evt) {
        System.out.println("formKeyPressed");
    private void formKeyReleased(java.awt.event.KeyEvent evt) {
       System.out.println("formKeyReleased");
    private void formKeyTyped(java.awt.event.KeyEvent evt) {
       System.out.println("formKeyTyped");
}

i don ti thanks
public class IFTest extends javax.swing.JInternalFrame {
    public IFTest() {
        initComponents();
         this.getActionMap().put("test", new AbstractAction(){
            public void actionPerformed(ActionEvent e) {
                System.out.println("Escape Pressed");
        InputMap map = this.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
        map.put(stroke,"test");
    private void initComponents() {
        setClosable(true);
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            public void keyReleased(java.awt.event.KeyEvent evt) {
                formKeyReleased(evt);
            public void keyTyped(java.awt.event.KeyEvent evt) {
                formKeyTyped(evt);
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 394, Short.MAX_VALUE)
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 278, Short.MAX_VALUE)
        pack();
    private void formKeyPressed(java.awt.event.KeyEvent evt) {
        System.out.println("formKeyPressed");
    private void formKeyReleased(java.awt.event.KeyEvent evt) {
       System.out.println("formKeyReleased");
    private void formKeyTyped(java.awt.event.KeyEvent evt) {
       System.out.println("formKeyTyped");
}

Similar Messages

  • How to show old value in webui when user press NO button on popup button.

    Hi Experts,
    As per requirement I have created custom field with dropbox and with popup box to cofirm user decision if value from field changes.
    Now on Popup when user press Yes then its Ok as no need to change the current value in the field.
    but when user press the NO button I want to display the old value on Web UI so now I am able to catch the old value and pass it into the field at backend but I am not able to make the change on the web page.
    Please reply if anyone have solution for it.
    BR
    Gaurav    

    Hi Gaurav,
    First of all when all this is happening in UI why you need to pass the selected value to backend. I didnt get this.
    I believe, this is only ui related and the old value which you got can be set in the IMPL class global variable and  trigger method set_on_close_event, say here 'CONFIRM_POPUP_CLOSED' as shown below:
      gr_popup->set_on_close_event( iv_event_name = 'CONFIRM_POPUP_CLOSED'
                                        iv_view = me ).
    Retrive the answer as per selection from popup in method 'CONFIRM_POPUP_CLOSED'
    by using:
      lv_answer = gr_popup->get_fired_outbound_plug( ).
    if lv_answer is NO, then put back the globally stored old value back to dropdown attribute, using:
    set_property_by_value method(   iv_attr_name = 'dropdown attr' iv_value = 'old value' )
    Thats it. No need to do anything.
    Regards,
    Bhushan

  • At selection-screen when user presses back button

    Experts,
    I have two radio buttons and two relative checkboxes ( one checkbox related to other ).
    Now when user selects one radio button and executes teh program, there is a summary page. When user presses back button from there, I return to the selection screen, however the selections are still there.
    Ideally I want a blank screen, as in nothing selected( similar screen when program is executed first ). Is it possible ?
    Kindly advise,
    Gols

    Hi,
    Try clearing radio buttons and check boxes at PBO of selection screen using AT SELECTION-SCREEN OUTPUT statement.
    PARAMETERS:
      p_rad1 TYPE c RADIOBUTTON GROUP rd1,
      p_rad2 TYPE c RADIOBUTTON GROUP rd1.
    PARAMETERS:
      p_chk1 TYPE c AS CHECKBOX,
      p_chk2 TYPE c AS CHECKBOX.
    AT SELECTION-SCREEN OUTPUT.
      CLEAR: p_rad1, p_rad2, p_chk1, p_chk2.
    Hope this helps.
    Regards,
    txhughes

  • Apply my own formula when user presses sum button in a report

    Hi all,
    I have this requirement that when user presses SUM button for a particular field in a report instead of Summing it up and displaying I can apply my own formula and display its value. 
    For Ex :  When we press sum button for field efficiency :
    EFFICIENCY
    10
    11
    05
    26 - It would sum it up and display 26 , where as i don't want it to display 26 i want to apply a separate formula and display that value

    Suggest to add another custom button to the ALV toolbar and write the desired logic you want.
    Also to avoid confusion, disable the standard summation button. (you can add the same icon for the custom button if you wish)
    Thanks,

  • I want to ask company when user update to ios7 it stuck all of device and not clearly about apple id to active how to solve it or just keep all of device into recycle because can not use?

    i want to ask company when user update to ios7 it stuck all of device and not clearly about apple id to active how to solve it or just keep all of device into recycle because can not use?

    You need to enter the Apple ID and password that was used to set up/activate the phone. There is no way around this.

  • I Have a UITableView with 17 row. in last 17Th row i applyed cell.selectionStyle = UITableViewCellSelectionStyleNone;  and in this row i also put UIButton with Image -  my QUESTION IS that i want in 17Th row when user tapped Image on button is hide and wh

    I Have a UITableView with 17 row. in last 17Th row i applyed cell.selectionStyle = UITableViewCellSelectionStyleNone;
    and in this row i also put UIButton with Image …
    my QUESTION IS that i want in 17Th row when user tapped Image on button. then Image is hide and when user again tapped then image is shown …
    so PlZ…help me how can i put logic..
    Thanks FrNdZZzzzz…

    Sign in:
    https://developer.apple.com/devforums/
    If you're not a developer, you need to join first:
    https://developer.apple.com/programs/register/

  • FIrefox Browser ZOOM problem- When I press the 9 number key FIrefox zooms out and when I press a 0 number key Firefox zooms in

    FIrefox Browser problem- Suddenly now when I press the 9 number key (or 6) FIrefox zooms out and when I press a 0 number key Firefox zooms in. This just started happening 2 days ago. I am using a Mac and I have the latest Firefox . No updates of any kind have occurred in the past 4-5 days, so I must have inadvertedly activated this.
    How can I deactivate this?
    Note to Mozilla support: Please do not close this thread- I believe that it most specifically pinpoints the actual problem
    that I am facing, so hopefully I can find others with a similar problem (& solution!)
    The older thread can be ignored/closed.
    Also- I tried to respond to 2 tech support emails that I received, but I was unable to do so.
    (

    Hi lachem, you can't reply by email, you need to return to your thread in order to post a reply. If you need a link: https://support.mozilla.org/questions/1050646
    I'm not a moderator, so I'll just list a link to the earlier discussion: [https://support.mozilla.org/questions/1050032 The Firefox "search for text when I start typing feature" has just stopped working correctly]

  • Preventing app exiting when user presses cross button

    Hello,
    I can't seem to prevent the whole application closing down when the user presses the cross button at the top of any of the forms. For example I have a menu form which I want to keep running whilst the user closes other forms which are shown from it.
    Any suggestions?
    Thankyou,
    Karsten

    I could be wrong, but I thought that the default
    behavior of a JDialog is to not close the whole app
    when it closes. Is that not correct?You are correct, sir. The only way an application closes is by explicitly telling it to do so by EXIT_ON_CLOSE.

  • Problem in displaying loginpage when user press logout

    Hi everyone, I am new to Swing and facing an issue which might appear simple to you people.
    I have a Login Screen. When user supply credentials and press the login button, the next page is displayed which has a logout button. If user clicks this logout button, ideally the login screen should come. I am struck up in implementing this functionallity. I'm attached SAMPLE Code for the same.
    // MainFrame.java
    import java.awt.Color;
    import java.awt.Container;
    import java.awt.Font;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowListener;
    import java.io.PrintStream;
    import java.text.SimpleDateFormat;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    public class MainFrame extends JFrame implements WindowListener{
        private static final long serialVersionUID = 1L;
         public static  String server_url = "t3://localhost:7001";
         public static  String JNDI_NAME = "com.qwest.bpm.designerserver.DesignerServerRemoteHome";
         static final String title_base = "MY App";
         PrintStream log;
         SimpleDateFormat df;
         public static JPanel current_page;
        String errmsg;
        public Color background;
        public Color color_tablehead;
        public Color color_canvas;
        Font font_textfield;
        String database;
        MainFrame(String title){
             super(title);
            System.setSecurityManager(null);
            setSize(900, 720);
              addWindowListener(this);
              rootPane.setDoubleBuffered(false);
              background = new Color(0.9f,0.9f,0.7f);
              color_tablehead = new Color(0.8f,0.8f,0.6f);
              color_canvas = new Color(0.97f,1.0f,0.97f);
              font_textfield = new Font("courier", Font.PLAIN, 12);
              setBackground(background);
              getContentPane().setBackground(null);
              log = System.out;
              df = new SimpleDateFormat("HH:mm:ss");
              setDefaultLookAndFeelDecorated(true);
            errmsg = null;
            database = "Oracle";
         public void setPage(JPanel page) {
              if (current_page!=null) current_page.setVisible(false);
              Container content_pane = getContentPane();
              if (!content_pane.isAncestorOf(page)) {
                   // System.out.println("Add page " + page.getClass().getName());
                   content_pane.add(page);
              page.setVisible(true);
              current_page = page;
            if (errmsg!=null) {
                JOptionPane.showMessageDialog(this, errmsg);
                errmsg = null;
         public void logout() {
              //Code to be changed here
           System.exit(0);
         public static void main(String[] args){
              MainFrame frame = new MainFrame("My App");
              frame.setPage(LoginPage.getPage(frame));
              frame.setVisible(true);
         public void windowActivated(WindowEvent e) {
              // TODO Auto-generated method stub
         public void windowClosed(WindowEvent e) {
              // TODO Auto-generated method stub
         public void windowClosing(WindowEvent e) {
              // TODO Auto-generated method stub
         public void windowDeactivated(WindowEvent e) {
              // TODO Auto-generated method stub
         public void windowDeiconified(WindowEvent e) {
              // TODO Auto-generated method stub
         public void windowIconified(WindowEvent e) {
              // TODO Auto-generated method stub
         public void windowOpened(WindowEvent e) {
              // TODO Auto-generated method stub
    //MainPanel.java
    import java.awt.BorderLayout;
    import java.awt.Color;
    import javax.swing.JPanel;
    public class MainPanel extends JPanel{
         public MainFrame frame;
         protected Color background;
         public MainPanel(MainFrame frame) {
              super();
              this.frame = frame;
              setLayout(new BorderLayout());
              setBackground(null);
    //LoginPage.java
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.AbstractButton;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JPasswordField;
    import javax.swing.JTextField;
    public class LoginPage extends MainPanel implements ActionListener {
         private static final long serialVersionUID = 1L;
         JTextField username, serverurl, servername;
         JPasswordField password;
         static LoginPage singleton = null;
         LoginPage(MainFrame frame) {
              super(frame);
              setLayout(null);
              JLabel label;
              JPanel panel = new JPanel(new GridLayout(2,2));
            panel.setLayout(null);
            panel.setBounds(100,100,200,200);
            panel.setBorder(BorderFactory.createTitledBorder("Credentials "));
            panel.setSize(600,350);
            panel.setOpaque(false);
              label = new JLabel("User Name");
              label.setBounds(60, 60, 120, 20);
              panel.add(label);
              username = new JTextField();
              username.setBounds(200, 60, 120, 20);
            //username.setActionCommand(C.ACTION_LOGIN);
              panel.add(username);
              label = new JLabel("Password");
              label.setBounds(60, 90, 120, 20);
              panel.add(label);
              password = new JPasswordField();
              password.setBounds(200, 90, 120, 20);
            password.setActionCommand("login");
            password.addActionListener(this);
              panel.add(password);
              JButton button_login = new JButton("Log In");
              button_login.setBounds(150, 240, 120, 25);
              button_login.setBackground(background);
              button_login.setActionCommand("login");
              button_login.addActionListener(this);
              panel.add(button_login);
            add(panel);
         static LoginPage getPage(MainFrame frame) {
              if (singleton==null)
                   singleton = new LoginPage(frame);
              return singleton;
         public void actionPerformed(ActionEvent e) {
             Object source = e.getSource();
             String cmd;
              if (source instanceof AbstractButton)
                   cmd = ((AbstractButton)source).getActionCommand();
            else if (source instanceof JPasswordField)
                cmd = "login";  
              else return;
              if(cmd.equalsIgnoreCase("login")) {
                   frame.setPage(NextPage.getPage(frame));
    //NextPage.java
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.AbstractButton;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JPasswordField;
    import javax.swing.JTextField;
    public class NextPage extends MainPanel implements ActionListener{
         private static final long serialVersionUID = 1L;
         JTextField username, serverurl, servername;
         JPasswordField password;
         static NextPage singleton = null;
         NextPage(MainFrame frame) {
              super(frame);
              setLayout(null);
              JLabel label;
              JPanel panel = new JPanel(new GridLayout(2,2));
            panel.setLayout(null);
            panel.setBounds(100,100,200,200);
            panel.setBorder(BorderFactory.createTitledBorder("Credentials "));
            panel.setSize(600,350);
            panel.setOpaque(false);
              label = new JLabel(" Hurray Login Successfull ");
              label.setBounds(60, 60, 120, 20);
              panel.add(label);
              username = new JTextField();
              username.setBounds(200, 60, 120, 20);
            //username.setActionCommand(C.ACTION_LOGIN);
              panel.add(username);
              label = new JLabel("Now try Logout ");
              label.setBounds(60, 90, 120, 20);
              panel.add(label);
              JButton button_login = new JButton("Log Out");
              button_login.setBounds(150, 240, 120, 25);
              button_login.setBackground(background);
              button_login.setActionCommand("logout");
              button_login.addActionListener(this);
              panel.add(button_login);
            add(panel);
         static NextPage getPage(MainFrame frame) {
              if (singleton==null)
                   singleton = new NextPage(frame);
              return singleton;
         public void actionPerformed(ActionEvent e) {
             Object source = e.getSource();
             String cmd ="";
              if (source instanceof AbstractButton)
                   cmd = ((AbstractButton)source).getActionCommand();
              if(cmd.equalsIgnoreCase("logout")) {
                   frame.logout();
    }

    solved it :)

  • Triggering POPUP to SAVE when user Presses BACK  Button

    h4.
    Hi Friends,
    h4.
    When the User Presses BACK Button in the PF Status, it should trigger POPUP_TO_CONFIRM  whether to SAVE or not.
    h4.
    Suppose if the user doesn't change any thing in the Screen, it should not ask the User.
    h4.
    How can i know whether the user changes something in the Screen.
    h4.
    Screen mean Table Control..
    h4.
    How can i track this.
    h4.
    Regards:.
    h4.
    Sridhar.J

    Hi Sridhar,
    Within the table control loop, create a chain of all the fields in the structure of line type. call a PAI module with addition ON CHAIN-REQUEST. This is a conditional module call which will be triggered ONLY when user changes something on the screen. In this module you can set a global variable DATA_CHANGED to say 'X'. When user chooses BACK function, check this global variable to decide on the confirmation popup.
    One small caution. If you have the ROW SELECTION field also included in the line type of your internal table associated with the table control, you need to exclude that from the CHAIN of fields above; otherwise even when user selects a line or de-selects, this module will be triggered.
    Read ON CHAIN-REQUEST and ON REQUEST online ABAP help for more clarity.
    Regards
    Suresh
    Edited by: Suresh Radhakrishnan on Sep 28, 2009 4:29 PM

  • How can I remove a hotkey in Firefox, I don't want anything to happen when i press ALT

    When I press ALT the menubar pops up, I use ALT as a PTT button so it is very annoying. I would like to customize the hotkeys for Firefox if possible.

    Anyone having the same problem as me, get this add-on [https://addons.mozilla.org/sv-se/firefox/addon/personal-menu/ Personal Menu]

  • Pause timer if user presses up or down key, resume when they don't

    I am running a routine set of activities with a timer in C#.
    public MainWindow()
    RefreshTimer();
    public void RefreshTimer()
    var refreshTimer = new Timer();
    refreshTimer.Elapsed += (sender, e) => RefreshPlotList(sender, e);
    refreshTimer.Elapsed += (sender, e) => RefreshWatchList(sender, e);
    refreshTimer.Interval = 2000;
    refreshTimer.Enabled = true;
    How would I pause the timer if the user presses the up or down key, and then resume it after the key action is done?

    Sorry for the slow reply ... I got busy with weekend stuff.  ;0)
    I'm assuming that the RefreshTimer() is only called once from the MainWindow (I should also mention that you forgot to start the Timer). And that's really all you need for that (create and start it once). However, I'd make the refreshTimer variable a class
    member/field, instead of local to the RefreshTimer() method. That way, you can access it from the KeyUp and KeyDown event handlers and don't even need the _upDownKeyIsPressed variable.  Like this:
    private System.Timers.Timer refreshTimer;
    public MainWindow()
    RefreshTimer();
    public void RefreshTimer()
    this.refreshTimer = new Timer();
    refreshTimer.Elapsed += (sender, e) => RefreshPlotList(sender, e);
    refreshTimer.Elapsed += (sender, e) => RefreshWatchList(sender, e);
    refreshTimer.Interval = 2000;
    refreshTimer.Start();
    private void KeyUpPress(object sender, KeyEventArgs e)
    if (e.Key == Key.Up || e.Key == Key.Down)
    this.refreshTimer.Enabled = true;
    Console.WriteLine(_upDownKeyIsPressed.ToString());
    private void KeyDownPress(object sender, KeyEventArgs e)
    if (e.Key == Key.Up || e.Key == Key.Down)
    this.refreshTimer.Enabled = false;
    Console.WriteLine(_upDownKeyIsPressed.ToString());
    ~~Bonnie DeWitt [C# MVP]
    http://geek-goddess-bonnie.blogspot.com

  • My 13" MBP will not shut down/restart because my Safari application will not close, even when i press "Quit"

    When i press the restart or shud down button, it says it cannot shut down because the safari application is not closed.  When i right clich the application adn press quit, it does not quit.  What can i do to fix this?

    Force Quit.
    Command + Option + Esc is the shortcut.

  • Do not find the option for windows when I press the the option key during restart, since I downloaded Lion

    I still do not find any option for windows when I restart my mac when pressing the option key.  It used to go to windows when I pressed the option key during a restart but since I have downloaded Lion, it always go to mac.  I do not want to make a permanent switch. ANy suggestions on how to get back to using the option key?

    You probably need to reinstall your Windows machine.
    I'm not certain, but I have a feeling the install of Lion wipes it out, going by the number of threads started along similar lines since Lion's release.

  • Flatten or Lock a fillable pdf when user presses submit button

    Hi.  I've been searching all over the net trying to figure this out.  I have a form that I created in LiveCycle and in the form I inserted a "REGULAR" button, with the following script:
    //Create a variable to hold the document object
    var 
    oDoc = event.target;oDoc.mailDoc({
    bUI
    : true,
    cTo
    : "[email protected]",
    cSubject
    : "New Procedure - Operator "+TextField1.rawValue+" - ID "+TextField2.rawValue,
    cMsg
    : "Attached is the New Procedure form for Operator "+TextField1.rawValue+" - ID "+TextField2.rawValue+".",
    This script is emailing to "[email protected]" and populating the subject line and body of the message with some text and some items from fields in the PDF.
    I want to have the PDF locked or flattened when the user hits the submit button, to ensure that the information put in the PDF isn't altered after they submit it.  I cannot find any way of doing this easily.  I found a script that will flatten the message (below), but I don't know how to add it to the email script I have noted above.  I don't want to add a second button to the form as I want to keep it as simple as possible for the user.
    Any suggestions someone might have would be greatly appreciated.  Thank you.
    Ryan

    The link at the bottom of the blog post takes you to Acrobat.com where you can download the file.
    Just tested it, the lin k is working fine for me.

Maybe you are looking for

  • Firefox won't allow me to print a Web Page. The only option I am given is to Save the Web Page as a PDF File .

    In FF 16.0.1 when I try to print a web page I get dialog box to save it as PDF. There is no other choice in the 'save as type' box. I do not want to save it; I just want to print it. This happens whether I use 'file/print' or the print button on FF.

  • Export from ALV to Excel - problem with numeric values

    hi folks, when exporting from alv to excel and we have negative values (and using an u.s.a. setting where . and , are different to r/3) negetive values are not shown correctly in excel. when changing in win nt the regional settings to europe one's (e

  • Regarding profitability rate

    i have to use the user exit named userexit_save_document . through this i have to block sales order ,which is having low profitability rate. and also i have to maintain the custom table  , one of the field is 'kbetr'. with the custom table field i ha

  • Using BT Infinity 2 with asus n55u

    Hi, I was looking everywhere for a solution to my problem, which is that i cant get a connection to my asus n55u router ive tried everything to get it connected to bt but to no avail does anyone have any info on how to get it connected?

  • Info required on Jheadstart

    Hello All, We need to migrate an application developed in oracle Forms to J2EE migration using Oracle-ADF. Major functionalities developed using Oracle forms and Java Swing. We need some input regarding 1)Pro and cons of Jheadstart as a migration too