473,783 Members | 2,545 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Java Applets work fine in NS 4.79 but not working in IE6 / NS 7.1 ?

Hi All,

I am a relative newbie to Java / Applets, but am despirately after
some help !

I have got the following code, which is basically a listing with
button items along the sides, allowing the items in the list to be
moved up/down etc.

Obviously, for the top and bottom items, the appropriate move up /
move down buttons should be disabled.

The bit I am interested in is setButtons() method, which when
conditions are true, sets the _unrankedButton enabled property to
true, which in turn calls the code I have written for iButton for
which _unrankedButton has been declared as.

This then performs the appropriate tasks, and repaints the screen to
show any button updates in the void paint method.

Unfortunately, when I added some debug into the code, it is clear to
see that although Netscape 4.79 works fine, calling the setButtons
method, which in turn initiated the line :

g.drawImage(isE nabled() ? _image : _disabled, 1, 1, this);

which updates and repainting the buttons, but I cannot get this to
work in IE 6 or Netscape 7.1 both browsers I need to cater for ! The
logic behind the button is changed to disable / enable it, but the
buttons are bot repainted.

Is this something glaringly obvious that I am missing, or is there a
reason why buttons are not getting repainted browsers other than
Netscape 4.79 ?

If anyone can help me out or offer any insight into what I am doing
wrong, or how I can fix this, I would be really grateful !!!

Thanks in advance, and apologise in advance if my terminology is not
the best !

Martin

P.S. Sorry for the length of this post. I was unsure how much info. /
code would be useful
import java.awt.Color;
import java.awt.Compon ent;
import java.awt.Contai ner;
import java.awt.FlowLa yout;
import java.awt.Font;
import java.awt.GridBa gConstraints;
import java.awt.GridBa gLayout;
import java.awt.GridLa yout;
import java.awt.Image;
import java.awt.Insets ;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event. ItemEvent;
import java.awt.event. ItemListener;
import java.awt.event. MouseAdapter;
import java.awt.event. MouseEvent;
import java.util.Obser vable;
import java.util.Obser ver;
import java.util.Vecto r;

