New window in event handling

hi to all
i m beginner in java programming and i want to do event handling on mouse click. i have a button and i want if i click that button a new window open
can anyone help me

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ActionEvents implements ActionListener
    JDialog dialog;
    public ActionEvents(JFrame f)
        dialog = new JDialog(f, "dialog");
        dialog.getContentPane().add(new JLabel("hello world", JLabel.CENTER));
        dialog.setSize(200,100);
        dialog.setLocation(425,200);
    public void actionPerformed(ActionEvent e)
        if(!dialog.isVisible())
            dialog.setVisible(true);
        else
            dialog.toFront();
    private JPanel getPanel()
        JButton button = new JButton("open dialog");
        button.addActionListener(this);
        JPanel panel = new JPanel();
        panel.add(button);
        return panel;
    public static void main(String[] args)
        JFrame f = new JFrame();
        ActionEvents ae = new ActionEvents(f);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(ae.getPanel(), "North");
        f.setSize(200,100);
        f.setLocation(200,200);
        f.setVisible(true);
}

Similar Messages

  • First time data is not transported to pop up window through event handler

    Hi all,
    I am using NWDS 7.0, Now I want to open a pop up on click of a action link.
    There are two DCs DC-A and DC-B.
    I am calling action from DC-A to DC-B. DC-B contains view of pop up window.
    In DC-A I am using intreface controller of DC-B by using used coponents.
    Now In the DC-B used components I have created one fireplugin which is connected ith pop up view of DC-B and that firplugin is called from DC-A action to transport data from Dc-A to DC-B.
    Problem : when I click first time to open pop-up window then event handler is not called but the windows opened. When I close that window and again open the transported data start displaying on pop up window.
    So can you please help me that why first time data is not transported to pop up window.
    Thanks
    Kaushal

    You'll need to use an OARawTextBean. Oracle doesn't support opening links in new windows using OAFormattedTextBean. Just be aware that you'll need to set the CSS class in the HTML as well if you need it formatted a certain way.

  • Window: close event handler

    I have a button (action="dialog:ADD_MEMBER" useWindow="true" windowEmbedStyle="inlineDocument" windowModalityType="applicationModal" windowHeight="600" windowWidth="700"), which open a new window in the same TaskFlow. This window can be closed by using the special (my af:commandButton) button and by using common window close button ('X'). I want to write my custom close event handler in the second case. How can I do it?

    Hi,
    don't think you can. Did you check ifthe return listener fires ?
    Frank

  • I need a new window with a handle

    Hello,
    I am using the Win98 platform and need to create an empty window and
    retrieve its handle from within LV. I need this handle for a subsequent
    dll-call. Does anybody has a simple solution for this task?
    Thanks,
    Detlef

    > I am using the Win98 platform and need to create an empty window and
    > retrieve its handle from within LV. I need this handle for a subsequent
    > dll-call. Does anybody has a simple solution for this task?
    The VI Utilities on the NI ftp site and other ftp sites may be
    what you want, or you can just call system functions from a DLL
    node, actually called a Call Library Function.
    Greg McKaskle

  • How to open page in new window while handling event on link.

    Hi all
    I have a requirement where page should be opened in new window when I click on link.My item style is 'link'.Despite of mentioning target frame _blank, I m not able to open it in new window.I m handling event by setting Action Type as fireAction.I hope this might be the reason because of that this happened. Can somebody suggest some solution so that I can open it in new window.
    Thanks,
    Bhupendra

    Hi ,
    though i am not able to answer, i can get some answer for my question.
    How the link item is handled thru the ActionType and event in the Client Action..?
    The reason for this question is that we are trying to extend the customer search page in AR - EBSR12. there the search result page has the Account Name as a link and the Action event says viewAccountName and the action type says firePartialAction. I am trying to understand this so that i can add more parameters to the link so that i can use them in the target page of the link..
    Any help is appreciated..
    Thanks
    Chidam

  • Jvm unnamed windows events handle leak 1.3.1_08-b03 - 1.4.2-b28

    Hello,
    I have an server application that leaks windows unnamed event handles on small loads. (200 network connections) I've used the process explorer from www.sysinternals.com to find the type of handles that where leaking. I've run my application through jprobe several times and i'm not leaking any java objects. it doesn't happen on every run. It can run about 5 to 10 times with no leak but as i continue running a request that has 200 network connnections it will leak one handle. Over time they add up memory increases and eventually we get a out of memory error and the server has to be restarted
    My application uses the following
    java version "1.3.1_08"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_08-b03)
    Java HotSpot(TM) Client VM (build 1.3.1_08-b03, mixed mode)
    windows server 2000 service pack 3 (I've tried sp1 and sp2 same issue)
    starting and stopping threads
    inet jdbc driver una2000
    zlib compression libraries
    encryption DES
    sockets
    no jni code
    My network code uses input.available() and Socket.setSoTimeout() I don't think the setSoTimeOut time is timing anything out on these small runs.
    I've also have run it with
    java version "1.4.2"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
    Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
    I've tried not stopping any threads from my thread pool and it made no change. It still leaks! :-(
    Does anyone know what creates the unamed event handles? Are they created by synchronization? Since my applications uses so many different api's it's like looking for a needle in a hay stack.
    p.s. I've been working on this problem on and off for about 1 month. I've search the java forums and google.
    Thanks
    Alexander Anguiano

    My message has been here for a while and is off the first page. :-( Oh, well. I thought I would update this just incase anyone was following it. (can I award my self those duke dollars?)
    I think i've found the problem of why we are leaking handles. In the first 10 minutes it leaked 3 handles.(they may not have leaked but are resource that our application needed because of all the lazy initialization that we do) I've been runing a 200 task request every 5 minutes for the last 6 hours and have not leak any handles. The problem appears to be with calls to socket.setSoTimeout. I set it to 0. This effectively tells the socket to never time out. This is not an acceptable solution to the problem. I will be working on that next.
    Has any one had problems with the socket.setSoTimeout?
    If not then it may have to do with our simulated select. We have one thread that handles connection. Once the connection is established it's put on a list that get's polled [input.available()] that is handled by thread 2 if there is data then it gets handled by a worker thread [thread n-12]. Once the worker thread has read up to 4K of data it is put back on thread 2. I'm thinking that it has to do with so many thread doing a little work on it.

  • Opening a new window from an event handler in IC WebUI

    Hello ,
    I want to open a new browser window on the click of a button (through the event handler) .This can be done using javascript ,but I ideally want it to be triggered from the event handler .The URL is dynamically
    generated . Please do let me know if there are ways to achieve this .

    Hi,
    In the place where you declare your button write this code.
        ls_button-id = xx.
        lv_string1 = 'javascript:window.open( "'.
        lv_string2 = '" );'.
        ls_button-on_client_click = 'javascript:window.open( "lv_url");'
        CONCATENATE lv_string1
                    lv_url
                    lv_string2
                    INTO lv_string3.
        ls_button-on_client_click = lv_string3.
        ls_button-enabled = abap_true.
        APPEND ls_button TO gt_editbutton.
    pass your dynamic URL here to lv_url. Dont Pass anything to ls_button-on_click.
    You can do this coding in DO_PREPARE_OUTPUT or IF_BSP_WD_TOOLBAR_CALLBACK~GET_BUTTONS wherever your button is present.
    Regards,
    Masood Imrani S.

  • Event Handling - Swing Window to Console Switch

    I have a serious problem with an app I am writing - I have a swing 'main menu' system built around a standard JFrame which calls a new instance of another class. This other class takes input from the keyboard and is displayed in the standard console window; i.e Using the standard System.out.print() syntax.
    My problem is the Swing window will not release the input stream to allow the conole to take input from the keyboard. I have implemented inner-classes within the 'main menu's' class for event handling purposes; in this case the mouse-clicks of the menu's JButton components. The problem only manifests itself when the inner-class' event handling code is called - I wrote some test methods to call the console classes code without using the inner-class' and the console works perfectly. It is my conclusion, therefore, that the calling of the console-based method from within the inner-class of the Swing super-class reserves the input for the Swing components, failing to reactivate the console. I have tried creating new InputStream objects but to no avail.
    Does anyone know how to release or terminate the methods within the inner-classes (they are all void / no return type as they implement the ActionListener abstract class)? This, I hope, will return the focus to the console.
    Any advice would be most greatfully received.
    LEC.

    If you were to have your connection object declared so that it could be referenced from anywhere in your class then you could use it in you actionPerformed method. For example:
    public class Test extends JFrame
    &nbsp&nbsp&nbspprivate Connection con = null;
    &nbsp&nbsp&nbsppublic void actionPerformed(ActionEvent e)
    &nbsp&nbsp&nbsp{
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbspMyDetails appmydet = new MyDetails(con, id); //connection, userID
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbspappmydet.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
    &nbsp&nbsp&nbsp}
    &nbsp&nbsp&nbsppublic void setConnection(Connection theCon)
    &nbsp&nbsp&nbsp{
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbspcon = theCon;
    &nbsp&nbsp&nbsp}

  • Handling new window open with WebView

    Hi,
    I'm developing an app where I use webview to display a webpage. The webpage has a link where a file gets downloaded automatically when selected. What I'm trying to do is to get the link of the downloadable file and try to download it from my app. The problem
    I'm facing is that IE automatically opens whenever the downloadable link is pressed. I cant get event handler to detect this scenario. I've seen there could be a solution using Javascript but I dont know how to implement it. I found there is x-ms-webview.MSWebViewNewWindowRequested
    but this one is for Windows 10 only. I wonder if there is an alternative solution for WP8.1. Thanks

    Hi Rob,
    Now I've tried two solutions and none of them worked as expected. Here are the options
    1) In the WebView.NavigationStarted, I download the html content and then modify it to remove target=_blank which triggers opening a new window. I then call  WebView.NavigateToString to call the new html content. Looks like it works somehow but
    the reloaded page does not contain images, links, etc. Is there a way to fix this?
    2) I've tried the solution described in this link:
    http://stackoverflow.com/questions/18799534/notify-click-action-on-button-in-webview
    which is essentially injecting javascript code to handle button clicks.  The code looks like this:
    private void WebView_OnLoadCompleted(object sender, NavigationEventArgs e)
    webView.InvokeScript("eval", new[]
    "var loginButon=document.getElementById(\"login\");" +
    "if (loginButon.addEventListener) {" +
    "loginButon.addEventListener(\"click\", clickFunction, false);" +
    "} else {" +
    "loginButon.attachEvent('onclick', clickFunction);" +
    "} " +
    "function clickFunction(){" +
    " window.external.notify('loginClick');"+
    However, I get error when the code executes webView.InvokeScript (Execption:0x80020101). Do you have any idea why?
    Kind Regards

  • A message will pop up (Exc in ev handl: Error: Bad NPObject as private data!) and the tab I was on will close out and reopen in a new window. Why is it happening and how do I stop it?

    Okay, I will have a window open with 4 tabs open. At first, everything is fine, but after a day or so, a message will pop up on screen saying "'''Exc in ev handl: Error: Bad NPObject as private data!'''" and after you close it out, the tab you were on will close and reopen in it's own window. I then have to shut down all both old and new windows and open a new window with my original 4 tabs again. It will work fine until a few days pass and it starts over again.

    This issue can be caused by the McAfee Site Advisor extension
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • Creating a new window from and action event

    Hey I have a problem i would like most of my menu items to create a new window containing a set text and i was thinking of creating a new container with a JTextArea but for some reason its not working. if someone could help me that be great... so my question is how do create another window (TextArea) with my tokenized array info in it open up when Print File or Print Total is the event??
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    import java.util.StringTokenizer;
    import javax.swing.plaf.*;
    class PhoneProject extends JFrame implements ActionListener
         private static final int WIDTH = 260;
         private static final int HEIGHT = 160;
         private static final int X_ORIGIN = 402;
         private static final int Y_ORIGIN = 299;
         ArrayList internalCalls = new ArrayList();
         ArrayList externalCalls = new ArrayList();
         PhoneCall internal;
         PhoneCall external;
         JMenu query = new JMenu("Query");
         JMenu proccess = new JMenu("Proccess");
         String inRecord;
         int numExtension;
         int numCallType;
         int numSeconds;
         int totalIntTime;
         int totalExtTime;
    public static void main(String args[])
              PhoneProject frame = new PhoneProject();
              frame.setVisible(true);
    public  void LoadArray(File myFile) throws IOException
              FileReader fr = new FileReader(myFile);
              BufferedReader br = new BufferedReader(fr);
              while ((inRecord = br.readLine()) != null)
                   StringTokenizer tokenizer = new StringTokenizer(inRecord);
                   String extension = tokenizer.nextToken();
                   String callType = tokenizer.nextToken();
                   String seconds = tokenizer.nextToken();
                   numExtension = Integer.parseInt(extension);
                   numCallType = Integer.parseInt(callType);
                   numSeconds = Integer.parseInt(seconds);
                   if (numCallType == 0)
                        internal= new PhoneCall(numExtension, numCallType, numSeconds);
                        totalIntTime = (totalIntTime + numSeconds);
                        //System.out.println(totalIntTime + "int");
                        internalCalls.add(internal);
                   if (numCallType == 1)
                        external = new PhoneCall(numExtension, numCallType, numSeconds);
                        totalExtTime = (totalExtTime + numSeconds);
                        //System.out.println(totalExtTime + "EXT");
                        externalCalls.add(external);
                   System.out.println(internal.getSeconds());     
         public PhoneProject()
              Container contentPane;
              setBounds(X_ORIGIN, Y_ORIGIN, WIDTH, HEIGHT);
              setTitle("Phone Analyzer");
              setResizable(true);
              contentPane = getContentPane();
            contentPane.setLayout(new BorderLayout());
              JMenu file = new JMenu("File");
              JMenuItem  item;
              item = new JMenuItem("Open");
              item.addActionListener(this);
              file.add(item);
              item = new JMenuItem("Exit");
              item.addActionListener(this);
              file.add(item);
              proccess.setEnabled(false);
              item = new JMenuItem("Print File");
              item.addActionListener(this);
              proccess.add(item);
              item = new JMenuItem("Print Totals");
              item.addActionListener(this);
              proccess.add(item);
              item = new JMenu("Low and High");
              item.addActionListener(this);
              proccess.add(item);
              JMenuItem subItem = new JMenuItem("Compare");
              subItem.addActionListener(this);
              item.add(subItem);
              query.setEnabled(false);
              item = new JMenu("Average Total Utilization");
              item.addActionListener(this);
              query.add(item);
              JMenuItem itemInt = new JMenuItem("Internal");
              itemInt.addActionListener(this);
              item.add(itemInt);
              JMenuItem itemExt = new JMenuItem("External");
              itemExt.addActionListener(this);
              item.add(itemExt);
              item = new JMenuItem("Highest Internal Utilization");
              item.addActionListener(this);
              query.add(item);
              item = new JMenuItem("Highest Total Utilization");
              item.addActionListener(this);
              query.add(item);
              JMenuBar menuBar = new JMenuBar();
            setJMenuBar(menuBar);
            menuBar.add(file);
            menuBar.add(proccess);
            menuBar.add(query);
              contentPane.add(new JTextArea("Phone Report"));
      public void actionPerformed(ActionEvent event)
           String menuName;
           menuName = event.getActionCommand();
           if (menuName == "Open")
                JFileChooser chooser = new JFileChooser();
                int returnVal = chooser.showOpenDialog(this);
                if (returnVal == JFileChooser.APPROVE_OPTION)
                     try
                        File myFile = chooser.getSelectedFile();
                        this.LoadArray(myFile);
                        proccess.setEnabled(true);
                        query.setEnabled(true);
                     catch (Exception e)
         if (menuName == "Print File")
    JTextArea display = new JTextArea();
              display.setText("Hello");testing to see if it works
              display.setVisible(true);
         if (menuName == "Print Total")
                                               JTextArea display = new JTextArea();
              display.setText("Hello");//testing
              display.setVisible(true);
           if (menuName == "Exit")
                System.exit(0);
    }Phone.txt
    2000 0 300
    2000 0 538
    2000 1 305
    2000 1 729
    2005 0 205
    2005 0 305
    2005 1 592
    2005 1 594
    2010 0 364
    2010 0 464
    2010 1 904
    2010 1 100
    2020 0 234
    2020 0 839
    2020 1 999
    2020 1 210
    Assignment: Array Based GUI Assignment
    Telephone call data has been collected from a company's telephone switch. You have been asked to analyze it and produce various statistics.
    Input File
    The input file is a sequential file. It is in no specific order. The file contains an extension number, type of call, and the length of call in seconds. A record is produced each time a call is made from that extension. You should create your own test file.
    Field     Type     Description
    Extension     Integer     Extension number. This is a 4 digit number. Valid Extensions are 2000 to 2020.
    Type     Integer     Value of 1 means internal, any other value is an external call.
    Time     Long     Length of call in seconds
    Example:
    �     2000,1,60 : ----->>>> Extension 2000 had an internal call that lasted 60 seconds
    �     2000,1,356: ----->>>> Extension 2000 had an internal call that lasted 356 seconds
    �     2019,2,65: ------>>>> Extension 2019 had an external call that lasted 65 seconds
    �     2001,1,355: ----->>>> Extension 2001 had an internal call that lasted 355 seconds
    Process
    1.     Use 2 arrays to accumulate the time of calls for each extension, both internal and external.
    2.     The reports and queries are to be produced from the arrays.
    Hints:
    �     Create 2 arrays: one for internal calls and one for external calls.
    �     Load the arrays in Form Load: do not do any calculations here.
    �     The report and queries can totally be produced from the arrays.
    Output: Report
    Telephone Useage Report
    Extension Internal External
    2000 4500 3500
    2001 19350 22981
    2002 2333 900
    2003 3144 122
    Totals 99999 99999
    Output: Queries
    On the form add add query capability.
    1.     Average Total Utilization: Internal Calls: 9999 (total length of all internal calls / number extensions)
    2.     Average Total Utilization: External Calls: 9999
    3.     Extension with the highest internal call utilization: Ext xxxx; 9999 seconds.
    4.     Extension with the highest total utilization.
    Form Design
    The design of the form is up to you. However, use the following guidelines:
    �     use menus (preferred) or command buttons
    �     use a common dialog box to ask for the file name
    �     use a list box or text box to display the output
    the caption on the form should include your name

    hi
    u can try like following code
    if (menuName == "Print File")
              new mytextframe();
    class mytextframe extends JFrame{
         JTextArea display = new JTextArea();
         public mytextframe()
              setSize(300,300);
              setVisible(true);
              add(display);
              display.setText( "ello");
    }

  • SRW.SET_HYPERLINK - Handle SPACE in filename AND open in NEW WINDOW

    Report 10g (10.1.2.3.0 - 32bit on Windows 7 64bit)
    Issue #1:
    using srw.set_hyperlink to get a handle on *.pdf file on remote server. Report is launched as PDF. PDF that is opened via the URL launches in same window as report. I need run report as PDF, click hyperlink to get handle on another file which should launch in New Window.
    SRW.SET_HYPERLINKATTR only useful with HTML and HTMLCSS. Javascript? If so, sample code?
    Issue #2:
    possible that file retrieved will have spaces in its name. Hyperlink defaults %20 in the spaces of the name, but the link does not successfully retrieve file. Tried replacing spaces w/ %20, but like defaults does not retrieve document; due to actual file name not having the %20 in its actual name. Is there are way to account for the spaces in the URL then "remove" them to find the correct file and open in new window?
    Tried using virtual path as well as physical path.
    Help with either or both issues is truly appreciated,
    Thanks!!

    Hello,
    When you set the property "Hyperlink", the property "Additionnal Hyperlink Attributes (HTML)" is displayed. Set this property to :
    target="_blank"
    Regards

  • Event handler if new File added in current folder

    Hi folks,
    I'm just trying to write a little jsx script for Bridge CS6.
    How can I implement an event handler that will react if the user adds a new thumbnail (new file) to the current folder in bridge.
    I've tested it with this code, but it doesn't work:
    app.document.thumbnail.watch ("children", function(id, oldVal, newVal) {
         $.writeln (oldVal + " to " + newVal);
         // some code here
    Thanks. Greetings

    Beautiful. Works as advertised. Thank you for pointing it out to me. Unfortunate that a basic subset of this extension's behaviour doesn't ship with Thunderbird out of the box, though.

  • Error in event handler method in window

    Hi,
    I have created configuration in SEFVISU, to receive the workitem i have created a parameter in event handler method in window
    but it is throwing dump The ASSERT condition was violated, if i remove that parameter means application executing properly but i am not able to pass the unique, values please guide me.
    Regards,
    Srini.

    Hello Srini,
    are you talking about the default event handler method of the window? if so then you need to ensure that the parameter name defined in the event and passed in name are same. And also its better to go for the parameter type as STRING.
    other option would be instead of defining the static parameters in the event handler method, you can get the parameters from the WDEVENT itself by accessing WDEVENT->PARAMETERS table.
    hope this helps.
    BR, Saravanan

  • Event Handling - New Approach

    Hi,
    I have developed a BSP and implemented the way Brian described in the Apprach 3 of the weblog mentioned below. In the method of new class that handles the server event(method name is same as server event), How do I access the model instance that I used in my BSP?
    BSP Programming: Handling HTMLB Events
    /people/brian.mckellar/blog/2004/07/28/bsp-programming-handling-htmlb-events
    Thanks,
    Suresh

    Brian it's Good Idea to create in Controller Class or creating event handling methods within the model class. But I would like to create s separate class just for Even handling alone, so that I can use wherever I want(in different BSP Applications).
    1.I have created ZCL_EVENT_HANDLER_FORME.
    2.Created Method HANDLE_MYBUTTONCLICK and passed
      event_object as a parameter.
    3. I have ZCL_MY_CONTROLLER and ZCL_MODEL for BSP.
    4. Created instance of ZCL_MODEL and assigned it to the Controller Attribute.
    5. Successfully dispatced the event from DO_HANDLE_EVENT to HANDLE_MYBUTTONCLICK method of CL_EVENT_HANDLER_FORME.
    6. I don't know how to get the reference to the model in
    HANDLE_MYBUTTONCLICK method of CL_EVENT_HANDLER_FORME.
    Am I missing some thing....
    -Suresh

Maybe you are looking for