How to Fix Drop-down Box Conflict in Applet

I am unable to run an applet and use a drop-downbox on the same page when using Netscape. The page hasmassive flickering and the applet will sometimes run. Theapplet runs just fine without the drop-down boxes.

Any suggestions?

I assume you’re referring to the Choice widget, which createsa popup window to allow the user to select one of several possibilities.Netscape’s implementation of java.awt.Choice is known to beextremely buggy, but there are work-arounds for some of theproblems.

For instance, Netscape doesn’t allow applets to set the defaultforeground and background colors of a Choice object, or set itsFont and Font Style. While AWT components normally inherit thesecharacteristics from their parent components, Netscape’s implementationof Choice always uses the default settings. Appletviewer doesn’texhibit this problem.

Another problem with Choice objects in Netscape is that they don’tredraw themselves properly. If your applet decides to set thechoice itself (not in response to user input) the Choiceobject will not redraw itself. It’ll go blank until the nextredraw event is received by the widget.

The massive flickering you mention is probably due to the eventhandling for that object. You have to be careful which eventsyou trap and handle.

In my experience, the following work-around seems to bypassmost of the fatal problems:

To handle Choice events, use:

       public boolean handleEvent(Event e) {               // To avoid flicker, make sure you’re not handling               // FOCUS events or other misc events               if ( instanceof Choice && == Event.ACTION_EVENT) {                       int i = selChoice.getSelectedIndex();                       // Do something with i …                       // You need this in order to force Netscape to                       // draw the Choice widget again                       selChoice.addNotify();                       return true;               }               return false;       }
Similarly, whenever the applet wants to set the Choice to aparticular item, make sure you call addNotify() rightafterwards:;       selChoice.addNotify();
Note that none of the other redraw methods including repaint() andpaint() do the trick with Netscape’s implementation ofChoice.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS