Solved

visual components behavior

Posted on 1998-03-18
4
204 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SHA2 certs for IIS AND Java? 2 134
by zero exception 10 79
Java: anonymous class 4 52
Pass multiple values or string arrays in java as a parameter 3 72
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

738 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