public class RankedView extends Panel
implements Observer
{
class _cls6 extends MouseAdapter
{

public void mousePressed(Mo useEvent me)
{
rankDown(10);
}

_cls6()
{
}
}

class _cls5 extends MouseAdapter
{

public void mousePressed(Mo useEvent me)
{
rankDown(1);
}

_cls5()
{
}
}

class _cls4 extends MouseAdapter
{

public void mousePressed(Mo useEvent me)
{
rankUp(1);
}

_cls4()
{
}
}

class _cls3 extends MouseAdapter
{

public void mousePressed(Mo useEvent me)
{
rankUp(10);
}

_cls3()
{
}
}

class _cls2
implements ItemListener
{

public void itemStateChange d(ItemEvent ie)
{
setButtons();
}

_cls2()
{
}
}

class _cls1 extends MouseAdapter
{

public void mousePressed(Mo useEvent me)
{
unrank();
}

_cls1()
{
}
}
public RankedView(Requ estModel m, Image images[])
{
_model = m;
GridBagLayout gbm = new GridBagLayout() ;
setLayout(gbm);
iLabel l1 = new iLabel(images[10]);
GridBagConstrai nts gbc1 = new GridBagConstrai nts();
gbc1.gridx = 0;
gbc1.gridy = 0;
gbc1.insets = new Insets(10, 42, 0, 0);
gbc1.anchor = 17;
gbm.setConstrai nts(l1, gbc1);
add(l1);
_heading = new Label("Rank Rating ID Status
Name");
GridBagConstrai nts gbc2 = new GridBagConstrai nts();
gbc2.gridx = 0;
gbc2.gridy = 1;
gbc2.insets = new Insets(0, 45, 0, 0);
gbc2.anchor = 17;
gbm.setConstrai nts(_heading, gbc2);
add(_heading);
Panel ranker = new Panel();
((FlowLayout)ra nker.getLayout( )).setVgap(0);
_unrankButton = new iButton(images[0]);
_unrankButton.a ddMouseListener (new _cls1());
ranker.add(_unr ankButton);
_rankList = new SizeList(15, false);
_rankList.setSi ze(300, 275);
_rankList.addIt emListener(new _cls2());
ranker.add(_ran kList);
Panel updown = new Panel(new GridLayout(4, 1));
_bigUpButton = new iButton(images[1]);
_bigUpButton.ad dMouseListener( new _cls3());
updown.add(_big UpButton);
_upButton = new iButton(images[2]);
_upButton.addMo useListener(new _cls4());
updown.add(_upB utton);
_downButton = new iButton(images[3]);
_downButton.add MouseListener(n ew _cls5());
updown.add(_dow nButton);
_bigDownButton = new iButton(images[4]);
_bigDownButton. addMouseListene r(new _cls6());
updown.add(_big DownButton);
ranker.add(updo wn);
GridBagConstrai nts gbc3 = new GridBagConstrai nts();
gbc3.gridx = 0;
gbc3.gridy = 2;
gbc3.anchor = 10;
gbm.setConstrai nts(ranker, gbc3);
add(ranker);
}

public void setHeadingColou r(Color c)
{
_heading.setFor eground(c);
}

public void setHeadingFont( Font f)
{
_heading.setFon t(f);
}

public void update(Observab le obs, Object o)
{
RequestRow row = null;
Vector rlist = _model.getRanke d();
int selected = _rankList.getSe lectedIndex();
if(rlist.size() > _rankList.getIt emCount())
selected = _rankList.getIt emCount();
_rankList.remov eAll();
for(int n = 0; n < rlist.size(); n++)
{
row = (RequestRow)rli st.elementAt(n) ;
_rankList.add(d isplayRow(row)) ;
}

selected = Math.min(select ed, _rankList.getIt emCount() - 1);
_rankList.selec t(selected);
setButtons();
}

public void save()
{
_model.save();
}

public String displayRow(Requ estRow row)
{
String spaces = " ";
String gap = " ";
String id = null;
String rank = null;
rank = spaces + row.getRanking( );
rank = rank.substring( rank.length() - 2);
id = spaces + row.getId();
id = id.substring(id .length() - 6);
return rank + gap + row.getRating() + gap + id + gap +
row.getStatus() + gap + row.getName();
}

public String getName(int index)
{
String name = null;
if(index >= 0)
name = _rankList.getIt em(index).subst ring(16);
return name;
}

public String getSelectedName ()
{
String name = null;
int index = _rankList.getSe lectedIndex();
return getName(index);
}

public void unrank()
{
String name = getSelectedName ();
if(name != null)
_model.setUnran ked(name);
}

public void rankUp(int times)
{
int index = _rankList.getSe lectedIndex();
for(int n = 0; n < times; n++)
if(index > 0 && index < _rankList.getIt emCount())
{
String name = getSelectedName ();
String above = getName(index - 1);
_model.swap(nam e, above);
index--;
}

_rankList.selec t(index);
_model.notifyOb servers();
}

public void rankDown(int times)
{
int index = _rankList.getSe lectedIndex();
for(int n = 0; n < times; n++)
if(index >= 0 && index < _rankList.getIt emCount() - 1)
{
String name = getSelectedName ();
String below = getName(index + 1);
_model.swap(nam e, below);
index++;
}

_rankList.selec t(index);
_model.notifyOb servers();
}

protected void setButtons()
{
int count = _rankList.getIt emCount();
int selected = _rankList.getSe lectedIndex();
if(count > 0 && selected >= 0)
{
_unrankButton.s etEnabled(true) ;
_bigUpButton.se tEnabled(select ed != 0);
_upButton.setEn abled(selected != 0);
_bigDownButton. setEnabled(sele cted != count - 1);
_downButton.set Enabled(selecte d != count - 1);
} else
{
_unrankButton.s etEnabled(false );
_bigUpButton.se tEnabled(false) ;
_upButton.setEn abled(false);
_bigDownButton. setEnabled(fals e);
_downButton.set Enabled(false);
}
}

protected RequestModel _model;
protected SizeList _rankList;
protected iButton _unrankButton;
protected iButton _bigUpButton;
protected iButton _upButton;
protected iButton _bigDownButton;
protected iButton _downButton;
protected Label _heading;
}
*************** *************** *************** *************** ********
import java.awt.*;
import java.awt.event. MouseAdapter;
import java.awt.event. MouseEvent;
import java.awt.image. FilteredImageSo urce;

public class iButton extends Canvas
{
class _cls2 extends MouseAdapter
{

public void mousePressed(Mo useEvent me)
{
_image = _pressed;
repaint();
}

public void mouseReleased(M ouseEvent me)
{
_image = _normal;
repaint();
}

_cls2()
{
}
}

class _cls1 extends MouseAdapter
{

public void mouseEntered(Mo useEvent me)
{
setCursor(Curso r.getPredefined Cursor(12));
}

public void mouseExited(Mou seEvent me)
{
setCursor(Curso r.getDefaultCur sor());
}

_cls1()
{
}
}
public iButton(Image image)
{
_normal = image;
_image = _normal;
_pressed = null;
_disabled = createImage(new
FilteredImageSo urce(_normal.ge tSource(), new
FadeFilter(Colo r.white)));
addMouseListene r(new _cls1());
}

public iButton(Image image, Image pressed)
{
this(image);
if(pressed != null)
{
_pressed = pressed;
addMouseListene r(new _cls2());
}
}

public Dimension getMinimumSize( )
{
return new Dimension(_imag e.getWidth(this ) + 2,
_image.getHeigh t(this) + 2);
}

public Dimension getPreferredSiz e()
{
return getMinimumSize( );
}

public void paint(Graphics g)
{
g.drawImage(isE nabled() ? _image : _disabled, 1, 1, this);
}

private Image _image;
private Image _normal;
private Image _pressed;
private Image _disabled;

}
Jul 17 '05 #1
0 1790

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5766
by: Dave D | last post by:
I just read something that spooked me. I'm a newbie working my way through "SAMS Teach Youself Java 2 in 21 Days." I used to code a bit in Symantec's Visual Cafe for Java about 3 years ago, but those brain cells are now gone... This book seems to imply that applets built with Java 2 (SDK 1.4) won't run in IE! It says IE only supports Java 1.0 and 1.1. As my primary aim is to build an applet for sharing from my personal web page, I'm...
1
2638
by: Rick | last post by:
Hi, I'm having problems with Java applets. I just generated a JApplet (also tried normal Applet) in Netbeans which is delivered with the newest JDK. When I compile it in Netbeans it seems to work fine. But when I try outside Netbeans by opening the html page which is automatically generated I only see a gray area where the applet was supposed to be... I tried some other example applets on the internet. Some work but also many won't show...
1
4691
by: Put 030516 in email subj to get thru | last post by:
I have a nice little applet on my web page at: www.benslade.com/pictures/2003/jul/alaska/images/Ben's_Alaska_Vacation_Slideshow.html (yes, that's an apostrophe in the URL, sorry) It runs fine everywhere except for MS-IE 6.x browsers. There I just get a grey screen where the applet is supposed to go. If I enable the Java console log, I see a "ClassNotFound" exception coming from Microsoft's Java VM (no explicit popup error message...
73
8073
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities as a standard portable part of the core language, the LISP package, and the java.lang package, respectively. Both have big integers, although only LISP has rationals as far as I can tell. Because CL supports keyword arguments, it has a wider range...
1
1842
by: Bradley1234 | last post by:
For some reason, on my win2000 sp4, newly updated generic Intel Pentium system, java applets on web pages stopped working This was about the time I downloaded the Microsoft Web developer beta tool, but am not sure. Ive been over and over the java settings, trying to get weather applets I used to check daily. setting the weather sites to "trusted site" and all permissions to lowest level, no, java applets just do not work.
2
2286
by: erik | last post by:
I'm working on a project which will test users abilities to guess a series of randomly generated pitches. The users need to be able to access the program via the web and the results will either be saved on the server hosting the webpage or will be emailed those evaluating the test. Is there a C# equivalent to Java applets to allow my program to run on the web? Do I need to use an Active Server Page? Or is ASP just a way to create dynamic...
1
9654
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
2
6967
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.