Opening a frame from an applet

Hi,
I want to open a frame in my applet. If I'm using swing, JApplet opening a JFrame, is it possible to keep the frame open if the user browses away from the page that holds the applet?
Are there any tricks? I've tried opening it in a new Thread, but it still goes away when the the browser's page changes.
Could I call getParent() from the applet until I get an instance of Frame (which would be the browser) and set my JFrames' parent? Or does that only work with the old Netscape and old AWT Frames?
I basically want to know if I can keep my JFrame open until the browser is closed. Any ideas or suggestions would be greatly appreciated.
thank you very much

Do you want to open a jsp application in a frame when you click on the applet?If so, there is a programme in http://www.globalleafs.com -Java-Java Applets 's download section. Check it out.

Similar Messages

  • [NEWBIE] How to open a frame from an Applet?

    Hi, I'm trying to open a JFrame from an Applet. Basically, I would like that, once the user selects an option from a JMenu, a Frame would be shown with a text box where user could type some content.
    I built both the Applet and the Frame, and singularly they work. When I execute the main method from the JFrame, the window appears, but when I execute something like the following from the applet:
    MyFrame mf = new MyFrame();
    mf.setVisible(true);nothing is shown. I'm sure that I don't know something, but I just started with applets.
    Thanks for any help,
    Marco

    If MyFrame is a subclass of JFrame, then it should not
    make any difference.
    What do you need the JFrame for? Can this be done
    using another "screen" by using a CardLayout?From a menu, when the user selects 'Start game' I need a text box coming out so that the user can insert a word. This word should then evaluate an instance member of the Applet.
    Marco

  • Help! How to Open a Frame from applet with

    Hey all. I need help =).
    I want:
    1. Have 1 class extends applet with running thread (this far no prob)
    2. Open a new frame from the applet (no prob)
    3. Start a new thread which is operating "inside" the new Frame/class
    4. Draw a simple Rect in the new Frame with the new thread to test that the graphics work.
    Plz help,
    ~Trobsky

    �rr..... i cant draw on the Frame =(.
    Heres the code:

    public class Fonster extends java.applet.Applet {
         Frame myFrame;
         Fri friFonster=new Fri();
         public void init() {
              myFrame=new Frame();
              myFrame.resize(300,300);
              myFrame.show();
              myFrame.add(friFonster);
              friFonster.init();
              friFonster.start();
         public void paint(Graphics g)
              g.drawRect(10,10,100,100);
    public class Fri extends java.applet.Applet {
         public void init(){
              repaint();
         public void paint(Graphics g)
              g.drawRect(10,10,200,200);

  • Opening frames from an applet

    Me and a friend are making an applet, and would like it to open a new frame at some point.
    It works perfectly* on his WIN 2k IE 5.0 but somehow it does not on my WIN 2k IE 6.0
    Is it no longer legal to open new windows from an applet?
    Thanks.
    *Except for the warning. Btw, is that warning removable?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    If the window doesnt show up, you might have an exception thrown somewhere. I assume you are using a Java Plug-In since you are using IE6.0. You can bring up the java console, if you open the Java Plug-In icon in the Control Panel and enable "Show Java Console". Restart your browser and try again and see if you are getting a stacktrace in the java console.You can also see what version of java you are using in the control panel, or change it in the Java Plug-In options (Advanced tab) if you have more than one installation installed.

  • Opening a browser from an applet

    I got a problem, I want to open a browser from my applet, but I just found one way:
    getAppletContext().showDocument(new URL(
    "http://www.java.sun.com"), "_blank");
    but the problem is: with this, the default browser with defaul settings is opened, and that's what I don't want...
    how can I open the browser with some settings (for example size, or no-url-bar, etc)
    thx for help

    hi,
    try this code:
    public void showDocument(java.net.URL url, String targetWindow)
    when targetWindow can be:
    "_blank" Display the document in a new, nameless window.
    "windowName" Display the document in a window named windowName. This window is created if necessary.
    "_self" Display the document in the window and frame that contain the applet.
    "_parent" Display the document in the applet's window but in the parent frame of the applet's frame. If the applet frame has no parent frame, this acts the same as "_self".
    "_top" Display the document in the applet's window but in the top-level frame. If the applet's frame is the top-level frame, this acts the same as "_self".

  • Opening a socket from an applet

    I tried to open a socket from an applet to a server on a remote computer and I've got a refusal message.
    When I try it on a server in the local machine, it works.
    What could be the problem ?
    P.S. : when I open the socket from an application in the Java environment, to the same remote server it works ok.

    this is part of the security system built into java and Applets
    unless you sign an Applet it cannot do many "dangerous" things, like..
    access the loacl file system
    connect to any server except the server that it came from

  • Opening and closing a frame from an applet security problem

    can I open a frame or a window from an applet and close the frame by using
    System.exit(0) for the frame or will it throw a security problem.

    I am using system.exit(0) to exit the JVM.
    dispose()
    Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. That is, the resources for these Components will be destroyed, any memory they consume will be returned to the OS, and they will be marked as undisplayable.
    If this frame have to be close and open again don't use dispose.
    there is no check whether a frame is active? what you can do is set the the new frame to null (frame = null) and also when you dispose it, this will let you know if the frame is active or not.
    Noah

  • Opening a jsp from an applet in a frame?

    this is the code i'm using to open a new jsp and send some stuff in the header. it works fine but it does not support the frameset i am using... any ideas how i can open this page in the frame?
    thanks
    URL url = getCodeBase();
    try{
    getAppletContext().showDocument (new URL (url+"AcceptHousePos.jsphouse="+myHouse.getString()));
    catch(MalformedURLException e) {
    showStatus("URL not found");

    Do you want to open a jsp application in a frame when you click on the applet?If so, there is a programme in http://www.globalleafs.com -Java-Java Applets 's download section. Check it out.

  • Open a JFrame from an applet

    I have an applet in which I have a JButton.
    When you click the button, I want a new window to open with a JFrame. Is that possile?
    I've written as follow but nothing happens when I click the button.
    1. In the applet, I've written:
    public class MyApplet extends Applet {
    if (e.getActionCommand() == myButton) {
    frame.getContentPane().add(new Blabla(), BorderLayout.CENTER);
    2. In the frame, I've written:
    public class Blabla extends JFrame {

    Thanks.
    Now a new window is opened when I click the button, but it's empty....
    In the frame I have a container, is that a problem? I don't know where to put "your":
    "getContentPane().setLayout(new BorderLayout());"
    I've written:
    public class Blabla extends JFrame {
    boolean inAnApplet = true;
    private boolean laidOut = false;
    private JButton b1, b2, b3;
    private JLabel fnamn;
    public Blabla() {
    Container contentPane = getContentPane();
    contentPane.setLayout(null);
    b1 = new JButton("some text");
    contentPane.add(b1);

  • Opening a frame inside IE applet (window)

    I have an applet whih creates an instance of a frame .. the frame opens up in a separate IE window .. is there a way for the frame to overlay the applet window or is the nature of the frame always going to force a new window to open .. thanks to all who reply in advance

    If you want the frame to overlap the applet, don't use a frame but a panel.
    Kind regards,
      Levi

  • Open web pages from an applet

    I'm developing an applet that has to open some web pages.
    The only way I know is to use the method showDocument that
    needs and URL. So, how to pass parameters to the web page?
    I don't want to put them in the URL: everyone can see
    "secret data"!
    Help me, please.

    Take a look at this example that uses a JEditor pane to hold the HTML page.
    //Create a new JEditor Pane
    jep = new JEditorPane( );
    //Ensure the pane is not editable
    jep.setEditable(false);  
    //Use this to get local HTML file
    URL fileURL = this.getClass().getResource("Manual/Manual.htm");
    //add the html page to the JEditorPane
    jep.setPage(fileURL);Ok the core line of code here is this.
    URL fileURL = this.getClass().getResource("Manual/Manual.htm");The standard method for accessing a html file via a URL is thus. As you can see its very similar.
    URL fileURL = new URL("http://www.comp.glam.ac.uk/pages/staff/asscott/progranimate/docs/Manual/Manual.htm");this.getClass().getResourse() will return the file location of the class you are working with.
    By doing the following you can access manual.html in a folder called Manual that sits in the same file location as the class file you are using.
    URL fileURL = this.getClass().getResource("Manual/Manual.htm");I hope this helps.
    Andrew.

  • Opening a frame from a button

    Can some one help me figure out how to get a frame to open ferom a button with input. here is the source code where it would be used.
    // Programmer:     AISC AM Programming class
    // Jan. 22, 2004
    // DiseaseSim2 driver to test out People class
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class DiseaseSim2 extends JApplet implements ActionListener
    int i,r,numPeople=100,diameter=10;
    int mx,my;
    int lenghtOfIllness = 15;
    boolean sick;
    Person[] people = new Person[numPeople];
    Rng randn = new Rng();
    Locator datastore = new Locator();
    JButton pressButton = new JButton("Move Folks Around");
    public void init()
    Container con = getContentPane();
    con.setLayout (new FlowLayout());
    con.add(pressButton);
    pressButton.addActionListener(this);
    //CREATE PEOPLE OBJECTS AS AN ARRAY
         for(int i=0;i<numPeople;i++)
    people[i] = new Person(randn.getR(100,400),randn.getR(100,400));
    //SLOW DOWN PROCESS FOR RANDOM NUMBER SEED distinction
    pause(13);
    //MAKE ONE PERSON SICK INITIALLY
    r=randn.getR(1,numPeople);
    people[r].setSick(true);
    public void actionPerformed(ActionEvent e)
    Object source = e.getSource();
    if(source == pressButton)
    repaint();
    public void paint(Graphics gr)
    setBackground(Color.blue);
    pressButton.repaint();
         //ERASE PREVIOUS POSITIONS
    for(i=0;i<numPeople;i++)
    gr.clearRect(people.getx(),people[i].gety(),diameter,diameter);
    //Locator CALL
    datastore.setNumPeople(numPeople);
         datastore.contaminate(people);
    //MOVE PEOPLE
    for(i=0;i<numPeople;i++)
    mx = randn.getR(-100,100);
    my = randn.getR(-100,100);
              people[i].move(mx,my);
              //Make red or green
         sick = people[i].getSick();
         if(sick)
              gr.setColor(Color.red);
    //INCREMENT DAYS SICK
    people[i].countDaySick();
         else
              gr.setColor(Color.green);
         gr.fillOval(people[i].getx(),people[i].gety(),diameter,diameter);
              //MAKE PEOPLE WELL (NOT SICK)
              if(sick && people[i].getDaySick() > lenghtOfIllness)
              people[i].setSick(false);
    people[i].setDaySick(0);
    //REQUIRED METHOD FOR PAUSE
    void pause(int time)
    try{ Thread.sleep(time);}
    catch(InterruptedException e) { }

    &#91;code&#93;public void actionPerformed(ActionEvent e)
        Object source = e.getSource();
        if(source == pressButton)
            JFrame jf = new JFrame("My New Frame!!!");
            jf.setBounds(200,200,200,200);
            jf.setVisible(true);
    }&#91;/code&#93;
    Isn't code easier to read with &#91;code&#93;&#91;/code&#93; blocks around it?

  • How do I open a url from an applet?

    is it done the same way with HTTPUrlConnection as with an application or is it done in a different way? I'm getting a "ClassCastException"

    Now I'm trying to call a CGI script and past things in through the post method... I still get a ClassCastException. This exact same code worked in the applet, once again. here is the code I am using:
                   URL url = new URL ("http://address.pl");
                   HttpURLConnection cxn = (HttpURLConnection) url.openConnection();
                   cxn.setRequestMethod("POST");;
                   cxn.setUseCaches(false);
                   cxn.setDoOutput(true);
                   cxn.setDoInput(true);
                   ByteArrayOutputStream bytes = new ByteArrayOutputStream(400);
                   PrintWriter writer = new PrintWriter (bytes,true);
                   writer.print("hello=world&food=good");
                   writer.flush();
                   cxn.setRequestProperty("Content-Length",String.valueOf(bytes.size()));
                   cxn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
                   bytes.writeTo(cxn.getOutputStream());

  • Open Frame from MainFrame Menu item

    I created new Frame, and I want to open this frame from Main Frame menu item.
    Help me

    You should add an action listener to the Menu Item. In the action listener's actionPerformed(ActionEvent) method, call your frame's setVisible(boolean) method.
    //frame setup
            JFrame mainFrame = new JFrame("main frame");
            final JFrame otherFrame = new JFrame("second frame");
            mainFrame.setSize(400,400);
            otherFrame.setSize(200,200);
            //menu setup
            JMenuItem item = new JMenuItem("Open my special frame");
            JMenuBar bar = new JMenuBar();
            JMenu menu = new JMenu("menu");
            bar.add(menu);
            menu.add(item);
            mainFrame.setJMenuBar( bar );
            mainFrame.setVisible( true );
            //here's the important part
            item.addActionListener( new ActionListener()
                @Override
                public void actionPerformed(ActionEvent e)
                   otherFrame.setVisible(true);
        }

  • Print HTML doument without open it from an applet

    I need to know how I can print an HTML document from an applet developed with Jbuilder 4. I'm not a very expert developer and I need a detailed information about this problem. Important is that the HTML document is printed without open it.
    I use: win 2000 pro
    J2RE 1.4.0
    thanks in advance for your help
    Mauro Losa

    Thanks for your help but my problem is that i want print the document without display it.
    I think to have find a solution using Java Print Service API (JDK 1.4) but when i run the example the system display this error refered to this instruction
    "PrintService[] pservices = PrintServiceLookup.lookupPrintServices(flavor, aset);":
    java.lang.UnsatisfiedLinkError: getDefaultPrinterName
    at sun.print.Win32PrintServiceLookup.getDefaultPrinterName(Native Method)
    at sun.print.Win32PrintServiceLookup.getDefaultPrintService(Unknown Source)
    at sun.print.Win32PrintServiceLookup.getPrintServices(Unknown Source)
    at sun.print.Win32PrintServiceLookup.getPrintServices(Unknown Source)
    at javax.print.PrintServiceLookup.getServices(Unknown Source)
    at javax.print.PrintServiceLookup.lookupPrintServices(Unknown Source)
    at untitled4.applet1.main(Applet1.java:32)

Maybe you are looking for

  • MIRO Split out line item based on different tax amounts

    Hello Friends, We have a scenario where we get different tax rates related to the same line item quoted on the invoice which we receive from the vendor. The split out of the line item amount into different tax rates is not known at the time of bookin

  • Problem linking css style sheet

    I am trying to link a css style sheet to a new root file. When I try to link the css sheet I get an error - A recursive style import was found while trying to add CFTtemp.css. Please resolve this error by editing the file in an external text editor a

  • License Server: IP Address for Virtual Server

    Hi everyone, Our license server is installed at 192.168.1.5 : 30000.  Our internal network is able to access the server.  Some SAP Business One client are located remotely so they must connect to server through VPN in which the VPN service provided u

  • Still Monitor in Yellow

    Hi i Ran the Init. Delta without Data transfer from ODS to other ODS and Cubes. In Manage Data Target it showing Green Symbol(No Report Symbol) , But in Monitor still it is in Yellow for long time , please some tell me how would i proceed further Ver

  • Battery efficency problems- fully charged laptop shuts down unplugged HELP

    I Have Asus x54H,windows 7 for 2 years now( warranty conveniently just expired) and for month or so,everytime i turn it on after~ 15 min it shuts down by itself.Battery is fully charged,but sometimes when i click on its icon it shows something like 7