Solved

visual components behavior

Posted on 1998-03-18
4
188 Views
Last Modified: 2010-04-16
hi,

i derived a button from a button component to add a feature of being "stuck" (not raising after the user released the mouse button).
all i do is override the paint method (and update) and changing the state of the button to 'pressed' before calling super.paint(g) (for as long as i need it to remain pressed).

this works well in appletviewer.

on netscape on the other hand there is this weird fenomena: i press the button, release the mouse button, move to another place (in the applet space), then the button suddenly 'decides' to raise itself. but, if i take another window (in the win95 environment, not a jave window) and move it on the button (cover it) and then move it back the button paints itself as pressed again (with out any events in the applet).  

so i did 2 things:
a. i added System.err.println commands to show the state of the button before it paints (i see this in the java console of netcape) and indeed it stil has the press state.
b. i copied the entire paint code to my method (without call to super.paint(g)). the code seems to work ok (and it does under appletviewer), but in netscape....

so have any ideas on the subject?

thanks,
ittay
0
Comment
Question by:ittay
  • 2
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
jpk041897 earned 100 total points
ID: 1233634
Netscape send refresh messages to all elements contained in the browser area whenever the browser area gets updated, like when an immage or text is loaded and displayed, or when a part of the browser is covered by another window and redisplayed.

You need to bracket your display data using a state variable that controls which immage to display.

There is an article at:

http://www.javaworld.com/javaworld/jw-03-1997/jw-03-imagebutton.html

that contains code for a three state button in an applet that works fine on both IE and Netscape that you might want to look at.
0
 

Author Comment

by:ittay
ID: 1233635
to jpk:
i derived from a button which has this state variable. the problem was that it automaticaly sets it to unselect on various events. i tried overriding the paint method and resetting it before calling super.paint(g). that didn't help (neither doing that in update). i think this is because the component uses various item painters and view managers which don't paint it right away but query its state variable after a while (giving it a chance to undo my setting). what i finally did is to override all the processXXXX methods which changed the state and reset it after calling super.process...

since you helped me so much until now, i've accepted your answer :)
ittay
0
 

Author Comment

by:ittay
ID: 1233636
to jpk:
i derived from a button which has this state variable. the problem was that it automaticaly sets it to unselect on various events. i tried overriding the paint method and resetting it before calling super.paint(g). that didn't help (neither doing that in update). i think this is because the component uses various item painters and view managers which don't paint it right away but query its state variable after a while (giving it a chance to undo my setting). what i finally did is to override all the processXXXX methods which changed the state and reset it after calling super.process...

since you helped me so much until now, i've accepted your answer :)
ittay
0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1233637
OK, Thanks.


0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now