Solved

visual components behavior

Posted on 1998-03-18
4
199 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Spring Framework HTTPSession management 1 45
session migration servlets 2 42
Maven Project: Hibernate Dependencies Conflict 10 40
java stored proc example 9 44
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

828 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