Opening a frame with button click

hi all
when i am going to click a button which is placed in JTabel it should
open a JFrame with some component.
thanks & regards
daya

This task can be decomposed in two logically unrelated subtasks:
1: Adding a button in a table column and listening to it
2: Showing a frame from some method
In case you are hesitant how to solve the first task: you need to create your own cell editor (possibly by extending DefaultCellEditor) that returns a button as editor component. Of course this editor must be set to the desired column(that must be editable too). And just listen to that button's actions.
Another possible solution is to just render the column with a button and listen the table for mouse clicks, then determine the ros/column for the click and act correspondingly.
The solution of the second task depends entirely on you.
HTH
Mike

Similar Messages

  • Professional way to call that frame on button click?

    Hi
    Nice to get new look and feel for forum :)
    Wel my question is I have a frame which has many buttons textfields labels and other components too.
    On clicking one of the button I am opening a frame which is like calculator(display is same as calculator)
    I am using frame for that calculator.
    My question is that what will be the most professional way to call that frame on button click?
    All you java professionals your kind attention will be appreciated
    Regards

    Good question, I've often wondered this myself!
    Personally, I don't like to use anonymous inner classes for handling events. I generally handle events two ways:
    1. Make the main class implement lots of interfaces and use action commands. eg
    public class MyFrame extends JFrame implements ActionListener {
        public static final String CALC_BUTTON = "cb";
        public MyFrame() {
            super();
            JButton cButton = new JButton("Calculator");
            cButton.addActionListener(this);
            cButton.setActionCommand(CALC_BUTTON);
        public void actionPerformed(ActionEvent ae) {
             if (ae.getActionCommand().equals(CALC_BUTTON) {
                 //do something
    2. Subclass AbstractAction.
    public class MyAction extends AbstractAction {
        //create a constructor specific to the goal
        public MyAction(/*Some arguments*/) {
            //set  variables
        public void actionPerformed(ActionEvent ae) {
             //handle the action
    //and in the main class
    JButton cButton = new JButton("Calculator");
    cButton.setAction(new MyAction());I tend to use the first method more often, but if there's some specific kind of action, then I use the second method.
    I'm interested to know what other people do though. :)
    -Muel

  • Putting frame with buttons into a thread

    please help!!!
    i've got a thread:
    package aJile;
    import java.io.*;
    import java.net.*;
    public class SocketHandler extends Thread
      private Socket socket;               // Socket used for messages 
      private int socketNr;
      private byte[] inbuf;
      private InputStream in;
      private OutputStream out;
      public SocketHandler(Socket socket)
        this.socket = socket; 
      public void send(String str) throws IOException {
           out.write(str.getBytes(), 0, str.length());
           out.flush();              
      public String receive() throws IOException {
           int numBytes = in.read(inbuf);
          String str = new String(inbuf, 0, numBytes);
          return str;
      public String switchOn() throws IOException {
           send("1");
           String state = receive();
           return state;
      public void run()
        try {
          // set up the input and output streams
          in  = socket.getInputStream();
          out = socket.getOutputStream();
          inbuf = new byte[128];
          receive();
         // System.out.println(switchOn());     
          in.close();
          out.close();
          socket.close();
          System.out.println("closing");
        catch (Exception e)
          System.out.println("Caught exception "+ e);
    }and i want to add a frame with buttons to this thread. that everytime tread starts, this frame would appear. and that methods of the thread would be called with a button press. How to join them?
    here is a frame:
    package buttons;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Frame3 extends JFrame implements ActionListener
         JPanel pane = new JPanel(); 
         Icon lightIcon = new ImageIcon("light.gif");
         Icon darkIcon = new ImageIcon("dark.gif");
         JButton pressme = new JButton("Press Me");
         JButton ironButton = new JButton("Iron",lightIcon);
         JButton lampButton = new JButton("Lamp",lightIcon);
         JButton ovenButton = new JButton("Oven",lightIcon);
         public Frame3()  
              super("Event Handler Demo"); setBounds(100,100,300,200);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Container con = this.getContentPane(); // inherit main frame
              con.add(pane);
              pressme.setMnemonic('P');
              pressme.addActionListener(this);   // register button listener
              ironButton.addActionListener(this);
              lampButton.addActionListener(this);
              ovenButton.addActionListener(this);
              pane.add(ironButton);
              pane.add(lampButton);
              pane.add(ovenButton);
              pane.add(pressme);
      public void actionPerformed(ActionEvent event)
        Object source = event.getSource();
        if (source == pressme){     
          JOptionPane.showMessageDialog(null,"Hello!","Message Dialog",
          JOptionPane.PLAIN_MESSAGE);
        if (source == ironButton){
             if (ironButton.getIcon() == lightIcon){
                  ironButton.setIcon(darkIcon);               
             else ironButton.setIcon(lightIcon);
        if (source == lampButton){
             if (lampButton.getIcon() == lightIcon)
                  lampButton.setIcon(darkIcon);
             else lampButton.setIcon(lightIcon);
        if (source == ovenButton){
             if (ovenButton.getIcon() == lightIcon)
                  ovenButton.setIcon(darkIcon);
             else ovenButton.setIcon(lightIcon);
      public static void main(String[] args){
           Frame3 app = new Frame3();
           app.setVisible(true);
    }thank you

    could you tell me how to avoid exceptions?
    what i want to to is to call a method wich simply sends a string and gets a string back.
    public String switchOn() throws IOException {
           send("1");
           String state = receive();
           return state;
      }but when i call this method in actionPerformed() i get exceptios and my socket closes. It sends the string though, but after this program crashes. is there anything special to do if i want to use this Frame3 in order to communicate with a client by pressing buttons?

  • Open PDF document with a click of a button

    Hello All,
    I am trying to open a pdf document which is located on the Unix server when a button is clicked. The Button is of Item Style 'Button', the file is at a location for example /tmp/user/.
    Can anyone please suggest with some already existing examples. I looked for a few in the OTN forums but everything was pointing to involving BI Publisher. But my requirement is to open an already existing document with a click of a button.
    Please suggest.
    Thanks
    Kris

    Wahid,
    Thanks, the button is not only opening the document but before that the button click should merge the Pdf documents into one. The PDF merge is happening, but when I have a URL in the button its killing the merge functionality.
    I used the HttpServletResponse and servletoutput stream to open the merged PDF document. Its working on my local machine, I need to try it on the server.
    I was trying to use the XMLIMporter command to upload the OAF oage which already exists in the server. But this did not work for me. Since I am new to OAF may be Im missing something. Below is the XMLIMporter command.
    java oracle.jrad.tools.xml.importer.XMLImporter SearchPG.xml -username apps -password pwd -dbconnection " (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostname.com)(PORT=1111))(CONNECT_DATA=(SID=ora_sid)))" -rootdir $JAVA_TOP -rootPackage /Server/apps/comn/java/classes/customDir/module/page/webui/
    The Search Page is in /customDir/module/page/webui/ this folder. Is Framework bounce needed in this case.
    Thanks again.
    Kris

  • Open Dialog box on button click using Visual Webpart

    Hi,
    I am trying to create New Item,Edit Item & Delete Item button in Visual web part.On clicking on the button it should open the corresponding custom form on dialogue box.I don't want to create any button in the ribbon.I just want to create UI page for
    all buttons and also corresponding input forms on button click in Visual web part.
    Is it possible through visual web part?
    I will be needing your initial guidance to achieve this.
    Please help.
    Thank you.

    Hi,
    According to your post, my understanding is that you want to open modal dialog in a visual web part.
    To open a modal dialog, there are multiple ways, such as using JavaScript.
    However, for your scenario, you should register the script from the C# code, there are some articles for this topic, you can refer to them.
    http://www.ashokraja.me/articles/How-to-Programmatically-Show-or-Hide-a-Modal-Popup-Dialog-with-Server-Side-Code-in-Share-Point-2013
    http://blogs.perficient.com/microsoft/2012/01/sharepoint-2010-closing-a-modaldialog-manually-from-code-c-and-javascript/
    More reference:
    http://blogs.msdn.com/b/chaks/archive/2011/09/14/modal-dialog-box-in-sharepoint-sandbox.aspx
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Open a report from button click/javascript

    Hi,
    Does anyone know if there is a way to call a report from a button click? Or through javascript? I set the report to Display Results > Link - within the dashboard and then did a view source on it and found the function that calls the report from the hyperlink.
    This is the code:
    return DashboardReportLink('saw.dll?PortalGo&_scid=v-x8QJloqTY&PortalPath=/shared/Plan\x2520Setup\x2520Audit\x2520Tool\x2520/_portal/Plan\x2520Setup\x2520Audit&Page=Historical&NavFromViewID=d\x253adashboard\x257ep\x253acp4tq3p9brn77o6o\x257er\x253a8a2g9nltmkrtra9n&Path=/shared/Plan\x2520Setup\x2520Audit\x2520Tool\x2520/Archive\x2520Reporting/Run\x2520Historical\x2520Report&Action=PromptStart&Options=frdc', 'd:dashboard~p:cp4tq3p9brn77o6o~r:8a2g9nltmkrtra9n','Dashboard&PortalPath=/shared/Plan\x2520Setup\x2520Audit\x2520Tool\x2520/_portal/Plan\x2520Setup\x2520Audit&Page=Historical', false)
    I added this function to the end of my javascript but when i click the button it just opens a blank page with
    http://la820119:9704/analytics/saw.dll?PortalGo
    as the url.
    Any help would be appreciated

    Hi,
    So i have been trying out a few things and the following url works to open the default view of the request:
    window.location='saw.dll?Go&Path=/shared/Plan Setup Audit Tool /Archive Reporting/Run Historical Report&Options=dfr';
    I just replaced 'Dashboard' in the code provided with the 'Go' and it started to work :)
    What i need to do though is have this work for the session variables set up on the dashboard. I have 7 prompts which a user can use to filter a request. Each is assigned to a session variable that is used to call a stored procedure. Originally i thought that by setting the variables and then calling the report from the url that the session variable values i set would be used in the request. What seems to be happening is that the variables get set and then, on calling the url, they are reset to the defaults and the report is run.
    Any help in solving this would be very much appreciated
    Una

  • Opening new window on button click from pdf without loosing session

    Hi,
    In my Java web applicaion on click of a link, we are opening a new window in which we are displaying a pdf. There are 5 buttons on this pdf.
    On clicking of this button again we are opening a application link in new window. But in this window we are not gettting our session, which is there in first two window.
    For opening new window from pdf button click we are using
    var dynamicUrl3 = myappurl;
    app.launchURL(dynamicUrl, true); 
    How can i open new window with the same sesion from the pdf button.
    Please help for the same.
    Thanks,
    Abhijit Mohite.

    Yes, with target="_blank" in a link or a form.Thanks for ur valuable suggestion. I changed the button to link.
    Its working fine now without JavaScript.
    Now i got another requirement. When user select some items and press a button in the new popup window, the window must close on button click and the parent window must refresh. This must also be done without using JavaScript.
    Is this possible? Please give me an idea to do this.
    Thanks.

  • Loading movie clip to stage with button click AS3

    I'm trying to figure out how to load a movie clip to the stage with a button click and have the movieclip close again using a close button. Does anyone have a step by step on how to do this or links to some tutorials.
    Below is an example of what I'm trying to do.

    Alrighty I changed the publish settings to as3. I'm still getting two errors:
    Scene 1
    1046: Type was not found or was not a compile-time constant: Popup1Btn.
    Scene 1, Layer 'as', Frame 1, Line 3
    1061: Call to a possibly undefined method addEventListener through a reference with static type Class.
    So my setup on my main timeline is I have an actionscript layer with this code now:
    var popup1:Popup1
    Popup1Btn.addEventListener(MouseEvent.CLICK,addF);
    ClosePopup1.addEventListener(MouseEvent.CLICK,closeF);
    function addF(e:MouseEvent):void{
    popup1=new Popup1();
    addChild(popup1);
    function closeF(e:MouseEvent):void{
    removeChild(popup1);
    popup1=null;
    On the stage I have a button with the isntance/AS linkage name Popup1Btn. Inside my Popup1 MC I have a box with text and then a button with the instance/linkage name ClosePopup1 to close the popup.
    What am I missing?

  • Play Audio On Webpage With Button Click

    Hello everyone. I'm new to Flash, so please bear with me.
    I'm creating a language learning website, and wish to add
    audio to it for all vocabulary words. I want the audio to be
    compatible across browsers and simply play when a button is
    clicked, without any controls or media players opening up.
    From what I hear, it sounds like Flash is a good way to go
    and would do the trick. It's just a matter of converting all the
    mp3s to Flash. The mp3 file size is already relatively small (1-2
    seconds in length each and about 30kb in size I believe).
    How could I create a button that plays the mp3 when it is
    clicked? I was
    researching the topic and came across a few things.
    What I am looking for is almost identical to this:
    Site
    demonstrating audio buttons
    While I could jump right in and use her example, it doesn't
    quite work. With hers, everything needs to be in different folders,
    and I would need a different button - her's is a little big. I
    can't put everything in different folders, because I will have
    hundreds of audio files. It would be much easier to put them all in
    an audio folder with different filenames.
    I also was reading at another site that it deals with
    Javascript controlling the Flash - when you click the button it
    plays the swf file. Since I am very new to Flash, I'm not exactly
    sure of what all it can and cannot do. The site also mentioned not
    all browsers allow Javascript to control Flash files. Again,
    however, I'm unsure of how accurate the information still remains.
    The browsers were older versions, and they were talking about how
    to do it in Flash 5 and Dreamweaver 4. Furthermore, the example
    located at the above link does not use any Javascript.
    Does anyone have any ideas on how I can do this? While I am
    beginning to learn Flash, I doubt I will understand what to do all
    on my own for a while, and I need to get the site finished as soon
    as possible. The audio is practically all that is left before the
    site launch. Like I said, I'm looking for a way to add audio to a
    webpage, that is played (without media players opening up, etc)
    with the push of a button, and also will load quickly, since there
    were be about 20 audio files per page.

    Here is some info on sound linkage, not sure if this is what
    you want but its a start:
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=194&threadid =1208568

  • Help in connecting between two frames using button click

    hi all
    am a student doing my final year project work. i would like to know how to redirect from frame to frame. like in the button click i should get redirected to a new frame. please help........
    Message was edited by:
    jayalekshmy.r

    thanks for the reply. in sockets the previous frame wil be there after redirection. i dont want tht frame to be there. i only want the new frame to be displayed after redirection. how can i do the same so. plaese help

  • Open system form on button click

    Hello Expert,
    How to open system form(invetery transfer from) on button click
    Regards,
    Abhinav Lalpurwala

    Hi Abhinav
    Try This.....
    'In Button pressed event
       sbo_application.ActivateMenuItem("3080") 'For Inventory Transfer form
    Thanks
    Shafi

  • Changing JPanel with button click.

    Hi, I have a class call TOC(Table of Content) which contains all the buttons. One class call MainController. All buttons I add an actionListener which the MainController class will handle. Anothe class which is the main one which contain a JPanel.
    When I click on the button in TOC class, it will go through the MainController class and display the respective JPanel associate with the button.
    Now the problem is how do I change the JPanel in the main class with a click on the button in TOC class?
    Please advise. Thanks in advance.

    Not sure what you mean exactly. However,
    Assuming that your view class is a JPanel, when you create your controller,
    ViewPanel view = new ViewPanel();
    MainController controller = new MainController(viewPanel);
    In MainController track a reference to your viewPanel. Also in viewPanel have a method called setCurrentPanel(JPanel panel). then int he controller's action listener
    public void actionPerformed(ActionEvent ev) {
    JPanel pnl = (JPanel) panelMap.get(ev.getSource().getName());
    viewPanel.setCurrentPanel(pnl);
    I am assuming you have a way of mapping each button to the panel it will use, which is what is in the panelMap. The viewPanel can have a CardPanel layout for the panels it displays and its setCurrentPanel, can bring to front/oradd the specified panel.
    Good luck, hope this helps :-)

  • Opening signature dialogue with a click on a button

    Hi all,
    I have a simple question,
    How is it possible to open the signing dialogue (like when you click on the signature field) from another button.
    I mean - I have a simple test form with one button and one signature field and I want to open the signing dialogue when I click the button - not the signature field.
    Hope you understand what I am trying to do?
    Cheers
    Kim Christensen
    Dafolo A/S
    Denmark

    Hi Shai,
    Following are the details
    VC Server Version 700.15.0.1.
    We are using version 7.0.
    Regards
    Joga

  • Avoid opening new window on button click

    Hi All,
               I have created BSP pages with flow logic.
    I have the following pages :
    main.htm
    selection.htm
    details.htm
    I have embedded selection.htm and details.htm  in main.htm
    In selection.htm page I have button .On clicking this button, it opens a new window and displays details there. However , i dont want the new window to be opened . The details should be displayed in the details.htm within the same window.
    Here is how i have written the code for button in selection.htm page :
              <ht mlb: butt on id      = "submit"
                            d esign  = "emphasized"
                            te xt    = "<%= otr(zdfps_google/submit) %>"
                            on Click = "submit"
                            toolt ip = "Update Map" />
    How can I avoid opening of a new window onclick of the button(submit buttton)?

    Hi,
    If a new window is opening, I think this is because you specify a target value in your form tag that does not correspond to an existing frame or window. For example:
    <htmlb:form id="details_form" target="details">
    This submits the form in a frame or window with name "details". If it does not exist, a new window shows up.
    If you want to submit your form to page details.htm, in the same window, you can use the following:
    <htmlb:form id="details_form" action="details.htm">
    Note that the target attribute is not specified.
    Hope it helps!
    Regards,
    Tanguy

  • Opening New Window on button click

    Hi all,
    On click of a <h:commandButton> i want to display a new window which is containing datatable. Is there any possible way to do this with out using javaScript? Is there any possible way of doing it inside bean?
    If javascript is the only way tell me how to do that.
    Thanks...

    If you want to do it without Javascript, use links instead of buttons. A bean or a servlet cannot push a new window. Using Javascript it's fairly simple:onclick="window.open('foo.jsp');"

Maybe you are looking for