Posts

Showing posts from February, 2009

NetBeans App to Applet Conversion

In an earlier blog , I explored the possibility of moving code from one NetBeans project to another. To cut a long story short, it was pretty much a case of dragging source files and classes from one project and dropping them into another. This experiment was with two projects of the same type (both applications), but I was hoping I could try the same technique dragging code and objects from a desktop application to a web application. And again to make a long story short, I couldn't make it work. NetBeans is very clever the way it helps you set things out on a form (or jframe, as they call it) with everything nicely lined up and the right size. It is also very clever the way it writes a lot of code, all with the right syntax. Against this, I find that if you want to do anything beyond plain vanilla, the help files are singularly unhelpful, and the tutorials seem simply to replicate the help files. I also find it annoying that I am locked out of code in NetBeans

Converting Applications to Applets

As luck would have it, the bit that I am particularly interested in, Converting Applications to Applets, crops up quite early in the getting started with Applets lesson . The section opens with a paragraph on the technical differences between an application and an applet, and then goes on to outline what it calls the "basic steps ... to convert an application program into an applet program.". I quote: You need to create a subclass of java.applet.Applet in which you override the init method to initialize your applet's resources the same way the main method initializes the application's resources. init might be called more than once and should be designed accordingly. Moreover, the top-level Panel needs to be added to the applet in init ; usually it was added to a Frame in main . That's it! When I read the words "That's it" after two short bullet points, I am lead to believe that what is being explained is

The Hello World Applet

Image
Editorial Note: I have removed some of the links on this page because the tutorial has been updated; the old links don't work, and the applet code has been changed since this blog entry was made. So the "next" lesson in the trail is Getting Started with Applets . I hate hello world, but after the last lesson I'm quite pleased to see it. At least it provides a scrap of code to play with. If I can embed this applet into my web page, it will improve my understanding, and if it works, it will make me feel better. So to facilitate the process, I check out the source code for the page. The first thing I notice is that the code calling the applet on this page is completely different to the example on the previous page. The example given was: <applet code=AppletWorld.class width="200" height="200"> </applet> But the code used to call the Hello World applet is: < applet code = "HelloWorld.class" codebase =

Java Applets

There are more lessons in the Java Webstart Trail , but quite frankly the effort I have expended so far way exceeds any benefit. After many days of fiddling, I got my application to run using Webstart. But my commercial ISP does not support jnlp files, so I had to host the app on my own server, which is not available 24/7. And the end user is required to have Webstart installed. Frankly anyone, with the skill or the energy or the inclination to install Webstart, could just as well run the app from the command line. So I shall now look at embedding an applet in a web page. This takes me to a thread entitled Creating and Deploying Applets with Java Plug-in , and the index lesson is simply entitled Applets . It opens well: "This lesson talks about the basics of applets, advantages of applets over applications, how to load applets in a web page, how to convert applications to applets and how applets work". These are exactly the things I want to know. Let&#

Windows 7 upgrade and networking issues

As a general rule, when I test an OS I do so on a clean drive, or at least an empty sector. But when I was browsing through the MS fora looking for ideas on the network dysfunction it seemed that a number of punters were using the upgrade option, and even that MS intended people to this. So I ghosted my working XP drive to an experimental drive, booted to that drive, and full of optimism, inserted my Win 7 DVD. Everything seemed to begin well, but then after a few minutes a dialog box appeared with the message: Windows Setup experienced an unexpected error. To install Windows, restart the installation. Error code: 0x0. I am not surprised, but I am disappointed. This is pathetic. Vista was way better than this. I opted not to buy Vista, but I didn't hate it. I just thought it wasn't worth shelling out hundred of dollars. But Win7 seems to be a complete botch. The feeble opening pic, even the name seems to suggest that MS is losing heart, if not the plot

Tinkering with the JNLP File

The lesson Deploying Java Web Start Applications includes the statement: "The following table describes the elements and attributes in the sample JNLP file". This statement is not true, because the table does not include the j2se element. However the lesson redeems itself with the following admission: Note : This table does not include all possible contents of the JNLP file. For more information, see the Java Network Launching Protocol & API Specification (JSR-56) . Quite frankly, the lesson would be as useful if this note (or at least the link) were the only the only content in it. The answer to my earlier question on the main attribute of the jar element is included in the specs, and it turns out that my "logical" guess was wrong. That line in my jnlp file should in fact read: <jar href="ActiveMathJA002.jar" main="true"/> But in fact when I substituted that line, the app still would not run. The error message

Windows 7

A review of Windows 7 belongs here only to the extent that I am running Java from Windows, and it is quite interesting to know how easy it will be to rebuild everything I had working in XP. I am building Win7 on a clean drive because I want to be able to go back to XP as simply as moving a cable from one drive to another. My first impression was disappointing. I loved the default background pic in Vista - it was so clean and crisp. The default pic in Win 7 looks cheap and half rate. The impression is more like trying out a lame Linux distro than I would expect from a new product from MS. Fixing the pic was easy, but it was more disappointing still to find my network was dead. I am using an Asus P5K. Asus is not exactly an unknown brand, and I bought the board 18 months ago, so how come Win7 didn't ship with the drivers? And of all the things to lose, the network is most annoying, because you either have to start fiddling with hardware, or you have to use both