473,396 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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(isEnabled() ? _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.Component;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
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.Observable;
import java.util.Observer;
import java.util.Vector;

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

public void mousePressed(MouseEvent me)
{
rankDown(10);
}

_cls6()
{
}
}

class _cls5 extends MouseAdapter
{

public void mousePressed(MouseEvent me)
{
rankDown(1);
}

_cls5()
{
}
}

class _cls4 extends MouseAdapter
{

public void mousePressed(MouseEvent me)
{
rankUp(1);
}

_cls4()
{
}
}

class _cls3 extends MouseAdapter
{

public void mousePressed(MouseEvent me)
{
rankUp(10);
}

_cls3()
{
}
}

class _cls2
implements ItemListener
{

public void itemStateChanged(ItemEvent ie)
{
setButtons();
}

_cls2()
{
}
}

class _cls1 extends MouseAdapter
{

public void mousePressed(MouseEvent me)
{
unrank();
}

_cls1()
{
}
}
public RankedView(RequestModel m, Image images[])
{
_model = m;
GridBagLayout gbm = new GridBagLayout();
setLayout(gbm);
iLabel l1 = new iLabel(images[10]);
GridBagConstraints gbc1 = new GridBagConstraints();
gbc1.gridx = 0;
gbc1.gridy = 0;
gbc1.insets = new Insets(10, 42, 0, 0);
gbc1.anchor = 17;
gbm.setConstraints(l1, gbc1);
add(l1);
_heading = new Label("Rank Rating ID Status
Name");
GridBagConstraints gbc2 = new GridBagConstraints();
gbc2.gridx = 0;
gbc2.gridy = 1;
gbc2.insets = new Insets(0, 45, 0, 0);
gbc2.anchor = 17;
gbm.setConstraints(_heading, gbc2);
add(_heading);
Panel ranker = new Panel();
((FlowLayout)ranker.getLayout()).setVgap(0);
_unrankButton = new iButton(images[0]);
_unrankButton.addMouseListener(new _cls1());
ranker.add(_unrankButton);
_rankList = new SizeList(15, false);
_rankList.setSize(300, 275);
_rankList.addItemListener(new _cls2());
ranker.add(_rankList);
Panel updown = new Panel(new GridLayout(4, 1));
_bigUpButton = new iButton(images[1]);
_bigUpButton.addMouseListener(new _cls3());
updown.add(_bigUpButton);
_upButton = new iButton(images[2]);
_upButton.addMouseListener(new _cls4());
updown.add(_upButton);
_downButton = new iButton(images[3]);
_downButton.addMouseListener(new _cls5());
updown.add(_downButton);
_bigDownButton = new iButton(images[4]);
_bigDownButton.addMouseListener(new _cls6());
updown.add(_bigDownButton);
ranker.add(updown);
GridBagConstraints gbc3 = new GridBagConstraints();
gbc3.gridx = 0;
gbc3.gridy = 2;
gbc3.anchor = 10;
gbm.setConstraints(ranker, gbc3);
add(ranker);
}

public void setHeadingColour(Color c)
{
_heading.setForeground(c);
}

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

public void update(Observable obs, Object o)
{
RequestRow row = null;
Vector rlist = _model.getRanked();
int selected = _rankList.getSelectedIndex();
if(rlist.size() > _rankList.getItemCount())
selected = _rankList.getItemCount();
_rankList.removeAll();
for(int n = 0; n < rlist.size(); n++)
{
row = (RequestRow)rlist.elementAt(n);
_rankList.add(displayRow(row));
}

selected = Math.min(selected, _rankList.getItemCount() - 1);
_rankList.select(selected);
setButtons();
}

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

public String displayRow(RequestRow 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.getItem(index).substring(16);
return name;
}

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

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

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

_rankList.select(index);
_model.notifyObservers();
}

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

_rankList.select(index);
_model.notifyObservers();
}

protected void setButtons()
{
int count = _rankList.getItemCount();
int selected = _rankList.getSelectedIndex();
if(count > 0 && selected >= 0)
{
_unrankButton.setEnabled(true);
_bigUpButton.setEnabled(selected != 0);
_upButton.setEnabled(selected != 0);
_bigDownButton.setEnabled(selected != count - 1);
_downButton.setEnabled(selected != count - 1);
} else
{
_unrankButton.setEnabled(false);
_bigUpButton.setEnabled(false);
_upButton.setEnabled(false);
_bigDownButton.setEnabled(false);
_downButton.setEnabled(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.FilteredImageSource;

public class iButton extends Canvas
{
class _cls2 extends MouseAdapter
{

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

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

_cls2()
{
}
}

class _cls1 extends MouseAdapter
{

public void mouseEntered(MouseEvent me)
{
setCursor(Cursor.getPredefinedCursor(12));
}

public void mouseExited(MouseEvent me)
{
setCursor(Cursor.getDefaultCursor());
}

_cls1()
{
}
}
public iButton(Image image)
{
_normal = image;
_image = _normal;
_pressed = null;
_disabled = createImage(new
FilteredImageSource(_normal.getSource(), new
FadeFilter(Color.white)));
addMouseListener(new _cls1());
}

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

public Dimension getMinimumSize()
{
return new Dimension(_image.getWidth(this) + 2,
_image.getHeight(this) + 2);
}

public Dimension getPreferredSize()
{
return getMinimumSize();
}

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

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

}
Jul 17 '05 #1
0 1765

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

Similar topics

8
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...
1
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...
1
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...
73
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...
1
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...
2
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...
1
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.