Opening a web page in an applet
Some may recognize this as I have posted it before and got nowhere. So I decided to post it again to see if anybody could help me. I have made a few changes to my code, but no guarantees it's better.
public class FinalWindow extends Applet
private AppletContext appContext;
public void init()
java.net.URL url;
appContext = this.getAppletContext();
try
url = new java.net.URL("http://www.google.com");
} catch (Exception e)
System.out.println("Didn't work.");
url = null;
System.out.println("this");
try
if(url != null)
getAppletContext().showDocument(url, "_self");
//appContext.showDocument(url, "_self");
} catch (Exception e)
System.out.println("Error loading page.");
public static void main(String[] args)
FinalWindow fw = new FinalWindow();
fw.init();
}I have to things that i tried to use to show the web page in the applet, but they both produce NPE saying:
Exception in thread "main" java.lang.NullPointerException
at java.applet.Applet.getAppletContext(Applet.java:187)
at FinalWindow.init(FinalWindow.java:84)
at FinalWindow.main(FinalWindow.java:107)Let me know what ya'll think.
wythe25 wrote:
No, I don't want the page to load in the browser window, I want it to load in the applet, as I said before.Your showDocument commands above would result in the target page replacing the page the applet is in, rather than opening the target page inside the applet.
To load a document inside the applet, might be achieved by using a JEditorPane to contain the HTML, then simply calling JEP.setPage(URL). Two things about that though:
1) An applet will need to be trusted in order to load documetns from foreign hosts.
2) Google frowns upon people reading their pages into any bot or software other than a standard browser.
I defined the main() method because that is the way I know how to do it. I'm not worried about having a main() in it right now. You should be. Combined applet/applications do make some sense during development - I do them quite often. But you need to realise that an applet launched that way will not be able to use the kind of things an embedded applet can normally expect to be able to access, such as the AppletContext. (1)
..I just can't figure out how to load a web page in an applet.
Basically making a web browser out of an applet that loads the page I tell it to in the code.JEditorPane (with a HyperlinkListener), trusted applet, not Google. And in fact, though the JEP is getting better over time, it is not generally considered to be good enough to use as the basis for a 'real world (wild web)' browsing component.
Edit 1:
(1) Having implemented a basic AppletContext for Appleteer , I can tell you it is not trivial!
Also, that code above was just one line short (the import for the applet package) of being an SSCCE *(<- link).* Please consider posting SSCCEs in future - you get better chance of help, faster.
Edited by: AndrewThompson64 on Nov 13, 2009 1:42 PM
Similar Messages
-
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. -
how do i open a web page with VeriSign Class 3 Extended Validation SSL SGC SS CA ?
Hi
I am not suprised no one answered your questions, there are simply to many of them. Can I suggest you read the faq on 'how to get help quickly at - http://forums.adobe.com/thread/470404.
Especially the section Don't which says -
DON'T
Don't post a series of questions in a single post. Splitting them into separate threads increases your chances of a quick answer.
PZ
www.pziecina.com -
Safari on iPod touch will no longer open any web pages even after reset.
My iPod touch will no longer open any web pages via Safari. I am connected to WiFi and other apps work fine (mail for example). I connected to Itunes and did a reset - still no luck. S/w is up to date for this version of touch - 4.x.
Please help with any ideas?hello susnyk, please see [[Fix problems connecting to websites after updating Firefox]] &
[[Firefox can't load websites but other browsers can]] -
Can not open any web page in Safari
can not open any web page in Safari on the IPad. All other wireless features work fine.
If this does not work then try a reset ,
Reset your iPad by pressing the 'Sleep' and 'Home' button at the same time for about 15 seconds or so. Your iPad will then go through a reset / reboot procedure and will be ready for use within about a minute.
Don't worry about doing this as you will not lose data or settings.
Good luck and do report back. -
I just updated my Safari to 3.1.2 and now it wont open any web page. I know my system is fine as I also have Firefox and it works great. I have tried reseting Safari, emptying the cache deleting the plist, but nothing works. I have even tried deleting Safari and downloading the latest version from the apple website and re-installing it. No dice either. Safari seems to be working fine but it wont opent any website. Everything just time's out. Any suggestions would be appreciated.
Try this:
Empty Safari's cache (from the Safari menu), then close Safari.
Go to Home/Library/Safari and delete the following files:
form values
download.plist
Then go to Home/Library/Preferences and delete
com.apple.Safari.plist
Repair permissions (in Disk Utility).
Start up Safari again, and things should have improved.
If not, MacFixit have published a very detailed (very!) article on speeding up a slow Safari, here:
http://www.macfixit.com/article.php?story=20070416000657464
Many, including me, have also followed the advice given by others here to add DNS codes to their Network Settings, with good results in terms of speed-up:
Open System Preferences/Network. Double click on your connection type, or select it in the drop-down menu. Click on TCP/IP and in the box marked 'DNS Servers' enter the following two numbers:
208.67.222.220
208.67.220.222
Click on Apply Now and close the window.
Restart Safari, and repair permissions. -
Can't open some web pages... DOES ANYONE HAVE A FIX THAT WORKS?
I'm unable to open certain web pages. The pages will start to open and than the application will just stall. This seems to have coincided with downloading a security update a while back. I've tried downloading firefox and it too will not open these specific pages. I've searched the forum and as of now I can't find a solution. From what I've hear, Apple isn't even acknowledging that there is an issue. I've repaired permissions, deleted Safari plist files, all with no improvement. I know for a fact that it is not my internet connection, as my powerbook can navigate to these sites without any issues, however my powermac seems to have "forgotten" how to open some web pages.
Any fixes would be enourmously appreciated!Thanks for the reply.
I don't think that reporting the pages to apple would do much good as it's not the pages themselves that are the issue, it's something on my system that prevents them from opening up properly. My laptop will open the pages without any issue, however my desktop isn't able to for god knows what reason. I know others on this board have had similar problems. -
My wi-fi connection is enabled, however Safari is telling me the server stopped responding. My laptop is working fine on the same wi-fe network. I have reset the network settings and still Safari will not open any web pages. Help!
Ralph..........Did as you suggested and I am still getting the message "Safari could not open the page because the server stopped responding". I am not able to connect with anything on the Internet. Frustrating since I am able to connect with my laptop. Thanks for the suggestion.
-
My MBP can't open some web pages
Hello.
I have problem with opening some web pages. It doesn't matter on the browser. It happens as in Safari as in Chrome. All browsers are updated. My MPB is updated. Problem is not in router. My gf has the same MBP and she can open the pages which I can't.
Thanks for any advice.
Resume:
Lion 10.7.1, the latest Chrome and Safari, other computers in my network works fine (win/mac), example of page which I can't open: www.adobe.comThanks for the reply.
I don't think that reporting the pages to apple would do much good as it's not the pages themselves that are the issue, it's something on my system that prevents them from opening up properly. My laptop will open the pages without any issue, however my desktop isn't able to for god knows what reason. I know others on this board have had similar problems. -
Safari won't open certain web pages
Hi,
I can't get Safari to open certain web pages. This has only been the case for the last week or so, I could happily view them before.
2 examples are : www.facebook.com and www.quaysws.co.uk
can anybody please help, it just seems a bit weird...I just got this link, http://www.quaysws.co.uk/flash/page1.php,
to open in both Safari and Firefox. Mind you at the same time, I cannot get Apple.com to open in Safari I'm running Leopard with Safari 3.0.4. Whoa Safari just decided that Apple.com does exist and opened it without me first having to restart the computer. Safari definitely has some bugs but you may want to make sure that you don't have any 3rd party add-ons set up and you may have to reinstall. -
When I try to open any web page, a dialog box opens up "Opening search". It asks me 'What should Firefox do with this file?'
The bullets 'Open with Browse' and Sane File.Clear the cache and the cookies from sites that cause problems.
"Clear the Cache":
*Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
"Remove Cookies" from sites causing problems:
*Tools > Options > Privacy > Cookies: "Show Cookies"
Which security software (firewall, anti-virus) do you have?
Some security may alter the HTTP response headers if Firefox is not a trusted application. -
when i try to open a web page, a blue screen appears - message says - sarfari cannot open the page because it is not connected to the internet. i have an iphone - no proble and a laptop - no problem as well.
what is wrong?There are other things that need attention:
Your above posted system details show outdated plugin(s) with known security and stability risks that you should update.
*Shockwave Flash 10.0 r32
Update the [[Managing the Flash plugin|Flash]] plugin to the latest version.
*http://www.adobe.com/software/flash/about/ -
How to open a web page in JFrame.
Please let me know how to open a web page in the Java Frame.
HTML code can be viewed in any Swing component you want.
-
Opening a WEB page from FORMS CS & WebForms
Hi,
We would like to open a Web Page from a forms running in
client/server as well as from a form runningover the web.
Over the web, we plan to use SHOW_DOWUMENT (Even tough it seems
broken, on forms 6.0, the only way we have got it working was by
using the parameter that overwrites the current page (the form),
we cannot have it open an URL in another window)
In C/S mode, the SHOW DOCUMENT does not work. What is the proper
way to lauch an URL in a browser in C/S mode ?
Is there a way to determine if we're running in CS mode or Web
Mode ? We would like to use the same code both on the web and in
C/S
Example pseudo code:
if (Running in CS Mode) then
open the URL using C/S method
else
open the URL with show dowument
fi
Thanks
nulluse '_blank' as parameter, not '_self'.
Guy Dallaire (guest) wrote:
: Hi,
: We would like to open a Web Page from a forms running in
: client/server as well as from a form runningover the web.
: Over the web, we plan to use SHOW_DOWUMENT (Even tough it
seems
: broken, on forms 6.0, the only way we have got it working was
by
: using the parameter that overwrites the current page (the
form),
: we cannot have it open an URL in another window)
: In C/S mode, the SHOW DOCUMENT does not work. What is the
proper
: way to lauch an URL in a browser in C/S mode ?
: Is there a way to determine if we're running in CS mode or Web
: Mode ? We would like to use the same code both on the web and
in
: C/S
: Example pseudo code:
: if (Running in CS Mode) then
: open the URL using C/S method
: else
: open the URL with show dowument
: fi
: Thanks
null -
Whenever I upgrade to FF 26 on my pc laptop I am no longer able to open any web pages on my laptop in any browser. If I reset my system to a previous date I am good to go. Any ideas on what may be going on or how to troubleshoot it? I am not a technical person - btw
My connection to the internet still shows as connected, but I cannot open any web pages.
thanks,
BillIs this happening on a computer running Windows (you posted with as Mac)?
If this is an issue on a Windows computer:
It is possible that security software (firewall, anti-virus) blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.
Remove all rules for Firefox and the plugin-container from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process and the updater process.
See:
*https://support.mozilla.org/kb/Server+not+found
*https://support.mozilla.org/kb/Firewalls
*https://support.mozilla.org/kb/fix-problems-connecting-websites-after-updating
Maybe you are looking for
-
Setting up test environment for EBS
Hi all ! We have r12 setup on RHEL 5.7 servers with SAN storage and 11.1.0.7 database. What are the best practices for setting up test environment for testing patches, fixes, etc. ? Should the test env be an exact replica of the production setup ? Wh
-
Upgrading to MAC OS 10.5.8 from 10.4.11 for new iPhone4 usage
I found out after purchase that I need to upgrade to a newer operating system to use my new phone. (That's OK because I've been meaning to for some time.) Should I go with Leopard or Snow Leopard? What issues should I be on the lookout for when I upg
-
How do I start on Oracle Generic Connectivity?
Hi, I am new to Oracle and can i know where i can get info on setting up Oracle Generic Connectivity to connect Oracle with non-Oracle databases?
-
Hi All, I need to get the employee position title from the PERNR. i am in BI7.0flow. so i can't use 0employee as a master data reference for this employee position title. In the transformations rule can i get the position title from PERNR through rou
-
Sd card reader not in device manager
Hi, I have recently formatted my HP DM1 4118au, and after which, my SD Card reader was undetected by the Device Manager. I have tried to install the Driver but it's still not detected. Any otherway to make it work again, or to diagnose what is wrong