Using a frame to call a frame

Hi,
I am currently writing a program where, at one point, the main program (an applet) calls another window with a popup question. The user is to answer a question (it's multiple choice, so checkboxes are used) and I would like a score value to be returned to the main applet. I have heard of things like JDialog stuff, but I wish to look for any alternative method other than anything too advanced. I was thinking of writing a value into a textfile and then reading the textfile from the main applet, however, for some reason the program freezes when this happens. If you have any suggestions as to what i can do please reply asap. Thanks

Actually, when it comes to something not too advanced, trying to use a text file probably doesn't qualify. The thing is, Java applets are executed in a sandbox inside the browser, and typically not allowed to wander around outside of it. Which means that, unless you specifically assign permissions otherwise (which qualifies as "advanced"), your applet probably doesn't have access to the user's file system.
Much simpler would be to use a field. Now, I hate public fields, so I'd use a private field and a public accessor. A field like theAnswer, with an accessor like setTheAnswer, that your popup window calls just before it closes. That way, you don't have to step outside of the sandbox.
Sincerely,
Dylan

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

  • Call a frame with variable/dynamic number of Textfields

    Hi to all,
    I would like to call a frame using a button that has a number of Textfields previously determined.
    Lets say I have frame1 with a textfiled and a button, and frame2. How can I call frame2 using the button to be opened with a number of textfields defined in the textfield of frame1?
    Thanking in advance
    Sotirios

    I am getting all these errors when trying to run my application
    java.lang.NullPointerException
         at MC_SIM.defXGroups.jbInit(defXGroups.java:38)
         at MC_SIM.defXGroups.<init>(defXGroups.java:22)
         at MC_SIM.PhantomDef.jButton1_actionPerformed(PhantomDef.java:122)
         at MC_SIM.PhantomDef_jButton1_actionAdapter.actionPerformed(PhantomDef.java:134)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
         at java.awt.Component.processMouseEvent(Component.java:5134)
         at java.awt.Component.processEvent(Component.java:4931)
         at java.awt.Container.processEvent(Container.java:1566)
         at java.awt.Component.dispatchEventImpl(Component.java:3639)
         at java.awt.Container.dispatchEventImpl(Container.java:1623)
         at java.awt.Component.dispatchEvent(Component.java:3480)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
         at java.awt.Container.dispatchEventImpl(Container.java:1609)
         at java.awt.Window.dispatchEventImpl(Window.java:1590)
         at java.awt.Component.dispatchEvent(Component.java:3480)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

  • Can java be called as frame work

    I just want to know what is the exact definition of frame work. can java language or any other language can be called as frame works. if so why?
    if not why not? if any one have a clear idea. pls define and help me in having a better idea. thank you.

    Well, I would agree with you conclusion that a language by itself can't be called a framework. If you goal is to improve your communication, I would suggest you make good use of capitalization and use proper English instead of words like "pls".
    *The criticism is meant to be helpful.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Using session storage between Report and Frame Driver

    I have an existing report that has a link calling a frame driver with multiple forms. I would like to make the Initial Target Frame Content dynamic based on information contained in the targeted record of the report. I am able to make this work (in basic concept) on the frame driver side, but have not been able to pass session variables from the report side. I can, of course, pass bind variables via a link from the report. Does anyone know of a way to access the parameter bind varaiables in the frame driver component using session storage or something else in order to make these variables available to the PL/Sql of the Initial Target Frame?
    Message was edited by: PM
    user477244

    Seems that session is changed during logon or even if
    web page (where the servlet is located) is refreshed!In Portal 10g (and maybe even in 9.0.2.6) the Web provider session is not lost any more when the user logs in to Portal.
    PL/SQL doesn't lost the session storage data during
    logon. But is it possible to find Java session storage
    from PL/SQL session storage?No, you cannot share the session between database and Web providers. You need to find other ways to share information between portlets belonging to different providers. You can use parameter passing, or a persistent store, such as the database.
    Java session storage doesn't use domain name or
    subdomain which are mandatory for PL/SQL session
    storage.The domain, sub-domain strings are irrelevant, as long as you can uniquely identify your session variable. For example, if you want to make sure that you have a separate session variable for every portlet instance, you should include the preference path in your domain or sub-domain. In case you want to share the session store between your portlets, don't include the unique portlet ID.
    Peter

  • I want to play video on my computer to make some analysis to frames,the problem that I face ,I can't change video frame rate using labview,but I can change frame rate to the video out of labview using some program

    HI All
    I want to play video on my computer to make some analysis to it's frames,the problem that I face ,I can't change video frame rate using labview,but I can change frame rate to the video out of labview using some program .
    I used IMAQ AVI Read Frame VI
    for example I have avi video It's frame rate is 25 fbs ,my image processing code is very fast that can process more 25 fbs,so I want to accelerate video acquisition

    Hi abdelhady,
    I looked into this further, and reading an AVI file into LabVIEW faster than its frames per second won't be possible. LabVIEW could read in frames faster than 25fps, but because it will be pulling the available frame at that point in time this would just give you duplicate frames. If you want to be able to read in frames at faster than 25fps, you would need to speed up your AVI file before reading into LabVIEW.
    There's a good shipping example to show how to read in from an AVI file, "Read AVI File.vi". You'll notice that they add timing to make sure that the while loop runs at the right speed to match up with the frames per second of the file being read. This is to make sure you're not reading duplicate frames.
    Thank you,
    Emily C
    Applications Engineer
    National Instruments

  • Call details frame from master frame in report 10g

    Hi
    I have i am using oracle 10g reports
    i have two frame one for State master(Main Frame Name : M_G_state_name,Repeatig Fram name : G_State)
    and other for city master(Main Frame Name : M_G_city_name,Repeatig Fram name : G_city)
    in state master frame two feild State code and State Name and in city Master Frame three feild as city_code,city_name,State_code
    i want that when i click on State_code of State master Frame then it show City details city master Frame of selected state.
    i have no idea how can do these.please help me
    thanx in advance

    Hello,
    http://www.oracle.com/webapps/online-help/reports/10.1.2/topics/htmlhelp_rwbuild_hs/rwwhthow/whatare/reports/webrpt/fa_hyperhtml.htm
    Reports output in HTML format can include the following types of Web links:
    A link from an object to another object within the same report, or to another HTML or PDF document (a hyperlink).
    Regards

  • Some of my rotation animation is stepping at about one degree increments instead of tweening smoothly.  I'm using classic tweening.  I see that if I select the whole interval and use F6 to convert every tween frame to a key and then select the object at t

    Some of my rotation animation is stepping at about one degree increments instead of tweening smoothly.  I'm using classic tweening.  I see that if I select the whole interval and use F6 to convert every tween frame to a key and then select the object at the different frames, that I see under transform that the skew values are changes from frame to frame aroung that same one degree range.  Is there a solution to this?

    Some of my rotation animation is stepping at about one degree increments instead of tweening smoothly.  I'm using classic tweening.  I see that if I select the whole interval and use F6 to convert every tween frame to a key and then select the object at the different frames, that I see under transform that the skew values are changes from frame to frame aroung that same one degree range.  Is there a solution to this?

  • Using addEventListener for Enter and Exit frame

    hi , sometimes i want to set some function in specific frame in start and exit this frame
    for example i have Flv player in frame 20 , i have background sound ( mp3 player ) so i want when swf goes to this frame my sound goes Off and when Exit from it and go to another frames the sound played again ...
    i put these script in frame 20 :
    addEventListener(Event.ENTER_FRAME,enterfunc);
    function enterfunc(e:Event):void {
        trace("I started");
    addEventListener(Event.EXIT_FRAME,exitfunc);
    function exitfunc(e:Event):void {
        trace("will Exit");
    but after test movie i see I started and will Exit runs Repeatly without stoping !!
    Notice : first i put my sndChannel = soundClip.play; and sndChannel = soundClip.stop;  but my music runs over and over and finally my system Hanged and need to Restart so i use trace to see
    so whats a problem ?  thanks for spending time and help me

    kglad wrote:
    // in frame 1:
    function f():void{
    trace("function f is executing when the playhead is in frame:", this.currentFrame);
    // in frame 2:
    f();
    This works well For Excute Function on entering Frame Once !! thanks ...
    but Only 1 More Question :
    as You told me in your No.2 Replay :
    I try to add some movieclip with instance name Or FLv playback with instance name and then Try to use this codes :
    mymc.addEventListener(Event.ADDED_TO_STAGE, addedF);
    function addedF(e:Event):void{
    trace("I Start");
    mymc.addEventListener(Event.REMOVED_FROM_STAGE, removedF);
    function removedF(e:Event):void{
    trace("I exit");
    why The removedF function Works well and the addedF function not work ?!?   in fact nothing Happend on Enter This Frame but on exit i see my I exit Trace !!

  • Help, on calling another frame

    I am doing a program which start with a frame. Where is a button, by clicking it, another window may popup to show some running msg of the main window. I decide to use two frames to do that. One is the main window and another one will be visible when that button is clicked. Now my problem is the second window(frame) did come up, but the JTextArea inside it is not been displayed. There is one time that the second window displayed its content when some process in main window throws exceptions. I have no idea what I did wrong.
    second window:
    public class networkConnect extends JFrame {
        public JLabel msgLbl;
        public JTextArea msgArea;
        public networkConnect()
            Toolkit kit = Toolkit.getDefaultToolkit();
            Dimension screenSize = kit.getScreenSize();
            int screenHeight = screenSize.height;
            int screenWidth = screenSize.width;
            msgLbl = new JLabel();
            this.msgArea = new JTextArea(30,50);
            this.msgArea.setEditable(false);
            this.getContentPane().add("Center", new JScrollPane(msgArea));
            this.setTitle("Connection Message");
            this.setSize(150,70);
            this.setLocation(screenWidth/4,screenHeight/4);
            this.pack();
            this.show();
    }In main window:
    networkConnect netConnect = new networkConnect();
    netConnect.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    netConnect.setVisible(true);
    netConnect.......Thank you!!

    for instance:
    import java.awt.*;
    import javax.swing.*;
    public class NetWorkConnect
      private static final Dimension PANEL_SIZE = new Dimension(250, 170);
      private JPanel mainPanel = new JPanel();
      private JTextArea msgArea = new JTextArea(30, 50);
      public NetWorkConnect()
        msgArea.setEditable(false);
        mainPanel.setPreferredSize(PANEL_SIZE);
        mainPanel.setLayout(new BorderLayout());
        mainPanel.add(new JScrollPane(msgArea), BorderLayout.CENTER);
      public JComponent getComponent()
        return mainPanel;
      public void appendMessage(String message)
        msgArea.append(message);
      public void clearMsgArea()
        msgArea.setText("");
    import java.awt.*;
    import java.awt.Dialog.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class NetWorkConnectMain
      private JPanel mainPanel = new JPanel();
      private JTextField textfield = new JTextField(20);
      private NetWorkConnect netConnect = new NetWorkConnect();
      private JDialog dialog;
      private JButton appendTextBtn;
      public NetWorkConnectMain()
        JButton showNetConnectBtn = new JButton("Show NetConnect");
        appendTextBtn = new JButton("Append Text to NetConnect");
        textfield.setEnabled(false);
        appendTextBtn.setEnabled(false);
        showNetConnectBtn.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent arg0)
            showNetConnectAction();
        appendTextBtn.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent arg0)
            appendTextAction();
        mainPanel.add(showNetConnectBtn);
        mainPanel.add(textfield);
        mainPanel.add(appendTextBtn);
      private void showNetConnectAction()
        if (dialog == null)
          Window windowAncestor = SwingUtilities.getWindowAncestor(mainPanel);
          dialog = new JDialog(windowAncestor, "Connection Message", ModalityType.MODELESS);
          dialog.getContentPane().add(netConnect.getComponent());
          dialog.pack();
          dialog.setLocationRelativeTo(null);
          dialog.setVisible(true);
        else if (!dialog.isVisible())
          dialog.setVisible(true);
        appendTextBtn.setEnabled(true);
        textfield.setEnabled(true);
      public void appendTextAction()
        if (dialog != null && netConnect != null)
          netConnect.appendMessage(textfield.getText() + "\n");
      public JComponent getComponent()
        return mainPanel;
      private static void createAndShowUI()
        JFrame frame = new JFrame("NetWork Connect Main");
        frame.getContentPane().add(new NetWorkConnectMain().getComponent());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      public static void main(String[] args)
        java.awt.EventQueue.invokeLater(new Runnable()
          public void run()
            createAndShowUI();
    }

  • How to call main frame from showMessage OK button clicked?.

    hello,
    I create one project. there, I create one textfield and button. after clicking it, the input add into JList.
    when I click the list component and enter OK button ,it will go to another window.
    When the input is fault, it show error in dialog box. then, when i click the OK button, it must go to main window and processed from first.
    My problem is,
    When I click OK in show dialog box, it is not going to main frame.
    if((source==ConnectButton) != firstSel)
                String message="Not Able to Connect to the Specified IP !!!";
              int answer = JOptionPane.showConfirmDialog(MainFrame.emsMainFrame, message);
              if (answer == JOptionPane.YES_OPTION) {
                  initcomp();
                   MainFrame.setSize(750, 550);
                   // Image icon = Toolkit.getDefaultToolkit().getImage("Images.gif");
                    //emsMainFrame.setIconImage(icon);
                     emsMainFrame.setVisible(true);
                     emsMainFrame.setEnabled(true);
                      initSNMPlogin();
                    // BroIPSelect.setVisible(true);
                    // BroIPSelect.setEnabled(true);
            // workPanel.add();
            //   JPanel cp = new JPanel(new GridLayout(0,3));
              workPanel.setVisible(true);
            workPanel.add( new JLabel( "work" ) );
           // leftPanel.setVisible(true);
          else if (answer == JOptionPane.NO_OPTION) {
            // User clicked NO.
                  System.exit(0);
        }        To go to main frame and access , what can I do.
    thanks.

    Wow that's a mess.
    Normally when you want to go back to your main window, the only thing you have to do is hide your second window. Then the focus automatically returns to your main window.
    Hiding a frame is calling setVisible(false) on it.
    If you keep a reference somewhere to your hidden frame, you can easily show it up again without rebuilding it.
    But post some other code.
    What is "MainFrame"?
    Is it a class with static methods for accessing MainFrame.emsMainFrame?
    Note that objects/instances/variables/references should start with a lowercase letter, and classes should start with an uppercase letter.
    Why do you call initcomp()? If it is a function for initialising the GUI components, then make it run once at the start of your program.
    Why do you have this XOR:
    ((source==ConnectButton) != firstSel)

  • How call a frame from a Servelt please

    how call a frame from a Servelt please

    hi, you can output a javascript that calls a frame as follows
    PrintWriter out=response.getWriter();
    out.print("<script>");
    out.print("window.frames['frameName'].functionCall();");
    out.print("</script>");
    good luck

  • Calling other frames/classes

    let's say i have 2 frames..frame 1 and 2
    frame 1 have a button, when clicked, it will dispose() and show frame 2.
    how do i show frame 2?
    i did a JFrame frame = new frame2();
    but it couldn't run..

    can you tell me what you did that..is possible give the code how u did it

  • Frame drivers - control of frame?

    I have a frame driver which calls a form. The form is based on a procedure.
    From within the procedure I call the frame driver again.
    In Webdb22 I was able to control the frame names, and targets, and thus could get the 2nd call of the frame driver to display in the same place the when called the 2nd time as the first.
    In Portal30 I don't see a way to set frame names for frame drivers.
    1) is there a way that I can name the frames?
    2) if not, how can I call the frame driver from PL/SQL with one of the standard targets (_blank, _parent, etc.).
    Thanks,
    Bob

    Stephanie,
    Frame Driver can be used without rendering it as portlet. I am giving you a simple example:
    Say you have four charts:
    1) Chart_1, 2) Chart_2, 3) Chart_3, 4) Chart_4
    You can create a frame driver "Chart_Frame" as:
    Select 'Chart 1' Chart, 'Schema1.chart_1.show' url from dual
    union
    Select 'Chart 2' Chart, 'Schema1.chart_1.show' url from dual
    union
    Select 'Chart 3' Chart, 'Schema1.chart_1.show' url from dual
    union
    Select 'Chart 4' Chart, 'Schema1.chart_1.show' url from dual
    Now create a site "Site1".
    Add an item of type "URL" with url as: http://machine name:port/pls/portal dad/schema1.Chart_Frame.show
    You can set "Link That Displays Item In New Browser Window"
    I hope you can use it like this.
    Thanx,
    Chetan

  • Addressing the Frame in an extended Frame

    I wrote some nice code bringing my Frame to the Exlusive Fullscreen Mode. Since I want to put all the methods like "renderSprite" or "showBuffer" into on package, I tried the following:
    public class ExclFrame extends Frame implements MouseListener, MouseMotionListener, MouseWheelListener
    /* All kinds of variables and functions*/
         public ExclFrame(GraphicsConfiguration graphConf)
              gc = graphConf;
              addMouseListener(this);
              addMouseWheelListener(this);
              this.createBufferStrategy(2);            /* Evil line */
              BufferStrategy bufferStrategy = getBufferStrategy();
    }When I try to let that run, it tells me that in the /*Evil line*/ I need a valid peer. It worked fine, as long as I used a plain Frame and had frame.createBufferStrategy(2);. After changing it to that package, I don't know how to "address the Frame" of my extended Frame. Shouldn't be that problematic, I guess...
    Many thanks in advance,
    G :-)

    well, you can call show on super, if that's where you want it, or you can call show on "this", cuz if you haven't overridden show it'll call it on the super class anyway... Just be careful with that if you end up overriding the show method on your own later for something. Don't know about the undecorated thing... although I don't think that has any use whatsoever in full-screen mode anyway.

Maybe you are looking for